diff --git a/components/TagIcon.js b/components/TagIcon.js new file mode 100644 index 000000000..39d17a719 --- /dev/null +++ b/components/TagIcon.js @@ -0,0 +1,19 @@ +import React from "react"; + +export default () => ( + +); diff --git a/lib/tags.js b/lib/tags.js new file mode 100644 index 000000000..e87a206ae --- /dev/null +++ b/lib/tags.js @@ -0,0 +1,13 @@ +export const parseTags = (strings) => { + const postTags = keys + .map((key, index) => { + const value = values[index]; + // Parse yaml metadata & markdownbody in document + + const document = matter(value.default); + const rawTags = document.data?.tags || ""; + return rawTags.split(",").map((tag) => tag.trim()); + }) + .flat() + .filter((value) => value !== ""); +}; diff --git a/pages/posts/[post].js b/pages/posts/[post].js index c7584671e..a4680d08b 100644 --- a/pages/posts/[post].js +++ b/pages/posts/[post].js @@ -5,6 +5,7 @@ import rehypeRaw from "rehype-raw"; import Page from "../../components/Page"; import glob from "glob"; import React from "react"; +import TagIcon from "../../components/TagIcon"; export default function BlogTemplate(props) { function reformatDate(fullDate) { @@ -31,6 +32,21 @@ export default function BlogTemplate(props) { }); }; + const renderTagList = () => { + const tags = props.frontmatter.tags + ?.split(",") + .map((tag) => tag.trim()); + + return ( +