Skip to content

Instantly share code, notes, and snippets.

@kynetiv
Last active October 22, 2018 10:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kynetiv/b27da64adaa1341750aafc4271764831 to your computer and use it in GitHub Desktop.
Save kynetiv/b27da64adaa1341750aafc4271764831 to your computer and use it in GitHub Desktop.
Hack for Hexo post permalink overrides
/**
* Fix post permalink not overriding config permalink in Hexo v3.2.2
* Add a `mypermalink: hello-example` to any post front-matter to override config.
* Place this script in your project/scripts directory (project/scripts/hexo-post-permalink-fix.js)
*/
hexo.extend.filter.register('post_permalink', function(data) {
if (typeof data.mypermalink != "undefined") {
// unregister default post_permalink filter that doesn't respect custom post permalink
hexo.extend.filter.unregister('post_permalink', require('hexo/lib/plugins/filter/post_permalink') );
// hacky way to bypass an error due to newly missing filter above
hexo.extend.filter.register('post_permalink', function(data) { return data; });
return data.mypermalink + '.html';
}
return data;
}, 9);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment