Fixed breadcrumbs

This commit is contained in:
David Ball 2024-03-28 11:02:03 -04:00
parent 6d53fff6f3
commit 5341507431
2 changed files with 7 additions and 1 deletions

View File

@ -23,7 +23,7 @@
<%= h.trimSlashes({path: value.name}) %> <%= h.trimSlashes({path: value.name}) %>
<% } else { %> <% } else { %>
<a href="/<%= value.url %>"> <a href="/<%= value.url %>">
<%= h.getDirectoryTitle({directory: value.name}) %> <%= h.getDirectoryName({directory: value.name}) %>
</a> </a>
<% } %> <% } %>
<% }); %> <% }); %>

View File

@ -24,6 +24,11 @@ const getSiteName = () => {
const trimSlashes = ({path}) => { const trimSlashes = ({path}) => {
return path.replace(/^[\/\\]|[\/\\]$/g, ''); return path.replace(/^[\/\\]|[\/\\]$/g, '');
}; };
const getDirectoryName = ({directory}) => {
directory = trimSlashes({path: directory});
let title = trimSlashes({path: directory.replace("public", "")}).replaceAll(path.sep, path.posix.sep);
return (directory=="public") ? getSiteName() : title;
};
const getDirectoryTitle = ({directory}) => { const getDirectoryTitle = ({directory}) => {
directory = trimSlashes({path: directory}); directory = trimSlashes({path: directory});
let title = trimSlashes({path: directory.replace("public", "")}).replaceAll(path.sep, path.posix.sep); let title = trimSlashes({path: directory.replace("public", "")}).replaceAll(path.sep, path.posix.sep);
@ -60,6 +65,7 @@ const printReadme = ({directory}) => {
module.exports = { module.exports = {
trimSlashes, trimSlashes,
getSiteName, getSiteName,
getDirectoryName,
getDirectoryTitle, getDirectoryTitle,
getWelcomeBanner, getWelcomeBanner,
shouldShowDirectorySeparator, shouldShowDirectorySeparator,