This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Step 1: Parse metadata and components from markdown file */ | |
| const decoder = new TextDecoder("utf-8"); | |
| const fileContent = decoder.decode(Deno.readFileSync(filename)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Step 1: Parse metadata and components from markdown file */ | |
| const decoder = new TextDecoder("utf-8"); | |
| const fileContent = decoder.decode(Deno.readFileSync(filename)); | |
| const components = fileContent.split(COMPONENT_DELIMITER); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [ | |
| "---\ntitle: Deno Markdown Site\nstyles: >\n body { color: #22a6b3; }\nfavicon: 🦕\n---\n/home:Home\n\n# Hom...", | |
| "\n/about:About\n\n# About\n\nBuilt for learning.\n\n", | |
| "\nlayout:footer\n\ndeno-md-site\n" | |
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Step 1: Parse metadata and components from markdown file */ | |
| const decoder = new TextDecoder("utf-8"); | |
| const fileContent = decoder.decode(Deno.readFileSync(filename)); | |
| const components = fileContent.split(COMPONENT_DELIMITER); | |
| const { meta: frontMatter } = Marked.parse(components[FIRST_ITEM_INDEX]); | |
| const { title, styles, favicon } = frontMatter; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { title: "Deno Markdown Site", styles: "body { color: #22a6b3; }\n", favicon: "🦕" } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Step 2: Construct page data from components */ | |
| for (const component of components) { | |
| const { content } = Marked.parse(component); | |
| console.log(content); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <p>/home:Home</p> | |
| <h1 id="home">Home</h1> | |
| <p>Hello world!</p> | |
| <p>/about:About</p> | |
| <h1 id="about">About</h1> | |
| <p>Built for learning.</p> | |
| <p>layout:footer</p> | |
| <p>deno-md-site</p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const COMPONENT_TYPE_PATTERN = /<\S>(.*?)\:(.*?)<\/\S>/g; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Step 2: Construct page data from components */ | |
| for (const component of components) { | |
| const { content } = Marked.parse(component); | |
| const [matchedComponentType] = content.matchAll(COMPONENT_TYPE_PATTERN); | |
| const [, path, name] = matchedComponentType; | |
| console.log({ path, name }); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { path: "/home", name: "Home" } | |
| { path: "/about", name: "About" } | |
| { path: "layout", name: "footer" } |