Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update cache.js to make option to specify route name in dynamic routes for grouping to hreflang links #241

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions lib/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,24 @@ function joinRoutes(staticRoutes, dynamicRoutes) {
* @returns {Object} A valid route object
*/
function ensureIsValidRoute(route) {
route = typeof route === 'object' ? (route.route ? { url: route.route } : route) : { url: route }
// force as string
route.url = String(route.url)
return route
let routeToReturn = null;
if (typeof route === 'object') {
routeToReturn = route.route ? { url: route.route } : route

if(route.name) {
routeToReturn.name = route.name
}

if(route.lastmod) {
routeToReturn.lastmod = route.lastmod
}
} else {
routeToReturn = { url: route };
}

routeToReturn.url = String(routeToReturn.url);

return routeToReturn;
}

module.exports = { createRoutesCache }