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
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:
parent
092042a42d
commit
ef88e79ae2
1 changed files with 26 additions and 0 deletions
26
js/main.js
26
js/main.js
|
@ -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;
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue