diff --git a/src/lib/components/BlogCard.svelte b/src/lib/components/BlogCard.svelte index 25bf97d..aa704c9 100644 --- a/src/lib/components/BlogCard.svelte +++ b/src/lib/components/BlogCard.svelte @@ -22,7 +22,7 @@ post, size = BlogCardSize.Both, fullHeight = false - }: { post: App.BlogPost; size: BlogCardSize; fullHeight: boolean } = $props(); + }: { post: App.BlogPost; size?: BlogCardSize; fullHeight?: boolean } = $props(); const type: App.BlogPostType = post.type ?? 'article'; let isPostNew = $state(false); diff --git a/src/lib/util/Blogs.ts b/src/lib/util/Blogs.ts index 3b193dc..223ca87 100644 --- a/src/lib/util/Blogs.ts +++ b/src/lib/util/Blogs.ts @@ -31,6 +31,7 @@ export function postEventStatus(post: App.BlogPost): EventStatus { export type PostComparer = (a: App.BlogPost, b: App.BlogPost) => number; export const sortPostsByPostDate: PostComparer = (a, b) => new Date(b.date!).valueOf() - new Date(a.date!).valueOf(); +export const sortPostsByPostAndUpdateDate: PostComparer = (a, b) => laterDate(b.date!, b.dateChanged) - laterDate(a.date!, a.dateChanged); function laterDate(a: string, ...dates: (string | undefined)[]): number { const dateA = new Date(a).valueOf(); @@ -45,8 +46,6 @@ function laterDate(a: string, ...dates: (string | undefined)[]): number { return max; } -export const sortPostsByPostAndUpdateDate: PostComparer = (a, b) => laterDate(b.date!, b.dateChanged) - laterDate(a.date!, a.dateChanged); - export async function fetchPostsSorted(postComparer?: PostComparer) { const allPosts = await fetchPosts(); diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index e617887..f6024d4 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1,11 +1,24 @@ @@ -88,9 +101,11 @@

ПОСЛЕДНИЕ ПОСТЫ

- {#each page.data.posts as post, i} + {#each posts as post, i}
- + {#key post} + + {/key}
{/each}
diff --git a/src/routes/blog/+page.server.ts b/src/routes/blog/+page.server.ts index c5653b5..916e748 100644 --- a/src/routes/blog/+page.server.ts +++ b/src/routes/blog/+page.server.ts @@ -1,4 +1,4 @@ -import { fetchPostsSorted } from "$src/lib/util/Blogs"; +import { fetchPostsSorted } from "$lib/util/Blogs"; export async function load() { return { title: "Блог", description: "Новости и заметки проектов Tea Sanctuary", posts: await fetchPostsSorted() }; diff --git a/src/routes/blog/+page.svelte b/src/routes/blog/+page.svelte index da243da..3eed89a 100644 --- a/src/routes/blog/+page.svelte +++ b/src/routes/blog/+page.svelte @@ -1,8 +1,10 @@
@@ -39,6 +54,20 @@ пропускать новые посты! +{#if !!eventPosts && eventPosts.length > 0} +
+

АКТУАЛЬНЫЕ СОБЫТИЯ

+ +
+ {#each eventPosts as post, i} +
+ +
+ {/each} +
+
+{/if} +
{#each groupedPosts.entries() as [monthYear, postsInMonthYear]}

{/each} -

\ No newline at end of file +