Skip to content

Commit

Permalink
Merge a5d28e7 into 9d7a18d
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed Apr 16, 2020
2 parents 9d7a18d + a5d28e7 commit 3c9f080
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
15 changes: 15 additions & 0 deletions lib/helpers.js
Expand Up @@ -82,6 +82,20 @@ function getPageTitle(pageTitle) {
return `${pageTitle} · ${app.title_suffix}`;
}

function generateBodyClass(pathname) {
if (pathname === '/') {
return 'page-home'; // only for the homepage
}

// Remove any backslashes
pathname = pathname.replace(/\//g, '');

// Make the first letter lowercase
pathname = pathname.charAt(0).toLowerCase() + pathname.slice(1);

return `page-${pathname}`;
}

module.exports = {
capitalize,
generateDataJson,
Expand All @@ -90,6 +104,7 @@ module.exports = {
selected: selectedTheme
},
getPageTitle,
generateBodyClass,
generateSri
};

Expand Down
14 changes: 1 addition & 13 deletions routes/appendLocals.js
@@ -1,6 +1,7 @@
'use strict';

const { app, files } = require('../config');
const { generateBodyClass } = require('../lib/helpers');

function getCurrentSiteurl(req) {
let proto = req.get('x-forwarded-proto');
Expand All @@ -24,19 +25,6 @@ function getThemeQuery(req) {
return query;
}

function generateBodyClass(pathname) {
if (pathname === '/') {
pathname = 'home'; // only for the index page
}

pathname = pathname.replace(/\//g, ''); // remove any slashes

// Make the first letter lowercase
pathname = pathname.charAt(0).toLowerCase() + pathname.slice(1);

return `page-${pathname}`;
}

function appendLocals(req, res) {
const siteUrl = getCurrentSiteurl(req);
const pageUrl = req.originalUrl;
Expand Down

0 comments on commit 3c9f080

Please sign in to comment.