From 562afb3c41a55874b3f412a82da0709709df7eb8 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Fri, 23 Jan 2015 16:42:01 -0700 Subject: [PATCH] scripts fix --- ENTITY.md | 2 +- desirae.js | 12 +++++++----- lib/transform-core.js | 1 + 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/ENTITY.md b/ENTITY.md index 49befed..a161fe4 100644 --- a/ENTITY.md +++ b/ENTITY.md @@ -38,7 +38,7 @@ tags : ['http','url','website'] relative_file : /posts/foo/index.html # excludes index.html -relative_link : /posts/foo/ +relative_href : /posts/foo/ # actual url of this file, even if redirect # excludes index.html diff --git a/desirae.js b/desirae.js index f628e12..c85b255 100644 --- a/desirae.js +++ b/desirae.js @@ -955,7 +955,7 @@ , author: Desi.num2str(author) }; - desi.allStyles = desi.styles; + desi.allStyles = desi.styles.slice(0); desi.styles = desi.styles.filter(function (str) { // TODO better matching return str.match('/' + themename + '/'); @@ -973,10 +973,12 @@ compiled.push({ contents: html, path: path.join(entity.relative_file.replace(env.base_path, '')) }); } - if (/\/index.html$/.test(entity.permalink)) { - entity.redirects.push(entity.permalink.replace(/\/index.html$/, '.html')); - } else if (/\.html$/.test(entity.permalink)) { - entity.redirects.push(entity.permalink.replace(/\.html?$/, '/index.html')); + // catches /a, /a/index.html, a/index.html + // but not index.html /index.html + if (/^.+\/(index\.x?html?)$/.test(entity.permalink)) { + entity.redirects.push(entity.permalink.replace(/\/(index.x?html?)?$/, '.html')); + } else if (/\.x?html?$/.test(entity.permalink)) { + entity.redirects.push(entity.permalink.replace(/\.x?html?$/, '/index.html')); } else { // found index, ignoring redirect } diff --git a/lib/transform-core.js b/lib/transform-core.js index 1962954..2ae91ff 100644 --- a/lib/transform-core.js +++ b/lib/transform-core.js @@ -149,6 +149,7 @@ .replace(/\/$/, '/index.html'); entity.relative_href = path.join(env.base_path, entity.permalink) .replace(/\/index\.html$/, '/'); + entity.relative_link = entity.relative_href; entity.url = env.base_url + path.join(env.base_path, entity.permalink) .replace(/\/index\.html$/, '/');