Skip to content

Commit

Permalink
feat(#7): customizable styles
Browse files Browse the repository at this point in the history
  • Loading branch information
jannis-baum committed Oct 26, 2023
1 parent b428226 commit f9ac457
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/parser/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,10 @@ for (const cp of configPaths) {
} catch {}
}

if (config.styles && config.styles.length > 0) {
const stylePath =
config.styles[0] === '~' ? path.join(homedir(), config.styles.slice(1)) : config.styles;
config.styles = fs.existsSync(stylePath) ? fs.readFileSync(stylePath, 'utf8') : '';
}

export default config;
3 changes: 3 additions & 0 deletions src/routes/viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ router.get(/.*/, async (req: Request, res: Response) => {
<link rel="stylesheet" type="text/css" href="/static/style.css"/>
<link rel="stylesheet" type="text/css" href="/static/highlight.css">
<link rel="stylesheet" type="text/css" href="/static/katex/katex.css">
<style>
${config.styles}
</style>
<body>
<a id="parent-dir" href="/viewer${dirname(path)}">↩</a>
<div id="body-content">
Expand Down

0 comments on commit f9ac457

Please sign in to comment.