{post.metadata.title}
21 |{post.metadata.description}
22 | 23 |{error.message}
14 | 15 | {#if dev && error.stack} 16 |{error.stack}17 | {/if} 18 |
This is the 'about' page. There's not much here.
8 |${highlighted}
`;
42 | };
43 | */
44 | const html = marked(
45 | content.replace(/^\t+/gm, match => match.split('\t').join(' ')) || '',
46 | {
47 | renderer,
48 | },
49 | );
50 |
51 | return {
52 | html,
53 | metadata,
54 | slug: file.replace(/^[\d-]+/, '').replace(/\.md$/, ''),
55 | };
56 | })
57 | .sort((a, b) => {
58 | return a.metadata.pubdate < b.metadata.pubdate ? 1 : -1;
59 | });
60 | }
61 |
--------------------------------------------------------------------------------
/src/routes/api/blog/index.js:
--------------------------------------------------------------------------------
1 | import get_posts from './_posts.js';
2 |
3 | let json;
4 |
5 | export function get(req, res) {
6 | if (!json || process.env.NODE_ENV !== 'production') {
7 | json = JSON.stringify(get_posts().map(post => {
8 | return {
9 | slug: post.slug,
10 | metadata: post.metadata
11 | };
12 | }));
13 | }
14 |
15 | res.set({
16 | 'Content-Type': 'application/json',
17 | 'Cache-Control': `max-age=${5 * 60 * 1e3}` // 5 minutes
18 | });
19 | res.end(json);
20 | }
--------------------------------------------------------------------------------
/src/routes/auth/me.json.js:
--------------------------------------------------------------------------------
1 | export function get(req, res) {
2 | if (!req.session.passport || !req.session.passport.user) {
3 | res.send(null);
4 | return;
5 | }
6 |
7 | const { id, username, displayName, photo } = req.session.passport && req.session.passport.user;
8 | res.send({ id, username, displayName, photo });
9 | }
--------------------------------------------------------------------------------
/src/routes/blog/[slug].html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
11 |
12 | {post.metadata.description}
21 | 22 | {@html post.html} 23 |{post.metadata.description}
22 | 23 |loading
48 | {:then posts} 49 | {#each posts.slice(0,5) as post} 50 | 51 |{ post.metadata.description }
54 | read 55 |In order to use GitHub authentication, you will need to register an OAuth application with gist
and read:user
scopes, and create a .env file:
GITHUB_CLIENT_ID=[YOUR_APP_ID]\nGITHUB_CLIENT_SECRET=[YOUR_APP_SECRET]\nBASEURL=http://localhost:300088 | 89 |
The BASEURL
variable should match the callback URL specified for your app.