Skip to content

An event listener to generate default category pages on a Jigsaw blog

License

Notifications You must be signed in to change notification settings

camuthig/jigsaw-blog-default-categories

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jigsaw Blog Template Category Generator

An event listener to allow generating default category pages for the Jigsaw Blog template when an explicit page is not configured.

Install

composer require camuthig/jigsaw-blog-default-categories:dev-master@dev

Setup

Add the listener to the afterCollections phase of your blog's bootstrap.php

<?php

// bootstrap.php

$events->afterCollections(\Camuthig\Jigsaw\DefaultCategories\GenerateDefaultCategories::class);

How it Works

The listener waits for the collections to be built, it then goes through the posts and categories collections, determining which categories exist on the posts but do not have a file configured for them in the categories collection already.

From there, it creates a new collections configuration, adds it to Jigsaw's configuration, and reloads the collection data.

Reloading all of the collection data is likely overkill. However, after spending more time than I wanted trying to create the appropriate data myself, I decided it was better to go this route.

Each of the default category pages is treated as a remote collection, so an empty source/_defaultCategories directory will created after building the site.

About

An event listener to generate default category pages on a Jigsaw blog

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages