Javascript

o-blog uses some javascript to handle some parts of the page, such as the menu builder or the tag-cloud generator. This article explains you how to use them.

Tag cloud

A tag cloud is generated for all articles and pages tags. The tag size depends on its frequency. During the export process, a JSON file tags.js is generated in the publishing directory. You can display it in any part of an HTML page using an HTML tag of class ob-tagcloud.

<span
  class="ob-tagcloud"
  data-source="<lisp>(ob:path-to-root)</lisp>/tags.js"
  data-path-to-root="<lisp>(ob:path-to-root)</lisp>"/>

The JavaScript widget takes 2 arguments in data-* attributes:

  • source is the path to the JSON structure.
  • path-to-root is the path to the site root directory.

Articles

Same as the tag cloud, an article JSON file is generated during the export process in articles.js into the publishing directory. You can display articles list anywhere in the HTML page using an HTML tag of class ob-articles.

<span
  class="ob-articles"
  data-source="<lisp>(ob:path-to-root)</lisp>/articles.js"
  data-path-to-root="<lisp>(ob:path-to-root)</lisp>"
  data-category="lorem"/>
<span
  class="ob-articles"
  data-source="<lisp>(ob:path-to-root)</lisp>/articles.js"
  data-path-to-root="<lisp>(ob:path-to-root)</lisp>"
  data-category="lorem"
  data-excerpt="true"
  data-limit="2"/>

The JavaScript widget takes 2 arguments in data-* attributes:

  • source is the path to the JSON structure.
  • path-to-root is the path to the site root directory.
  • category is the article category to handle.
  • excerpt (optional) if true add article excerpt, insert only titles otherwise.
  • limit (optional) is the article limit count.