WIP: c9f5dfc Update 'content/projects/RE-Chess.md'

This commit is contained in:
rei
2023-03-13 23:43:17 +01:00
parent 9b8b59d4e6
commit 63245d9afd
3 changed files with 35 additions and 7 deletions

View File

@@ -74,6 +74,24 @@ export const getAllProjectsFrontMatter = (): Post[] => {
);
};
export const getHeadings = (markdown: string): any => {
const headingOne = markdown.match(/^(#{1})\s(.*)/gm);
const headingTwo = markdown.match(/^(#{2})\s(.*)/gm);
const headingThree = markdown.match(/^(#{3})\s(.*)/gm);
const headingFour = markdown.match(/^(#{4})\s(.*)/gm);
const headings = markdown.match(/^(#{1,4})\s(.*)/gm);
var tree: any[] = [];
var prev = "";
headings?.forEach((heading) => {
if (headingOne?.includes(heading)) {
tree.push(heading);
}
});
return tree;
};
export async function markdownToHtml(markdown: any) {
const result = await remark().use(html).process(markdown);
return result.toString();