First version of webring with simple landing page and control functions.
This commit is contained in:
commit
554960fbef
22 changed files with 3621 additions and 0 deletions
15
src/render_templates.ts
Normal file
15
src/render_templates.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
import { WebringData, WebringEntry } from './webring';
|
||||
import { readFileSync, writeFileSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
|
||||
function generateEntryHTML(entry: WebringEntry) {
|
||||
return `<div><a href="${entry.url}">${entry.title}</a><span>by ${entry.author}</span></div>`;
|
||||
}
|
||||
|
||||
let index = readFileSync(
|
||||
join(import.meta.dirname, '../templates/index.html'),
|
||||
'utf8'
|
||||
);
|
||||
const renderedEntries = WebringData.map(generateEntryHTML).join('\n');
|
||||
index = index.replace('{{WEBRING_ENTRIES}}', renderedEntries);
|
||||
writeFileSync(join(import.meta.dirname, '../public/index.html'), index);
|
Loading…
Add table
Add a link
Reference in a new issue