2022-11-10 00:12:34 +05:30
|
|
|
import type { PageServerLoad } from "./$types";
|
2022-11-29 21:12:15 +05:30
|
|
|
import { compile } from "mdsvex";
|
2023-01-06 02:11:28 +05:30
|
|
|
import sanitizeHtml from "sanitize-html";
|
2022-12-30 22:32:49 +05:30
|
|
|
import db from "$lib/db";
|
2022-11-10 00:12:34 +05:30
|
|
|
|
|
|
|
export const load: PageServerLoad = async () => {
|
2022-12-30 22:32:49 +05:30
|
|
|
const Announcements = db.model("Announcements");
|
|
|
|
|
|
|
|
const data = await Announcements.findAll().then((docs) => {
|
|
|
|
return docs.map((doc) => doc.get());
|
|
|
|
});
|
|
|
|
|
2023-01-06 02:11:28 +05:30
|
|
|
const sanitizedContent = sanitizeHtml(data[0].title)
|
|
|
|
|
2022-12-30 22:32:49 +05:30
|
|
|
if (data.length !== 0 || data[0] !== undefined) {
|
|
|
|
return {
|
|
|
|
announcements: data[0],
|
2023-01-06 02:11:28 +05:30
|
|
|
content: compile(sanitizedContent).then((compiled) => compiled?.code)
|
2022-12-30 22:32:49 +05:30
|
|
|
}
|
|
|
|
}
|
2022-12-27 20:58:47 +05:30
|
|
|
};
|