From ca8e6824eaa711105f4092365792720c9dde026b Mon Sep 17 00:00:00 2001 From: Joe Carstairs Date: Thu, 18 Jun 2026 19:21:59 +0100 Subject: remove Astro website --- website/src/components/BlogFeed.astro | 103 ---------------------------------- 1 file changed, 103 deletions(-) delete mode 100644 website/src/components/BlogFeed.astro (limited to 'website/src/components/BlogFeed.astro') diff --git a/website/src/components/BlogFeed.astro b/website/src/components/BlogFeed.astro deleted file mode 100644 index 552fff4..0000000 --- a/website/src/components/BlogFeed.astro +++ /dev/null @@ -1,103 +0,0 @@ ---- -import type { CollectionEntry } from 'astro:content'; -import { getCollection } from 'astro:content'; -import FormattedDate from './FormattedDate.astro'; - -export interface Props { - headingLevel?: 1 | 2 | 3 | 4 | 5 | 6, - hideAuthor?: boolean, - hideSubheadings?: boolean, - maxEntries?: number, -}; - -const { headingLevel = 2, hideSubheadings = false, hideAuthor = false, maxEntries } = Astro.props; - -const allPosts = (await getCollection('blog')).filter((post) => !post.data.hidden); - -const posts = maxEntries === undefined - ? allPosts - : allPosts.sort(sortByPubDateDescending).slice(0, maxEntries); - -const distinctYears: number[] = posts - .map(post => pubDate(post).getFullYear()) - .reduce((acc, curr) => acc.includes(curr) ? acc : [...acc, curr], []) - .sort((a, b) => b - a); - -function matchesYear(year: number) { - return (post: CollectionEntry<'blog'>) => pubDate(post).getFullYear() === year; -} - -function sortByPubDateDescending(post1: CollectionEntry<'blog'>, post2: CollectionEntry<'blog'>) { - const date1 = pubDate(post1).getTime(); - const date2 = pubDate(post2).getTime(); - return date2 - date1; -} - -function pubDate(post: CollectionEntry<'blog'>): Date { - if (post.data.pubDate) { - return post.data.pubDate; - } - const date = new Date(post.id); - if (isNaN(date.valueOf())) { - throw new Error(`Post ${post.id} does not have a valid publication date.`); - } - return date; -} - -const HeadingElem = `h${headingLevel} class="p-name"`; -const SubHeadingElem = `h${headingLevel + 1}`; -const SubSubHeadingElem = `h${headingLevel + 2}`; -const AuthorElem = `p${hideAuthor ? " hidden" : ""}`; - -const canonicalBlogUrl = new URL('blog', Astro.site) ---- - -
- - My blog - - - - - - - { hideSubheadings - ?
    - { posts.sort(sortByPubDateDescending).map(post => ( -
  • - - {post.data.title} - -

    - -

  • - )) } -
- : distinctYears.map(year => ( - {year} -
    - { posts.filter(matchesYear(year)).sort(sortByPubDateDescending).map(post => ( -
  • - - {post.data.title} - -

    - -

  • - )) } -
- )) } - - { (maxEntries !== undefined && maxEntries < allPosts.length) - ? - : <> - } -
-- cgit v1.2.3