flatten monorepo, migrate off Vercel
- Remove penfield (split to own repo on Forgejo) - Move www/ contents to root, rename to wynne.rs - Swap @astrojs/vercel for @astrojs/node, upgrade to Astro 6 - Remove auth-astro/GitHub OAuth (TinyAuth at proxy layer) - Remove Vercel deploy webhook - Switch to local SQLite DB (drop Turso) - Update generate-stats.js for new build output paths
This commit is contained in:
parent
f2acf36784
commit
8a9c56c3d5
52 changed files with 45 additions and 7135 deletions
45
src/lib/txt.ts
Normal file
45
src/lib/txt.ts
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import yaml from 'js-yaml';
|
||||
import { sortEntries } from './format';
|
||||
|
||||
export interface TxtFile {
|
||||
name: string;
|
||||
date: Date;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
export interface TxtConfig {
|
||||
descriptions?: Record<string, string>;
|
||||
dates?: Record<string, string>;
|
||||
}
|
||||
|
||||
export function getTxtDir(): string {
|
||||
return path.join(process.cwd(), 'public');
|
||||
}
|
||||
|
||||
export function loadTxtConfig(): TxtConfig {
|
||||
const configPath = path.join(getTxtDir(), 'config.yaml');
|
||||
return fs.existsSync(configPath)
|
||||
? yaml.load(fs.readFileSync(configPath, 'utf8')) as TxtConfig
|
||||
: {};
|
||||
}
|
||||
|
||||
export function getTxtFiles(): TxtFile[] {
|
||||
const txtDir = getTxtDir();
|
||||
if (!fs.existsSync(txtDir)) return [];
|
||||
|
||||
const config = loadTxtConfig();
|
||||
const descriptions = config.descriptions || {};
|
||||
const dates = config.dates || {};
|
||||
|
||||
const files = fs.readdirSync(txtDir)
|
||||
.filter(file => file.endsWith('.txt'))
|
||||
.map(name => ({
|
||||
name,
|
||||
date: dates[name] ? new Date(dates[name]) : new Date(0),
|
||||
description: descriptions[name],
|
||||
}));
|
||||
return sortEntries(files);
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue