Типы блог-постов

This commit is contained in:
Иван Кузьменко 2025-10-22 08:32:10 +03:00
parent 0643f48189
commit 451d064dea
4 changed files with 50 additions and 6 deletions

View file

@ -1,5 +1,3 @@
import path from 'path';
export const THUMBNAIL_DEFAULT = "https://teasanctuary.ru/common/background-day.webp";
export const BLOG_POST_FRESHNESS_MILLIS = 3 * 24 * 60 * 60 * 1000; // 3 дня
@ -60,4 +58,24 @@ export function resolveBlogPath(slug?: string, src?: string) {
return src.startsWith('http://') || src.startsWith('https://')
? src
: `/blog/${slug}/${src}`;
}
}
const bptToString: Record<App.BlogPostType, string> = {
'article': 'Заметка',
'event': 'Событие',
'update': 'Обновление'
};
const bptToIcon: Record<App.BlogPostType, string> = {
'article': 'material-symbols:article',
'event': 'material-symbols:event',
'update': 'material-symbols:autorenew'
};
export function blogPostTypeToString(type: App.BlogPostType): string {
return bptToString[type] ?? bptToString['article'];
}
export function blogPostTypeToIcon(type: App.BlogPostType): string {
return bptToIcon[type] ?? bptToIcon['article'];
}