Blog plugin for Cogear.JS
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Blog plugin for Cogear.JS

Features | Installation | Usage | Post | Layouts | Pagination


Cogear.JS blog plugin in action


  • Data stored in flat files (as pages)
  • Pagination
  • Tags


Go to the site folder and install plugin with command:

yarn add cogear-plugin-blog
# or 
npm install cogear-plugin-blog

Plugin will loads up automatically.


By default it creates virtual blog page (uri /blog) and passed all the posts in ./src/pages/blog (can be customized) folder while rendering layout of blog page (also named the same).

Layout blog must be created in ./src/layouts or using theme layouts.

Variables passed to this layout:

  • posts – list of posts
    Typical Cogear.JS pages objects) with one exception – they have teaser field.
  • paginator - pagination data (Read More)
  • tags - all posts tags (for creating navs)


Let's take a look of typical post page.

Pay attention to tags which are passed to blog instance and to splitter ===, which bring teaser (before it) and full (without it) views.

Listing ./src/pages/blog/2018/08/

title: Welcome to Cogear.JS blog!
 - news

We are happy to introduce **Cogear.JS** – modern static websites generator. 
It's written in [Node.JS]( and powered by the latest [Webpack](

Read [the docs](/docs) to understand how the system works.


As you can see it's even suitable for blogging! Every blog post can have comments via modern services like [Disqus]( Posts can also be tagged.

All blog pages are built automatically and rebuilt when proper content pages are changed, added or deleted.


> Posts can even have teaser which is splitted from main content by 3 and more `=`,`:`,`_`,`--` symbol (new line only).

To create a blog on your site, please install [`cogear-plugin-blog`]( npm package and follow the instructions in `` file.

We really appreciate your attention, so it will be great if you write a comment.


All the layouts can be found at ./layouts folder of this repository.

Copy them to ./src/layouts or to a theme layouts folder, style it and use.

Generated pages

Plugin generates the following pages:

  • blog – index blog page
  • blog/[page-num] – pagination for index page
  • blog/tag/[tag] – tag index page
  • blog/tag/[tag]/[page-num] – pagination for tag index page


Pagination object passed to layout has the following properties:

  • count - total blog posts count
  • total - total pages number
  • current - current page
  • next - next page link
  • prev - prev page link


When post is changed, add or deleted all connected blog pages will be regenereated automatically and browser window will be refreshed.


If you wanna configure plugin, add blog section to ./config.yaml:

  posts: ^blog\/(?!tag).+ # Pages are feeded to blog page, tags pages and paginator
  split: '\<p\>[:=_-]{3,}\<\/p\>' # Regex to split teaser and full view, for PARSED content in html		

You may change blog.regex.posts expression to serve posts from another folder.

To change split symbol which divides post into teaser and full view, set up new blog.regex.split expression.

How to make post author name and avatar?

With ease. Use pages config param to pass all posts sitting on blog uri needed params:

    layout: blog
      - js/blog.js
      name: Dmitry Beliaev

As you see custom webpack entry point js/blog.js was also added to customize scripts and styles.


It's a bit nightmare to test async operations manually, because of error handling. But I've do my best 🔥

  • Automated testing…


How to create your own plugin?

Read the docs: