display blog article
This commit is contained in:
parent
b67fb2e6a5
commit
1dd89aef87
@ -71,3 +71,24 @@ adspexit Circe est iuvencae ut favilla inque vir. Fas gelidas depressitque, et
|
||||
ipse, occidit **afflatibus** est caesosque Liber? Animam [gramine quam
|
||||
melior](http://nequesolum.net/in.html); arbor parte gestit moras trementia
|
||||
aquilone se membris prima; Atlantis.
|
||||
|
||||
- Iunget quem color baculumque insistere perque nequiquam
|
||||
- Temptabat Macareus hoc urbem inmanem alasque averserisque
|
||||
- Tibia vita ita
|
||||
- Mihi caput audito Hippolytus debita finita
|
||||
- Ignis murmura summa nimis fragmina
|
||||
- Aeneadae omnibus
|
||||
|
||||
## Tractus aderat
|
||||
|
||||
Datque **in sidera** timorem in fuerant partem, sit hi lapidis robora et
|
||||
Phrygii! Dixisse dato posse et balatus tu tractare adit, merito quid tamen se.
|
||||
[Huic](http://quibus-corpus.net/dissimulare-condit.html) nivea in modo iam enixa
|
||||
sinistrum, haud collabitur misit, bello.
|
||||
|
||||
1. Stimuletur orbem vestigia regina
|
||||
2. Pedibusque Latona in sub ponderis sustinuit maiora
|
||||
3. Paverunt metiris malorum genetrice de illis
|
||||
4. Sedebant ora
|
||||
5. Deae bicolor submisso
|
||||
6. Suis astra ut illas frontes
|
||||
|
@ -23,7 +23,11 @@ export async function get(req, res, next) {
|
||||
}
|
||||
|
||||
const parsedPost = fm(postSource)
|
||||
const response = parseField('body')(parsedPost)
|
||||
|
||||
const response = parseField('body')({
|
||||
...parsedPost.attributes,
|
||||
body: parsedPost.body,
|
||||
})
|
||||
|
||||
res.setHeader('Content-Type', 'application/json')
|
||||
res.end(JSON.stringify(response))
|
||||
|
@ -2,19 +2,19 @@
|
||||
export async function preload({ params, query }) {
|
||||
// the `slug` parameter is available because
|
||||
// this file is called [slug].svelte
|
||||
const res = await this.fetch(`blog/${params.slug}.json`);
|
||||
const data = await res.json();
|
||||
const res = await this.fetch(`blog/${params.slug}.json`)
|
||||
const data = await res.json()
|
||||
|
||||
if (res.status === 200) {
|
||||
return { post: data };
|
||||
return { post: data }
|
||||
} else {
|
||||
this.error(res.status, data.message);
|
||||
this.error(res.status, data.message)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
export let post;
|
||||
export let post
|
||||
</script>
|
||||
|
||||
<style>
|
||||
@ -33,7 +33,7 @@
|
||||
|
||||
.content :global(pre) {
|
||||
background-color: #f9f9f9;
|
||||
box-shadow: inset 1px 1px 5px rgba(0,0,0,0.05);
|
||||
box-shadow: inset 1px 1px 5px rgba(0, 0, 0, 0.05);
|
||||
padding: 0.5em;
|
||||
border-radius: 2px;
|
||||
overflow-x: auto;
|
||||
@ -59,6 +59,6 @@
|
||||
|
||||
<h1>{post.title}</h1>
|
||||
|
||||
<div class='content'>
|
||||
{@html post.html}
|
||||
<div class="content">
|
||||
{@html post.body}
|
||||
</div>
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { readdir, readFile } from 'fs'
|
||||
import { promisify } from 'util'
|
||||
import { basename } from 'path'
|
||||
import fm from 'front-matter'
|
||||
import marked from 'marked'
|
||||
|
||||
@ -24,6 +25,7 @@ export async function get(req, res) {
|
||||
return {
|
||||
...parsedAttributes.attributes,
|
||||
preview,
|
||||
slug: basename(file, '.md'),
|
||||
}
|
||||
})
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user