diff options
author | Raphael Kabo <raphaelkabo@hey.com> | 2024-03-29 11:20:49 +0000 |
---|---|---|
committer | Raphael Kabo <raphaelkabo@hey.com> | 2024-05-26 16:05:32 +0100 |
commit | 0f6c06d3b37dbc277b211521a062223d96c540d0 (patch) | |
tree | 7b8dfe90b4c116028827186eaae5bd468e9fa406 /src/routes | |
parent | 42fea055924bfa55991720f2f6b01ec111985200 (diff) |
Refactor instance description
Diffstat (limited to 'src/routes')
-rw-r--r-- | src/routes/frontend.ts | 31 |
1 files changed, 8 insertions, 23 deletions
diff --git a/src/routes/frontend.ts b/src/routes/frontend.ts index 4e6f3ed..86ad69c 100644 --- a/src/routes/frontend.ts +++ b/src/routes/frontend.ts @@ -3,7 +3,11 @@ import fs from "fs"; import moment from "moment-timezone"; import { marked } from "marked"; import { markdownToSanitizedHTML, renderPlain } from "../util/markdown.js"; -import { frontendConfig, instanceRules } from "../lib/config.js"; +import { + frontendConfig, + instanceDescription, + instanceRules, +} from "../lib/config.js"; import { addToLog, exportICal } from "../helpers.js"; import Event from "../models/Event.js"; import EventGroup, { IEventGroup } from "../models/EventGroup.js"; @@ -27,6 +31,7 @@ router.get("/", (_: Request, res: Response) => { return res.render("home", { ...frontendConfig(res), instanceRules: instanceRules(), + instanceDescription: instanceDescription(), }); }); @@ -34,6 +39,7 @@ router.get("/about", (_: Request, res: Response) => { return res.render("home", { ...frontendConfig(res), instanceRules: instanceRules(), + instanceDescription: instanceDescription(), }); }); @@ -122,33 +128,12 @@ router.get("/events", async (_: Request, res: Response) => { }; }); - // Attempt to pull the instance description from a Markdown file - 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, - res.locals.config?.general.site_name, - ); - } catch (err) { - console.log(err); - } - res.render("publicEventList", { title: "Public events", upcomingEvents: upcomingEvents, pastEvents: pastEvents, eventGroups: updatedEventGroups, - instanceDescription, + instanceDescription: instanceDescription(), instanceRules: instanceRules(), ...frontendConfig(res), }); |