vimwiki icon indicating copy to clipboard operation
vimwiki copied to clipboard

Feature request: Make it possible to write custom variables to be used in HTML generation

Open stroiman opened this issue 7 years ago • 2 comments

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';
};

stroiman avatar Dec 04 '17 11:12 stroiman

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>

stroiman avatar Dec 04 '17 12:12 stroiman

Feel free to improve the html conversion, I just created a reference ticket #1139.

tinmarino avatar Jun 11 '21 15:06 tinmarino