GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — tipscode.github.io/server.js at master · TipsCode/tipscode.github.io Expand file tree/ Copy pathserver.jsMore file actions 41 lines (38 loc) · 1.43 KB / Copy pathserver.jsFile metadata and controls41 lines (38 loc) · 1.43 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 import Nullstack from 'nullstack'; import { readdirSync, readFileSync } from 'fs'; import prismjs from 'prismjs'; import { Remarkable } from 'remarkable'; import meta from 'remarkable-meta'; import Application from './src/Application'; const context = Nullstack.start(Application); context.start = async function start() { await import('prismjs/components/prism-jsx.min'); const articles = readdirSync('articles'); const md = new Remarkable({ // eslint-disable-next-line no-undef highlight: (code) => Prism.highlight(code, prismjs.languages.jsx, 'javascript'), }); md.use(meta); md.use((md) => { const originalRender = md.renderer.rules.link_open; md.renderer.rules.link_open = (...args) => { let result = originalRender(...args); const regexp = /href="([^"]*)"/; const href = regexp.exec(result)[1]; if (!href.startsWith('/')) { result = result.replace('>', ' target="_blank" rel="noopener">'); } return result; }; }); context.articles = articles.map((name) => { const markdown = readFileSync(`articles/${name}`, 'utf-8'); const [slug] = name.split('.'); const content = md.render(markdown); const { date: dateString, ...meta } = md.meta; const date = new Date(dateString); const readingTime = ~~(content.split(' ').length / 200); return { slug, content, date, readingTime, ...meta }; }).sort((a, b) => b.date - a.date); }; export default context; |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |