aboutsummaryrefslogtreecommitdiff
path: root/pages
diff options
context:
space:
mode:
Diffstat (limited to 'pages')
-rw-r--r--pages/index.tsx1
-rw-r--r--pages/post/[id].tsx4
2 files changed, 4 insertions, 1 deletions
diff --git a/pages/index.tsx b/pages/index.tsx
index 91b8aef..96b8684 100644
--- a/pages/index.tsx
+++ b/pages/index.tsx
@@ -28,6 +28,7 @@ export default function Home(props: {
return {
children: post.props.meta.chapters,
name: post.props.meta.title,
+ sectionLink: "/post/" + post.props.meta.id
} as chapter
})
]}/>
diff --git a/pages/post/[id].tsx b/pages/post/[id].tsx
index 23ce14e..8f6dde8 100644
--- a/pages/post/[id].tsx
+++ b/pages/post/[id].tsx
@@ -17,6 +17,7 @@ export interface ArticleMeta {
tags?: Array<string>;
date?: string;
chapters?: Array<chapter>;
+ id?: string;
}
export function RenderedArticle(props: { content: string }) {
@@ -104,7 +105,7 @@ function parseToCRecursive(headings: Array<string>): Array<chapter> {
var chapterName = headings[i].match(/^[#]+\s+(.+)/)[1];
children.push({
name: chapterName,
- sectionLink: sectionID(chapterName),
+ sectionLink: "#" + sectionID(chapterName),
unparsedChildren: [],
});
currentChildIndex += 1;
@@ -141,6 +142,7 @@ export function getStaticProps(props: {params: { id: string }}) {
var filecontent = readFileSync(filename).toString().trim()
var parsed = preprocessor(filecontent);
+ parsed.meta.id = props.params.id;
return {
props: {