scripts fix

This commit is contained in:
AJ ONeal 2015-01-23 16:42:01 -07:00
parent 5f02698d0a
commit 562afb3c41
3 changed files with 9 additions and 6 deletions

View File

@ -38,7 +38,7 @@ tags : ['http','url','website']
relative_file : /posts/foo/index.html relative_file : /posts/foo/index.html
# excludes index.html # excludes index.html
relative_link : /posts/foo/ relative_href : /posts/foo/
# actual url of this file, even if redirect # actual url of this file, even if redirect
# excludes index.html # excludes index.html

View File

@ -955,7 +955,7 @@
, author: Desi.num2str(author) , author: Desi.num2str(author)
}; };
desi.allStyles = desi.styles; desi.allStyles = desi.styles.slice(0);
desi.styles = desi.styles.filter(function (str) { desi.styles = desi.styles.filter(function (str) {
// TODO better matching // TODO better matching
return str.match('/' + themename + '/'); return str.match('/' + themename + '/');
@ -973,10 +973,12 @@
compiled.push({ contents: html, path: path.join(entity.relative_file.replace(env.base_path, '')) }); compiled.push({ contents: html, path: path.join(entity.relative_file.replace(env.base_path, '')) });
} }
if (/\/index.html$/.test(entity.permalink)) { // catches /a, /a/index.html, a/index.html
entity.redirects.push(entity.permalink.replace(/\/index.html$/, '.html')); // but not index.html /index.html
} else if (/\.html$/.test(entity.permalink)) { if (/^.+\/(index\.x?html?)$/.test(entity.permalink)) {
entity.redirects.push(entity.permalink.replace(/\.html?$/, '/index.html')); 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 { } else {
// found index, ignoring redirect // found index, ignoring redirect
} }

View File

@ -149,6 +149,7 @@
.replace(/\/$/, '/index.html'); .replace(/\/$/, '/index.html');
entity.relative_href = path.join(env.base_path, entity.permalink) entity.relative_href = path.join(env.base_path, entity.permalink)
.replace(/\/index\.html$/, '/'); .replace(/\/index\.html$/, '/');
entity.relative_link = entity.relative_href;
entity.url = env.base_url + path.join(env.base_path, entity.permalink) entity.url = env.base_url + path.join(env.base_path, entity.permalink)
.replace(/\/index\.html$/, '/'); .replace(/\/index\.html$/, '/');