Добавил скрытие постов без даты публикации и пример скрытого поста

This commit is contained in:
Иван Кузьменко 2025-09-29 02:19:38 +03:00 committed by Иван Кузьменко
parent fb9f52b254
commit 715e3fdc86
4 changed files with 18 additions and 8 deletions

8
src/app.d.ts vendored
View file

@ -1,5 +1,3 @@
import type { Member } from '$lib/types/Member';
declare global { declare global {
namespace App { namespace App {
// interface Error {} // interface Error {}
@ -23,12 +21,12 @@ declare global {
interface BlogPost { interface BlogPost {
slug: string; slug: string;
title: string; title: string;
thumbnail: string; thumbnail?: string;
date: string; date?: string;
description: string; description: string;
publisher: string; publisher: string;
published?: boolean; published?: boolean;
member?: Member; projects?: string[];
} }
} }
} }

View file

@ -0,0 +1,9 @@
---
title: 'Тестовый блог'
date:
description: 'Немного о самом сайте'
---
# ПРИВЕТ !
Добро пожаловать на наш первый блог-пост!

View file

@ -3,8 +3,11 @@ import path from 'path';
export async function fetchPostsSorted() { export async function fetchPostsSorted() {
const allPosts = await fetchPosts(); const allPosts = await fetchPosts();
const sortedPosts = allPosts.sort((a, b) => { const sortedPosts = allPosts
return new Date(b.date).valueOf() - new Date(a.date).valueOf(); // Для списка постов оставляем только те, у которых объявлена дата публикации
.filter((a) => !!a.date)
.sort((a, b) => {
return new Date(b.date!).valueOf() - new Date(a.date!).valueOf();
}); });
return sortedPosts; return sortedPosts;

View file

@ -26,7 +26,7 @@ ${posts.map((post) => `<item>
<description>${escapeXml(post.description)}</description> <description>${escapeXml(post.description)}</description>
<guid isPermaLink="true">https://teasanctuary.ru/blog/${post.slug}</guid> <guid isPermaLink="true">https://teasanctuary.ru/blog/${post.slug}</guid>
<link>https://teasanctuary.ru/blog/${post.slug}</link> <link>https://teasanctuary.ru/blog/${post.slug}</link>
<pubDate>${(new Date(post.date)).toUTCString()}</pubDate> <pubDate>${(new Date(post.date!)).toUTCString()}</pubDate>
</item>`).join("\n")} </item>`).join("\n")}
</channel> </channel>
</rss>`)) </rss>`))