-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrender.js
More file actions
26 lines (23 loc) · 1015 Bytes
/
Copy pathrender.js
File metadata and controls
26 lines (23 loc) · 1015 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const urlParameters = new URLSearchParams(window.location.search);
const fileID = urlParameters.get('id');
const movieTitle = urlParameters.get('title');
const movieDate = urlParameters.get('date');
if (fileID) {
document.getElementById('template-title').textContent = movieTitle;
document.getElementById('tab-title').textContent = `${movieTitle} - CodeDuck`;
document.getElementById('template-date').textContent = movieDate;
fetch(`content/${fileID}.md`)
.then(answer => {
if (!answer.ok) throw new Error("This .md file was not found in the server");
return answer.text();
})
.then(rawMarkdown => {
const generatedHTML = marked.parse(rawMarkdown);
document.getElementById('template-body').innerHTML = generatedHTML;
})
.catch(error => {
document.getElementById('template-body').innerHTML = "<p>Critical Error: Review not found or corrupted.</p>";
});
} else {
document.getElementById('template-body').textContent = "Movie not specified on the URL";
}