Filter pages

To filter pages under a specific condition

Options See on deno.land

extensions string[] *

The list of extensions this plugin applies to

Default:
"*"
fn function

The function to test the page

Default:
(page) => true

Description

This plugin allows to filter the pages of your site using a callback.

Installation

The plugin requires a function that receives the Page instance as the first argument and must return a boolean. If it returns false, the page will be discarded. For example, to remove all pages with the property ignored=true:

import lume from "lume/mod.ts";
import filterPages from "lume/plugins/filter_pages.ts";

const site = lume();

site.use(filterPages({
  fn: (page) => page.data.ignored !== true,
}));

export default site;

Limiting which files to test

By default the plugin tests all output files: not only 'pages' but also assets like .css. You can control this with the extensions option which specifies the extensions to apply to:

site.use(filterPages({
  extensions: [".html", ".json"],
  fn: (page) => page.data.ignored !== true,
}));

This will only test output files with the extensions .html or .json, all other pages will not be tested.