vimwiki
vimwiki copied to clipboard
Feature request: Make it possible to write custom variables to be used in HTML generation
I've been toying with the idea of converting my website from a wordpress site to a set of vimwiki pages, using Disqus for handling comments. The Disqus javascript needs to have two variables specified in order to work correctly, a page url, and an identifier:
var disqus_config = function () {
this.page.url = 'https://example.com/blog/vim-wiki-as'; // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = '1234'; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};
It would be nice (maybe even essential) if I could define these variables in the .wiki file, e.g.
%title Using VimWiki with Disqus
%template template_blog
%disqusUrl using-vimwiki-with-disqus
%disqusId 2edc65d0-d8e8-11e7-a7ea-54ee75cc7d26
= Using VimWiki with Disqus =
Quite easy! :)
And then I could write something like this in the template:
var disqus_config = function () {
this.page.url = 'https://example.com/blog/%disqusUrl';
this.page.identifier = '%disqusId';
};
I might have found a workaround for now. Add 'script' to g:vimwiki_valid_html_tags and add the following script to the specific blog page. Note that I have to split up the link, because vimwiki still tries to html-ify the stuff inside the script element, and therefore it tries to convert the url to an html link.
Custom variables for html generation would still be a nicer solution.
<script>
var disqus_config = function () {
this.page.url = "https:" + "//example.com/blog/foo";
this.page.identifier = '1234';
};
</script>
Feel free to improve the html conversion, I just created a reference ticket #1139.