aboutsummaryrefslogtreecommitdiff
path: root/pages/blog
diff options
context:
space:
mode:
authorlonkaars <l.leblansch@gmail.com>2021-04-09 17:10:50 +0200
committerlonkaars <l.leblansch@gmail.com>2021-04-09 17:10:50 +0200
commit5856e80fcb78446be37456ec1e5c47b2ab02201f (patch)
treeeb600e49b8e5884c8ffc7d96719a9bd0b9764120 /pages/blog
parent24a90a67674d52dd3569cf5289b3f4b2f35f23ad (diff)
dprint format :tada:
Diffstat (limited to 'pages/blog')
-rw-r--r--pages/blog/[post].tsx59
1 files changed, 30 insertions, 29 deletions
diff --git a/pages/blog/[post].tsx b/pages/blog/[post].tsx
index 9588517..9ebd3ad 100644
--- a/pages/blog/[post].tsx
+++ b/pages/blog/[post].tsx
@@ -1,50 +1,52 @@
-import micromark from 'micromark';
import { readdirSync, readFileSync } from 'fs';
-import { join } from 'path'
+import micromark from 'micromark';
+import { join } from 'path';
import { NavBar } from '../../components/navbar';
import { CenteredPage, PageTitle } from '../../components/page';
import { Vierkant } from '../../components/ui';
export default function Post(props: {
- post: string,
- content: string,
- tags: string
+ post: string;
+ content: string;
+ tags: string;
}) {
return <div>
- <NavBar/>
+ <NavBar />
<CenteredPage width={802}>
- <PageTitle>{props.post.replace(/_/g, " ")}</PageTitle>
+ <PageTitle>{props.post.replace(/_/g, ' ')}</PageTitle>
<Vierkant fullwidth>
- <div dangerouslySetInnerHTML={{__html: props.content}}>
+ <div dangerouslySetInnerHTML={{ __html: props.content }}>
</div>
</Vierkant>
</CenteredPage>
- </div>
+ </div>;
}
function parseTags(fileContent: string) {
- var fileAsArr = fileContent.split("\n");
- var lastLine = fileAsArr[fileAsArr.length-1]
- if (!lastLine.startsWith(";tags:")) return {
- tags: [],
- result: ""
+ var fileAsArr = fileContent.split('\n');
+ var lastLine = fileAsArr[fileAsArr.length - 1];
+ if (!lastLine.startsWith(';tags:')) {
+ return {
+ tags: [],
+ result: '',
+ };
}
- var tags = lastLine.replace(";tags:", "").trim().split(" ");
+ var tags = lastLine.replace(';tags:', '').trim().split(' ');
- fileAsArr.pop()
- var result = fileAsArr.join("\n").trim()
+ fileAsArr.pop();
+ var result = fileAsArr.join('\n').trim();
- return { tags, result }
+ return { tags, result };
}
-export function getStaticProps(props: {params: { post: string }}) {
- var filename = join("news/", props.params.post + ".md")
- var filecontent = readFileSync(filename).toString().trim()
+export function getStaticProps(props: { params: { post: string; }; }) {
+ var filename = join('news/', props.params.post + '.md');
+ var filecontent = readFileSync(filename).toString().trim();
var parsed = parseTags(filecontent);
- var content = micromark(parsed.result)
+ var content = micromark(parsed.result);
return {
props: {
@@ -52,21 +54,20 @@ export function getStaticProps(props: {params: { post: string }}) {
content,
tags: parsed.tags,
},
- }
+ };
}
export function getStaticPaths() {
- var files = readdirSync("news").filter(f => f.endsWith(".md"));
+ var files = readdirSync('news').filter(f => f.endsWith('.md'));
return {
paths: files.map((f) => {
return {
params: {
- post: f.substr(0, f.length - 3)
- }
- }
+ post: f.substr(0, f.length - 3),
+ },
+ };
}),
fallback: false,
- }
+ };
}
-