refactor: rename blog app to www
This commit is contained in:
parent
5ff2a3056e
commit
87c8260c80
40 changed files with 6 additions and 6 deletions
42
apps/www/src/pages/bookmarks/index.astro
Normal file
42
apps/www/src/pages/bookmarks/index.astro
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
---
|
||||
import Layout from '../../layouts/Layout.astro';
|
||||
import yaml from 'js-yaml';
|
||||
import bookmarksRaw from '../../data/bookmarks.yaml?raw';
|
||||
|
||||
interface Bookmark {
|
||||
date: string;
|
||||
title: string;
|
||||
url: string;
|
||||
}
|
||||
|
||||
const bookmarks = (yaml.load(bookmarksRaw) as Bookmark[])
|
||||
.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime());
|
||||
|
||||
function formatDate(date: Date): string {
|
||||
const d = String(date.getDate()).padStart(2, '0');
|
||||
const m = String(date.getMonth() + 1).padStart(2, '0');
|
||||
const y = String(date.getFullYear()).slice(-2);
|
||||
return `${d}/${m}/${y}`;
|
||||
}
|
||||
|
||||
function formatBookmarkDate(dateStr: string): string {
|
||||
const date = new Date(dateStr);
|
||||
return formatDate(date);
|
||||
}
|
||||
|
||||
function extractDomain(url: string): string {
|
||||
try {
|
||||
const parsed = new URL(url);
|
||||
return parsed.hostname.replace(/^www\./, '');
|
||||
} catch {
|
||||
return url;
|
||||
}
|
||||
}
|
||||
---
|
||||
<Layout title="bookmarks - lewis m.w.">
|
||||
|
||||
<details open>
|
||||
<summary>bookmarks</summary>
|
||||
<pre set:html={bookmarks.map(b => `<span class="muted">${formatBookmarkDate(b.date)}</span> <a href="${b.url}">${b.title}</a> <span class="muted">(${extractDomain(b.url)})</span>`).join('\n')} />
|
||||
</details>
|
||||
</Layout>
|
||||
Loading…
Add table
Add a link
Reference in a new issue