update root index logic
This commit is contained in:
parent
b81ed8af1c
commit
2797fd06a7
27
desirae.js
27
desirae.js
|
@ -268,7 +268,7 @@
|
||||||
themename = desi.site.theme;
|
themename = desi.site.theme;
|
||||||
}
|
}
|
||||||
|
|
||||||
// defaults to ruhoh-twitter defaults
|
// TODO NO DEFAULTS
|
||||||
if ('__page__' === layoutname) {
|
if ('__page__' === layoutname) {
|
||||||
layoutname = desi.config.themes[themename].pageLayout || 'page';
|
layoutname = desi.config.themes[themename].pageLayout || 'page';
|
||||||
} else if ('__post__' === layoutname) {
|
} else if ('__post__' === layoutname) {
|
||||||
|
@ -663,16 +663,15 @@
|
||||||
desi.navigation = [];
|
desi.navigation = [];
|
||||||
|
|
||||||
desi.content.root.forEach(function (entity) {
|
desi.content.root.forEach(function (entity) {
|
||||||
// XXX BUG TODO strip only strip _root so that nested nav will work as expected
|
var name = path.join(entity.relativePath, path.basename(entity.name, path.extname(entity.name)))
|
||||||
var name = path.basename(entity.path, path.extname(entity.path))
|
|
||||||
, nindex
|
, nindex
|
||||||
;
|
;
|
||||||
|
|
||||||
if (alwaysAdd && /^(_root\/)index(\.\w+)$/i.test(entity.path)) {
|
// The index should not show up in the automatic listing
|
||||||
|
if (alwaysAdd && 'index' === name) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (-1 === desi.data.navigation.indexOf(name) && 'index' !== name)
|
|
||||||
nindex = (desi.site.navigation).indexOf(name);
|
nindex = (desi.site.navigation).indexOf(name);
|
||||||
if (!alwaysAdd && -1 === nindex) {
|
if (!alwaysAdd && -1 === nindex) {
|
||||||
return;
|
return;
|
||||||
|
@ -680,6 +679,7 @@
|
||||||
nindex = desi.navigation.length;
|
nindex = desi.navigation.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO this happens before normalization... should fix that...
|
||||||
desi.navigation[nindex] = {
|
desi.navigation[nindex] = {
|
||||||
title: entity.yml && entity.yml.title || Desi.firstCap(name)
|
title: entity.yml && entity.yml.title || Desi.firstCap(name)
|
||||||
, name: name
|
, name: name
|
||||||
|
@ -920,19 +920,24 @@
|
||||||
|
|
||||||
// TODO nested names?
|
// TODO nested names?
|
||||||
navigation.forEach(function (nav) {
|
navigation.forEach(function (nav) {
|
||||||
|
// TODO allow permalink
|
||||||
nav.href = path.join(env.base_path, nav.name);
|
nav.href = path.join(env.base_path, nav.name);
|
||||||
nav.path = path.join(env.base_path, nav.name);
|
|
||||||
|
|
||||||
// path.basename(nav.path, path.extname(nav.path))
|
if (!/\.x?html?$/.test(nav.href)) {
|
||||||
//console.log('!!! entity', entity);
|
// add trailing slash
|
||||||
|
nav.href += '/';
|
||||||
|
}
|
||||||
|
|
||||||
if (nav.href.replace(/(\/)?(\/index)?(\.html)?$/i, '')
|
if (nav.href.replace(/(\/)?(\/index)?(\.html)?$/i, '')
|
||||||
=== entity.relative_url.replace(/(\/)?(\/index)?(\.html)?$/i, '')) {
|
=== entity.relative_url.replace(/(\/)?(\/index)?(\.html)?$/i, '')) {
|
||||||
nav.active = true;
|
nav.active = true;
|
||||||
}
|
}
|
||||||
if (env.explicitIndexes) {
|
|
||||||
nav.href = nav.href + '/index.html';
|
if (env.explicitIndexes && !/\.x?html?$/.test(nav.href)) {
|
||||||
nav.path = nav.path + '/index.html';
|
nav.href = path.join(nav.href, 'index.html');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nav.path = nav.href;
|
||||||
});
|
});
|
||||||
|
|
||||||
view = {
|
view = {
|
||||||
|
|
|
@ -60,7 +60,12 @@
|
||||||
|
|
||||||
// _root is not subject to the same permalink rules as collections,
|
// _root is not subject to the same permalink rules as collections,
|
||||||
// so we just go ahead and define that here
|
// so we just go ahead and define that here
|
||||||
entity.permalink = entity.yml.permalink || entity.path.replace(/\.\w+$/, '');
|
console.log('root entity.path', entity.path);
|
||||||
|
if (/^index\.\w+$/.test(entity.path)) {
|
||||||
|
entity.permalink = '/';
|
||||||
|
} else {
|
||||||
|
entity.permalink = entity.yml.permalink || entity.path.replace(/\.\w+$/, '/');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
cores.normalize = function (desi, env, collection, entity) {
|
cores.normalize = function (desi, env, collection, entity) {
|
||||||
|
@ -127,7 +132,7 @@
|
||||||
if (!entity.permalink) {
|
if (!entity.permalink) {
|
||||||
// try the fallback_permalink first (because we're looking at files that don't have yml)
|
// try the fallback_permalink first (because we're looking at files that don't have yml)
|
||||||
// then try the normal permalink (because :filename -> :title and whatnot, so it'll work)
|
// then try the normal permalink (because :filename -> :title and whatnot, so it'll work)
|
||||||
Desi.permalinkify(desi, collection.fallback_permalink || collection.permalink, entity);
|
entity.permalink = Desi.permalinkify(desi, collection.fallback_permalink || collection.permalink, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -136,11 +141,6 @@
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// The root index is the one exception
|
|
||||||
if (/^(index)?\/?index(\.x?html?)?$/.test(entity.permalink)) {
|
|
||||||
entity.permalink = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
// relative to the site
|
// relative to the site
|
||||||
entity.relative_file = path.join(env.base_path, entity.permalink)
|
entity.relative_file = path.join(env.base_path, entity.permalink)
|
||||||
.replace(/\/$/, '/index.html');
|
.replace(/\/$/, '/index.html');
|
||||||
|
|
Loading…
Reference in New Issue