Rename markdown to blog

pull/8253/head
Puru Vijay 4 years ago
parent 7afee765fc
commit e5ab5b65ce

@ -1,9 +1,9 @@
import { get_index } from '$lib/server/markdown';
import { get_index } from '$lib/server/blog';
export const prerender = true;
export async function load() {
return {
posts: get_index()
posts: get_index(),
};
}

@ -1,4 +1,4 @@
import { get_post } from '$lib/server/markdown/index.js';
import { get_post } from '$lib/server/blog/index.js';
import { error } from '@sveltejs/kit';
export const prerender = true;
@ -11,6 +11,6 @@ export async function load({ params }) {
}
return {
post
post,
};
}

@ -2,7 +2,7 @@ import satori from 'satori';
import { Resvg } from '@resvg/resvg-js';
import OverpassRegular from './Overpass-Regular.ttf';
import { html as toReactNode } from 'satori-html';
import { get_post } from '$lib/server/markdown/index.js';
import { get_post } from '$lib/server/blog/index.js';
import { error } from '@sveltejs/kit';
import Card from './Card.svelte';
@ -19,6 +19,7 @@ export const GET = async ({ params, url }) => {
throw error(404);
}
// @ts-ignore
const result = Card.render({ post });
const element = toReactNode(`${result.html}<style>${result.css.code}</style>`);
@ -28,18 +29,18 @@ export const GET = async ({ params, url }) => {
name: 'Overpass',
data: Buffer.from(OverpassRegular),
style: 'normal',
weight: 400
}
weight: 400,
},
],
height,
width
width,
});
const resvg = new Resvg(svg, {
fitTo: {
mode: 'width',
value: width
}
value: width,
},
});
const image = resvg.render();
@ -47,7 +48,7 @@ export const GET = async ({ params, url }) => {
return new Response(image.asPng(), {
headers: {
'content-type': 'image/png',
'cache-control': 'public, max-age=600' // cache for 10 minutes
}
'cache-control': 'public, max-age=600', // cache for 10 minutes
},
});
};

@ -1,4 +1,4 @@
import { get_index } from '$lib/server/markdown';
import { get_index } from '$lib/server/blog';
export const prerender = true;
@ -15,13 +15,13 @@ function escapeHTML(html) {
"'": '#39',
'&': 'amp',
'<': 'lt',
'>': 'gt'
'>': 'gt',
};
return html.replace(/["'&<>]/g, (c) => `&${chars[c]};`);
}
/** @type {import('$lib/server/markdown/types').BlogPostSummary[]} */
/** @param {import('$lib/server/blog/types').BlogPostSummary[]} posts */
const get_rss = (posts) =>
`
<?xml version="1.0" encoding="UTF-8" ?>
@ -63,7 +63,7 @@ export async function GET() {
return new Response(get_rss(posts), {
headers: {
'Cache-Control': `max-age=${30 * 60 * 1e3}`,
'Content-Type': 'application/rss+xml'
}
'Content-Type': 'application/rss+xml',
},
});
}

@ -1,3 +1,8 @@
{
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"allowSyntheticDefaultImports": true
}
}

Loading…
Cancel
Save