diff options
author | Blaster4385 <[email protected]> | 2024-04-21 19:20:06 +0530 |
---|---|---|
committer | Blaster4385 <[email protected]> | 2024-04-22 23:13:08 +0530 |
commit | c81696200f75e3d3e842c4c781601ed06b5c35c1 (patch) | |
tree | a221a70a9ec556266a93bc683814a63ee78f88b5 /index.html | |
parent | 3623473f7755d906121ae90f28da7a2ef11ecf1b (diff) |
feat: render all markdown files through a single page
Diffstat (limited to 'index.html')
-rw-r--r-- | index.html | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -44,7 +44,17 @@ <script src="markdown.js"></script> <script> document.addEventListener('DOMContentLoaded', function () { - loadMarkdownFile('home.md'); + // Get the pathname of the URL + const path = window.location.pathname; + // Remove leading slash if present + const trimmedPath = path.replace(/^\/|\/$/g, ''); + + if (trimmedPath === '') { + loadMarkdownFile('home.md'); + return; + } + // Load the markdown file based on the path + loadMarkdownFile(`${trimmedPath}.md`); }); </script> </body> |