mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
feat(api): ✨ Add TOS and Privacy Policy support
This commit is contained in:
parent
e9e33432c2
commit
ffcf01e3cd
12 changed files with 180 additions and 33 deletions
31
utils/markdown.ts
Normal file
31
utils/markdown.ts
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import { markdownParse } from "~/database/entities/Status";
|
||||
import { LogLevel } from "~/packages/log-manager";
|
||||
import { dualLogger } from "./loggers";
|
||||
|
||||
export const renderMarkdownInPath = async (
|
||||
path: string,
|
||||
defaultText?: string,
|
||||
) => {
|
||||
let content = await markdownParse(defaultText ?? "");
|
||||
let lastModified = new Date(1970, 0, 0);
|
||||
|
||||
const extended_description_file = Bun.file(path || "");
|
||||
|
||||
if (path && (await extended_description_file.exists())) {
|
||||
content =
|
||||
(await markdownParse(
|
||||
(await extended_description_file.text().catch(async (e) => {
|
||||
await dualLogger.logError(LogLevel.ERROR, "Routes", e);
|
||||
return "";
|
||||
})) ||
|
||||
defaultText ||
|
||||
"",
|
||||
)) || "";
|
||||
lastModified = new Date(extended_description_file.lastModified);
|
||||
}
|
||||
|
||||
return {
|
||||
content: content,
|
||||
lastModified,
|
||||
};
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue