Integrate Cusdis into Hexo

April 25, 2021

Hexo is a popular blog framework in Node.js. It’s very easy to integrate Cusdis into hexo. Suppose user has such theme’s _config.yml:

cusdis:
  host:
  app_id: xxx

Here is an example in Nunjucks/Swig template syntax:

<div id="cusdis_thread"
  data-host="{{ theme.cusdis.host || 'https://cusdis.com' }}"
  data-app-id="{{ theme.cusdis.app_id }}"
  data-page-id="{{ page.path }}"
  data-page-url="{{ page.permalink }}"
  data-page-title="{{ page.title }}"
></div>

If you use different template, just follow this cheatsheet:

Attribute Hexo variable
data-host set by user in config
data-app-id set by user in config
data-page-id page.path
data-page-title page.title
data-page-url page.permalink

Here is an example we integrate Cusdis into hexo-theme-even.


Comments