diff options
author | lonkaars <l.leblansch@gmail.com> | 2021-03-30 19:37:24 +0200 |
---|---|---|
committer | lonkaars <l.leblansch@gmail.com> | 2021-03-30 19:37:24 +0200 |
commit | 71ab18ec4264197aae27efe64e4565c4989a19cd (patch) | |
tree | 561f82b426e0fca092b22e1f10e1a507091925e7 /pages | |
parent | 609c78e15c43ae0a3733640c724e2f3b1a08ab80 (diff) |
scripts + links
Diffstat (limited to 'pages')
-rw-r--r-- | pages/index.tsx | 1 | ||||
-rw-r--r-- | pages/post/[id].tsx | 4 |
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: { |