mirror of
https://github.com/ProjectSegfault/website.git
synced 2024-11-18 14:13:00 +05:30
22 lines
585 B
TypeScript
22 lines
585 B
TypeScript
import type { PageServerLoad } from "./$types";
|
|
import { compile } from "mdsvex";
|
|
import sanitizeHtml from "sanitize-html";
|
|
import db from "$lib/db";
|
|
|
|
export const load: PageServerLoad = async () => {
|
|
const Announcements = db.model("Announcements");
|
|
|
|
const data = await Announcements.findAll().then((docs) => {
|
|
return docs.map((doc) => doc.get());
|
|
});
|
|
|
|
const sanitizedContent = sanitizeHtml(data[0].title)
|
|
|
|
if (data.length !== 0 || data[0] !== undefined) {
|
|
return {
|
|
announcements: data[0],
|
|
content: compile(sanitizedContent).then((compiled) => compiled?.code)
|
|
}
|
|
}
|
|
};
|