diff options
author | Raphael <mail@raphaelkabo.com> | 2024-05-26 19:12:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-26 19:12:37 +0100 |
commit | 43296cd88b9ab6f3ba1d5f4de5f76f44b68de82a (patch) | |
tree | 9738de17d2be368ffc95f90644dbf98220c2a136 /src/lib/config.ts | |
parent | 53288fa3df3f828e99eaba679d436e65def2deb4 (diff) | |
parent | 4ce9c7d32fd834ff1dc87b7dd90f7428ad0eb44d (diff) |
Merge pull request #138 from lowercasename/rk/style-overhaul
Style overhaul
Diffstat (limited to 'src/lib/config.ts')
-rw-r--r-- | src/lib/config.ts | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/lib/config.ts b/src/lib/config.ts index 4bc43bd..b4086d8 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -2,6 +2,7 @@ import fs from "fs"; import toml from "toml"; import { exitWithError } from "./process.js"; import { Response } from "express"; +import { markdownToSanitizedHTML } from "../util/markdown.js"; interface StaticPage { title: string; @@ -152,6 +153,31 @@ export const instanceRules = (): InstanceRule[] => { return rules; }; +export const instanceDescription = (): string => { + const config = getConfig(); + const defaultInstanceDescription = + "**{{ siteName }}** is running on Gathio — a simple, federated, privacy-first event hosting platform."; + let instanceDescription = defaultInstanceDescription; + try { + if (fs.existsSync("./static/instance-description.md")) { + const fileBody = fs.readFileSync( + "./static/instance-description.md", + "utf-8", + ); + instanceDescription = markdownToSanitizedHTML(fileBody); + } + // Replace {{siteName}} with the instance name + instanceDescription = instanceDescription.replace( + /\{\{ ?siteName ?\}\}/g, + config?.general.site_name, + ); + return instanceDescription; + } catch (err) { + console.log(err); + return defaultInstanceDescription; + } +}; + // Attempt to load our global config. Will stop the app if the config file // cannot be read (there's no point trying to continue!) export const getConfig = (): GathioConfig => { |