Last active
October 22, 2018 10:14
-
-
Save kynetiv/b27da64adaa1341750aafc4271764831 to your computer and use it in GitHub Desktop.
Hack for Hexo post permalink overrides
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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