hexo-helper-page-languages
v0.0.1
Published
List available language on a hexo page
Downloads
2
Maintainers
Readme
hexo-helper-page-languages
Get available languages as links on one page
Install
Install using npm.
$ npm install hexo-helper-page-languages --save
Usage
In your front-matter.
The default language:
title: Hello World
lang: en
contentId: hello-word
A translated version:
title: Bonjour le monde
lang: fr
contentId: hello-word
If contentId is not provided, the full path except language will be used as value. The contentId variable is really usefull only if your file names are translated.
This can come handy if you care about SEO.
in your ejs templates
List all pages for the same contentId.
<dl>
<dt><%= __('footer.otherlang') %></dt>
<% var versions = getPageLanguages();
for (var i=0; i<versions.length; i++) { %>
<dd><a href="<%= versions[i].url %>"><%= versions[i].label %></a></dd>
<% } %>
</dl>