Блоги #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 {
|
||||
namespace App {
|
||||
// interface Error {}
|
||||
|
|
@ -23,12 +21,12 @@ declare global {
|
|||
interface BlogPost {
|
||||
slug: string;
|
||||
title: string;
|
||||
thumbnail: string;
|
||||
date: string;
|
||||
thumbnail?: string;
|
||||
date?: string;
|
||||
description: string;
|
||||
publisher: string;
|
||||
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() {
|
||||
const allPosts = await fetchPosts();
|
||||
|
||||
const sortedPosts = allPosts.sort((a, b) => {
|
||||
return new Date(b.date).valueOf() - new Date(a.date).valueOf();
|
||||
const sortedPosts = allPosts
|
||||
// Для списка постов оставляем только те, у которых объявлена дата публикации
|
||||
.filter((a) => !!a.date)
|
||||
.sort((a, b) => {
|
||||
return new Date(b.date!).valueOf() - new Date(a.date!).valueOf();
|
||||
});
|
||||
|
||||
return sortedPosts;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ ${posts.map((post) => `<item>
|
|||
<description>${escapeXml(post.description)}</description>
|
||||
<guid isPermaLink="true">https://teasanctuary.ru/blog/${post.slug}</guid>
|
||||
<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")}
|
||||
</channel>
|
||||
</rss>`))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue