@gammastream/scully-plugin-regex
TypeScript icon, indicating that this package has built-in type declarations

2.0.3 • Public • Published

scully-plugin-regex

This postRenderer plugin for Scully will apply the configured regex replacements to your Scully rendered HTML.

Version 2.0.0 introduces breaking changes in the way the plugin is configured. It allows for a bit of decoupling from the main ScullyConfig

Installation

To install this library with npm run:

$ npm install @gammastream/scully-plugin-regex --save-dev

Usage

Add the plugin to the defaultPostRenderers to execute it on all rendered pages:

import { ScullyConfig, setPluginConfig } from '@scullyio/scully';
import { getRegexPlugin } from '@gammastream/scully-plugin-regex';

const RegexPlugin = getRegexPlugin();
setPluginConfig(RegexPlugin, {
    replacements: [{
        from: 'foo',
        to: 'foobar'
    }, {
        from: new RegExp('([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)', 'gi'),
        to: '<a href="mailto:$1">$1</a>'
    }],
    routes: {
        '/products/:productId': {
            replacements: [{
                from: 'foo',
                to: 'foofoo'
            }]
        },
    }
});

export const config: ScullyConfig = {
  projectRoot: './src',
  projectName: 'scully-plugins',
  outDir: './dist/static',
  defaultPostRenderers: [RegexPlugin],
  routes: {
    '/products/:productId': {
        type: 'json',
        productId: {
            url: 'http://localhost:4200/assets/products.json',
            property: 'id',
        }
    }
  }
};

Build app and run scully like normal.

npm run build
npm run scully

Questions or Issues

If you have any issues you can raise them here or contact me at: GammaStream

Readme

Keywords

Package Sidebar

Install

npm i @gammastream/scully-plugin-regex

Weekly Downloads

25

Version

2.0.3

License

MIT

Unpacked Size

90.9 kB

Total Files

15

Last publish

Collaborators

  • tatefowble
  • msacket