Skip to content

Commit

Permalink
Update tutorial.html
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamster3000 authored Sep 29, 2024
1 parent 870e30f commit 72034d2
Showing 1 changed file with 1 addition and 41 deletions.
42 changes: 1 addition & 41 deletions public/pages/tutorial.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,47 +8,7 @@
<link rel="stylesheet" href="../styles/tutorial.css">
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<script src="../components/components.js"></script>
<script>
document.addEventListener("DOMContentLoaded", async function () {
const tutorialContent = document.getElementById('tutorial-content');
const tutorialTitle = document.getElementById('tutorial-title');

function getQueryParam(param) {
const urlParams = new URLSearchParams(window.location.search);
return urlParams.get(param);
}

async function fetchMarkdownFile(filename) {
const response = await fetch(`../tutorials/${filename}`);
if (!response.ok) {
throw new Error(`Error fetching ${filename}`);
}
return await response.text();
}

try {
const file = getQueryParam('file');
if (!file) {
throw new Error('No file specified in query parameter.');
}
const markdown = await fetchMarkdownFile(file);
const htmlContent = marked.parse(markdown);

// Display title dynamically from the filename
const title = file.split('-').slice(3).join(' ').replace('.md', '');
if (tutorialTitle) {
tutorialTitle.textContent = title;
} else {
console.error('Element with ID "tutorial-title" not found.');
}

tutorialContent.innerHTML = htmlContent;
} catch (error) {
console.error('Error loading tutorial:', error);
tutorialContent.innerHTML = '<p>Sorry, this tutorial could not be loaded.</p>';
}
});
</script>
<script src="../scripts/tutorial.js"></style>
</head>
<body>
<div id="header-placeholder"></div>
Expand Down

0 comments on commit 72034d2

Please sign in to comment.