From 71ab18ec4264197aae27efe64e4565c4989a19cd Mon Sep 17 00:00:00 2001 From: lonkaars Date: Tue, 30 Mar 2021 19:37:24 +0200 Subject: scripts + links --- pages/index.tsx | 1 + pages/post/[id].tsx | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'pages') 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; date?: string; chapters?: Array; + id?: string; } export function RenderedArticle(props: { content: string }) { @@ -104,7 +105,7 @@ function parseToCRecursive(headings: Array): Array { 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: { -- cgit v1.2.3