Browse Source

scripts fix

month_name
AJ ONeal 9 years ago
parent
commit
562afb3c41
  1. 2
      ENTITY.md
  2. 12
      desirae.js
  3. 1
      lib/transform-core.js

2
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

12
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
}

1
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$/, '/');

Loading…
Cancel
Save