Add: README.md preview
Some checks failed
Publish Docker rootless image / Push Docker image to Docker Hub (push) Failing after 1m14s
Publish Docker image / Push Docker image to Docker Hub (push) Failing after 1m19s

This commit is contained in:
Aroy-Art 2024-03-27 15:39:24 +01:00
parent 092042a42d
commit ef88e79ae2
Signed by: Aroy
GPG key ID: 583642324A1D2070

View file

@ -81,6 +81,19 @@ $(document).ready(function () {
return parentDir; return parentDir;
} }
function getREADMEmdFile(filesData, path) {
if (path === "") {
return null;
}
var readmeFile = filesData.find(function (fileData) {
return fileData.name === "README.md" && fileData.type === "file";
});
return readmeFile ? path + "README.md" : null;
}
function renderFileList(filesData, path) { function renderFileList(filesData, path) {
var sortBy = $('input[name=sort]:checked').val(); var sortBy = $('input[name=sort]:checked').val();
@ -190,6 +203,19 @@ $(document).ready(function () {
console.log("replaceState", path); console.log("replaceState", path);
history.replaceState(null, path, '#' + path); history.replaceState(null, path, '#' + path);
if (path) {
var readmePath = getREADMEmdFile(filesData, path);
if (readmePath) {
var zeroMdElement = document.createElement("zero-md");
zeroMdElement.setAttribute("src", filesBaseUrl + readmePath);
document.querySelector("body > div.container").appendChild(zeroMdElement);
} else {
var zeroMdElement = document.querySelector("zero-md");
if (zeroMdElement) {
document.querySelector("body > div.container").removeChild(zeroMdElement);
}
}
}
isNavigating = false; isNavigating = false;
}, },