Skip to content

Commit

Permalink
initial formatting for research page
Browse files Browse the repository at this point in the history
  • Loading branch information
scheibo committed Nov 4, 2023
1 parent 82be853 commit ea8153a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/site/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ footer img {
align-items: center;
}

#research li {
margin-bottom: 0.5em;
}

.hide {
display: none;
}
Expand Down
16 changes: 12 additions & 4 deletions src/site/research.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,25 @@ import * as path from 'path';

import * as bibtex from '@retorquere/bibtex-parser';

// TODO generate listing from research.bib (and tags) - link externally always
export function page(dir: string) {
const buf: string[] = [];

const bib = bibtex.parse(fs.readFileSync(path.join(dir, 'research.bib'), 'utf8'));
if (bib.errors.length) throw new Error(`Error parsing research.bib: ${bib.errors.join(', ')}`);
const bibliography: {[id: string]: bibtex.Entry} = {};
for (const entry of bib.entries) bibliography[entry.key] = entry;

buf.push('<ul>');
for (const entry of bib.entries) {
// TODO: improve citation format
const title = `<em>${entry.fields.title[0]}</em>`;
const date = entry.fields.year[0];
buf.push(`<li><a href="${entry.fields.url[0]}">${title}</a> — ${date}</li>`);
}
buf.push('</ul>');

return {
title: 'Research | pkmn.ai',
header: '<h2>Research</h2>',
content: '<p>TODO</p>',
content: `<div id="research">${buf.join('')}</div>`,
edit: 'https://github.com/pkmn/ai/edit/main/src/site/research.bib',
};
}

0 comments on commit ea8153a

Please sign in to comment.