Блоги #1
4 changed files with 18 additions and 8 deletions
8
src/app.d.ts
vendored
8
src/app.d.ts
vendored
|
|
@ -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[];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
9
src/blogs/test_unpublished.md
Normal file
9
src/blogs/test_unpublished.md
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
---
|
||||||
|
title: 'Тестовый блог'
|
||||||
|
date:
|
||||||
|
description: 'Немного о самом сайте'
|
||||||
|
---
|
||||||
|
|
||||||
|
# ПРИВЕТ !
|
||||||
|
|
||||||
|
Добро пожаловать на наш первый блог-пост!
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -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>`))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue