;
}
export function getTxtDir(): string {
@@ -33,13 +33,14 @@ export function getTxtFiles(): TxtFile[] {
const config = loadTxtConfig();
const pinnedSet = new Set(config.pinned || []);
-
const descriptions = config.descriptions || {};
+ const dates = config.dates || {};
+
const files = fs.readdirSync(txtDir)
.filter(file => file.endsWith('.txt'))
.map(name => ({
name,
- date: getGitCreationDate(path.join(txtDir, name)),
+ date: dates[name] ? new Date(dates[name]) : new Date(0),
pinned: pinnedSet.has(name),
description: descriptions[name],
}));
diff --git a/www/src/pages/[slug].astro b/www/src/pages/[slug].astro
index 7974b9d..c2a81a8 100644
--- a/www/src/pages/[slug].astro
+++ b/www/src/pages/[slug].astro
@@ -2,11 +2,10 @@
import { getCollection, render } from 'astro:content';
import Layout from '../layouts/Layout.astro';
import { formatDate, formatListItem, excerpt } from '../lib/format';
-import { getSlug, enrichPostWithDates, enrichPostsWithDates, resolveRelatedPosts } from '../lib/md';
+import { getSlug, resolveRelatedPosts } from '../lib/md';
export async function getStaticPaths() {
- const rawPosts = await getCollection('md');
- const allPosts = enrichPostsWithDates(rawPosts);
+ const allPosts = await getCollection('md');
return allPosts.map(post => ({
params: { slug: getSlug(post.id) },
props: { post, allPosts }
@@ -22,13 +21,13 @@ const description = excerpt((post as any).body) || undefined;
{post.data.title}
-{formatDate(post.dates.created)}{post.dates.updated && ` (updated ${formatDate(post.dates.updated)})`}
+{formatDate(post.data.date)}{post.data.updated && ` (updated ${formatDate(post.data.updated)})`}
{related.length > 0 && (
related
- formatListItem(p.dates.created, `/${getSlug(p.id)}`, p.data.title)).join('\n')} />
+ formatListItem(p.data.date, `/${getSlug(p.id)}`, p.data.title)).join('\n')} />
)}
diff --git a/www/src/pages/feed.xml.ts b/www/src/pages/feed.xml.ts
index 55c43cc..d350661 100644
--- a/www/src/pages/feed.xml.ts
+++ b/www/src/pages/feed.xml.ts
@@ -1,19 +1,18 @@
import rss from '@astrojs/rss';
import { getCollection } from 'astro:content';
import type { APIContext } from 'astro';
-import { getSlug, enrichPostsWithDates } from '../lib/md';
+import { getSlug } from '../lib/md';
import { getTxtFiles } from '../lib/txt';
import { excerpt } from '../lib/format';
export async function GET(context: APIContext) {
- const rawPosts = await getCollection('md');
- const posts = enrichPostsWithDates(rawPosts);
+ const posts = await getCollection('md');
const txtFiles = getTxtFiles();
const items = [
...posts.map(post => ({
title: post.data.title,
- pubDate: post.dates.created,
+ pubDate: post.data.date,
link: `/${getSlug(post.id)}`,
description: excerpt((post as any).body) || post.data.title,
})),
diff --git a/www/src/pages/index.astro b/www/src/pages/index.astro
index 26a62d1..75f592f 100644
--- a/www/src/pages/index.astro
+++ b/www/src/pages/index.astro
@@ -3,12 +3,11 @@ import { getCollection } from 'astro:content';
import Layout from '../layouts/Layout.astro';
import { getApprovedEntries, type GuestbookEntry } from '../lib/db';
import { formatDate, formatListItem, escapeHtml } from '../lib/format';
-import { organizePostsByCategory, getSlug, enrichPostsWithDates } from '../lib/md';
+import { organizePostsByCategory, getSlug } from '../lib/md';
import { getTxtFiles } from '../lib/txt';
import { DEFAULT_CATEGORY, SECTIONS, SUBDOMAINS } from '../lib/consts';
-const rawPosts = await getCollection('md');
-const posts = enrichPostsWithDates(rawPosts);
+const posts = await getCollection('md');
const { grouped, categories: sortedCategories } = organizePostsByCategory(posts);
const bookmarksCollection = await getCollection('bookmarks');
@@ -25,7 +24,7 @@ try {
}
const urls = [
- ...posts.map(post => ({ url: `/${getSlug(post.id)}`, date: post.dates.created.getTime() })),
+ ...posts.map(post => ({ url: `/${getSlug(post.id)}`, date: post.data.date.getTime() })),
...txtFiles.map(f => ({ url: `/${f.name}`, date: f.date.getTime() })),
].sort((a, b) => b.date - a.date).map(e => e.url).concat(SUBDOMAINS);
---
@@ -38,7 +37,7 @@ const urls = [
{!isDefault && {category}}
- `${formatListItem(post.dates.created, `/${getSlug(post.id)}`, post.data.title, { pinned: post.data.pinned })}`
+ `${formatListItem(post.data.date, `/${getSlug(post.id)}`, post.data.title, { pinned: post.data.pinned })}`
).join('')} />
);