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 | |
parent | 609c78e15c43ae0a3733640c724e2f3b1a08ab80 (diff) |
scripts + links
-rw-r--r-- | components/chapters.tsx | 2 | ||||
-rw-r--r-- | pages/index.tsx | 1 | ||||
-rw-r--r-- | pages/post/[id].tsx | 4 | ||||
-rw-r--r-- | posts/gert.md | 34 | ||||
-rwxr-xr-x | scripts/tags | 8 |
5 files changed, 47 insertions, 2 deletions
diff --git a/components/chapters.tsx b/components/chapters.tsx index 9f15b87..facf1e1 100644 --- a/components/chapters.tsx +++ b/components/chapters.tsx @@ -39,7 +39,7 @@ function NavbarChapter(props: { classList={classes} title={props.chapter.name} onIconClick={() => props.chapter.children?.length > 0 && setCollapsed(!collapsed)} - href={"#" + props.chapter.sectionLink} + href={props.chapter.sectionLink} key={(() => Math.round(Math.random() * 1e12))()} style={{ marginLeft: 12 * props.level, 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: { diff --git a/posts/gert.md b/posts/gert.md new file mode 100644 index 0000000..62cc835 --- /dev/null +++ b/posts/gert.md @@ -0,0 +1,34 @@ +[meta]: <title> (Loek’s excruciatingly interesting blog) +[meta]: <subtitle> (Loek heeft dit geschreven) +[meta]: <author> (Loek) +[meta]: <date> (March 27 2021) +[meta]: <tags> (banana's, test,gert testing, debug) + +Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Gravida dictum fusce ut placerat orci nulla pellentesque. Laoreet id donec ultrices tincidunt arcu. Tortor aliquam nulla facilisi cras fermentum odio eu feugiat. A scelerisque purus semper eget duis at tellus. A iaculis at erat pellentesque adipiscing commodo elit at imperdiet. Arcu bibendum at varius vel pharetra vel turpis nunc eget. Euismod in pellentesque massa placerat duis. Lorem ipsum dolor sit amet consectetur adipiscing elit. Ultrices in iaculis nunc sed augue lacus. Vestibulum mattis ullamcorper velit sed. Adipiscing diam donec adipiscing + +[Here's a link](https://github.com/lonkaars) + +![fonny doge meme big laugh hahaha funni image big fonny me laugh because image fonne](https://external-content.duckduckgo.com/iu/?u=http%3A%2F%2Fbarkpost-assets.s3.amazonaws.com%2Fwp-content%2Fuploads%2F2013%2F11%2FplainDoge.jpg&f=1&nofb=1) + +Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Gravida dictum fusce ut placerat orci nulla pellentesque. Laoreet id donec ultrices tincidunt arcu. Tortor aliquam nulla facilisi cras fermentum odio eu feugiat. A scelerisque purus semper eget duis at tellus. A iaculis at erat pellentesque adipiscing commodo elit at imperdiet. Arcu bibendum at varius vel pharetra vel turpis nunc eget. Euismod in pellentesque massa placerat duis. Lorem ipsum dolor sit amet consectetur adipiscing elit. Ultrices in iaculis nunc sed augue lacus. Vestibulum mattis ullamcorper velit sed. Adipiscing diam donec adipiscing + +--- + +Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Gravida dictum fusce ut placerat orci nulla pellentesque. Laoreet id donec ultrices tincidunt arcu. Tortor aliquam nulla facilisi cras fermentum odio eu feugiat. A scelerisque purus semper eget duis at tellus. A iaculis at erat pellentesque adipiscing commodo elit at imperdiet. Arcu bibendum at varius vel pharetra vel turpis nunc eget. Euismod in pellentesque massa placerat duis. Lorem ipsum dolor sit amet consectetur adipiscing elit. Ultrices in iaculis nunc sed augue lacus. Vestibulum mattis ullamcorper velit sed. Adipiscing diam donec adipiscing + +Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Gravida dictum fusce ut placerat orci nulla pellentesque. Laoreet id donec ultrices tincidunt arcu. Tortor aliquam nulla facilisi cras fermentum odio eu feugiat. A scelerisque purus semper eget duis at tellus. A iaculis at erat pellentesque adipiscing commodo elit at imperdiet. Arcu bibendum at varius vel pharetra vel turpis nunc eget. Euismod in pellentesque massa placerat duis. Lorem ipsum dolor sit amet consectetur adipiscing elit. Ultrices in iaculis nunc sed augue lacus. Vestibulum mattis ullamcorper velit sed. Adipiscing diam donec adipiscing + +# Here's some hierarchy test + +## subsection + +### subsubsection + +## subsection + +### subsubsection + +### subsubsection + +### subsubsection + diff --git a/scripts/tags b/scripts/tags new file mode 100755 index 0000000..3b9272c --- /dev/null +++ b/scripts/tags @@ -0,0 +1,8 @@ +#!/bin/sh + +grep -Proh \ + "^\[meta\]:\s+<tags>\s+\(\K(.+)(?=\)$)" ../posts |\ + sed "s/,\s*/\n/g" |\ + sort |\ + uniq + |