teasanctuary.ru/src/routes/+page.ts

16 lines
No EOL
497 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { fetchPostsSorted, sortPostsByPostAndUpdateDate } from "$src/lib/util/Blogs";
const LATEST_POSTS_COUNT = 5;
export async function load() {
let md: any
try {
md = await import("$src/pages/index.md");
} catch (ex) {
throw "Не удалось найти текст для главной страницы";
}
return {
content: md.default,
posts: (await fetchPostsSorted(sortPostsByPostAndUpdateDate)).slice(0, LATEST_POSTS_COUNT)
};
}