summaryrefslogtreecommitdiff
path: root/website/src/components/LinksFeed.astro
diff options
context:
space:
mode:
authorJoe Carstairs <me@joeac.net>2026-06-18 19:21:59 +0100
committerJoe Carstairs <me@joeac.net>2026-06-18 19:21:59 +0100
commitca8e6824eaa711105f4092365792720c9dde026b (patch)
tree2b6493941352d11b799ee63d3f1311c13de649b8 /website/src/components/LinksFeed.astro
parenta0f25057283a397f006127b6f582d190d2c4294e (diff)
remove Astro website
Diffstat (limited to 'website/src/components/LinksFeed.astro')
-rw-r--r--website/src/components/LinksFeed.astro78
1 files changed, 0 insertions, 78 deletions
diff --git a/website/src/components/LinksFeed.astro b/website/src/components/LinksFeed.astro
deleted file mode 100644
index 1d837f0..0000000
--- a/website/src/components/LinksFeed.astro
+++ /dev/null
@@ -1,78 +0,0 @@
----
-import FormattedDate from '../components/FormattedDate.astro';
-import allLinks from '../data/links.ts';
-
-type Link = (typeof allLinks)[number];
-
-export interface Props {
- headingLevel?: 1 | 2 | 3 | 4 | 5 | 6,
- hideAuthor?: boolean,
- maxEntries?: number,
-};
-
-const { headingLevel = 2, hideAuthor = false, maxEntries } = Astro.props;
-
-const headingElem = `h${headingLevel}`;
-const subHeadingElem = `h${headingLevel + 1}`
-
-const links: Link[] = maxEntries === undefined
- ? allLinks
- : allLinks.sort(sortByDateAddedDescending).slice(0, maxEntries);
-
-const distinctYears: string[] = links
- .map(link => link.isoDateAdded.slice(0,4))
- .reduce<string[]>((acc, curr) => acc.includes(curr) ? acc : [...acc, curr], [])
- .sort((a, b) => Number.parseInt(b) - Number.parseInt(a));
-
-function matchesYear(year: string) {
- return (link: (typeof links)[number]) => link.isoDateAdded.slice(0,4) === year;
-}
-
-function sortByDateAddedDescending(link1: (typeof links)[number], link2: (typeof links)[number]) {
- const date1 = new Date(link1.isoDateAdded).getTime();
- const date2 = new Date(link2.isoDateAdded).getTime();
- return date2 - date1;
-}
-
-const canonicalLinksUrl = new URL('links', Astro.site)
----
-
-<section class="h-feed">
- <Fragment set:html={`
- <${headingElem} class="p-name">
- My links
- </${headingElem}>
- `} />
-
- <aside>
- <p hidden={hideAuthor}>
- These links are collected by <a class="p-author h-card" href="/">Joe Carstairs</a>
- </p>
-
- <p hidden>
- <a class="u-url" href={canonicalLinksUrl}>Permalink</a>
- </p>
- </aside>
-
- { distinctYears.map(year => (
- <Fragment set:html={`
- <${subHeadingElem}>
- ${year}
- </${subHeadingElem}>
- `} />
- <ul>
- { links.filter(matchesYear(year)).sort(sortByDateAddedDescending).map(link => (
- <li class="h-entry e-content">
- <FormattedDate className="dt-published" date={link.isoDateAdded} />
- <a class="u-url p-name" href={link.href} set:html={link.title} />
- <p class="p-description" set:html={link.description} />
- </li>
- )) }
- </ul>
- )) }
-
- { (maxEntries !== undefined && maxEntries < allLinks.length)
- ? <p class="full-feed-link"><a href="/links">All links</a></p>
- : <></>
- }
-</section>