Страница заметки в блоге

This commit is contained in:
Иван Кузьменко 2025-09-29 03:22:58 +03:00
parent f79762b1e0
commit f0a361c56d
4 changed files with 124 additions and 1 deletions

View file

@ -1,5 +1,7 @@
import path from 'path';
export const THUMBNAIL_DEFAULT = "https://teasanctuary.ru/common/background-day.webp";
export async function fetchPostsSorted() {
const allPosts = await fetchPosts();
@ -8,7 +10,7 @@ export async function fetchPostsSorted() {
.filter((a) => !!a.date)
.sort((a, b) => {
return new Date(b.date!).valueOf() - new Date(a.date!).valueOf();
});
});
return sortedPosts;
};
@ -31,3 +33,11 @@ export async function fetchPosts() {
return allPosts;
};
export function resolveBlogPath(slug?: string, src?: string) {
if (!src) return null;
return src.startsWith('http://') || src.startsWith('https://')
? src
: `/blog/${slug}/${src}`;
}