Switched video player to use modular breadcrumbs feature.

This commit is contained in:
David Ball 2024-06-18 11:45:51 -04:00
parent 76a460abcd
commit ece488c177
3 changed files with 12 additions and 21 deletions

View File

@ -173,7 +173,16 @@ export default function () {
else {
let info = JSON.parse((await readFile(fullFilePath)).toString());
let subtitleVTT = fs.existsSync(subtitleFile) ? (await readFile(subtitleFile)).toString() : '';
const renderData = { route, filePath, fullFilePath, req, paths, directory: path.join('public', directory), videoURL, subtitleURL, subtitleVTT, info };
let breadcrumbs: Breadcrumb[] = [];
paths.forEach((path, index, paths) => {
if (index == 0) {
breadcrumbs.push({ title: config.siteName, url: '/' });
}
else {
breadcrumbs.push({ title: helpers.getDirectoryName(path.name).replaceAll('_', ' ').replaceAll('-', ' '), url: `/${path.url}` });
}
});
const renderData = { breadcrumbs, route, filePath, fullFilePath, req, paths, directory: path.join('public', directory), videoURL, subtitleURL, subtitleVTT, info };
res.render("video-player", { h: helpers, ...renderData });
}
});

View File

@ -27,7 +27,7 @@ console.log(`Assigning /search route to search router.`);
app.use('/search', searchRouter());
// app.use('/advanced-search', advancedSearch.router);
// Search endpoints
// Page endpoints
console.log(`Assigning / route to page router.`);
app.use('/', pageRouter());

View File

@ -12,25 +12,7 @@
<main class="container">
<header>
<h1 class="mt-5" style="font-family: 'Covered By Your Grace'">
<% paths.forEach(function(value, index) { %>
<% if (h.shouldShowDirectorySeparator(index)) { %>
<span class="separator">&rsaquo; </span>
<% } %>
<% if (h.shouldShowSiteWelcomeMessage(paths)) { %>
<i>&nbsp;</i>
<%= h.getSiteWelcomeMessage() %>
<% } else if (h.shouldOmitLinkOnLastBreadcrumb(paths, index)) { %>
<%= h.trimSlashes(value.name) %>
<% } else if (index == 0) { %>
<a href="/"><%= h.getSiteName() %></a>
<% } else { %>
<a href="/<%= value.url %>">
<%= h.getDirectoryName(value.name) %>
</a>
<% } %>
<% }); %>
</h1>
<%- include('./includes/breadcrumbs.ejs') %>
</header>
<% if (typeof videoURL !== 'undefined') {%>