gammastream / scully-plugins

A collection of plugins written for Scully
31 stars 9 forks source link

Export SitemapConfig to improve type-safety #13

Closed marcjulian closed 3 years ago

marcjulian commented 4 years ago

Export SitemapConfig to improve type-safety in the scully.app.config.ts

Currently the sitemap config is added like

import { getSitemapPlugin } from '@gammastream/scully-plugin-sitemap';

const SitemapPlugin = getSitemapPlugin();
setPluginConfig(SitemapPlugin, {
    urlPrefix: 'https://gamma.stream',
    sitemapFilename: 'sitemap.xml',
    merge: false,
    trailingSlash: false,
    changeFreq: 'monthly',
    priority: ['1.0', '0.9', '0.8', '0.7', '0.6', '0.5', '0.4', '0.3', '0.2', '0.1', '0.0'],
    ignoredRoutes: ['/404'],
    routes: {
        '/products/:productId': {
            changeFreq: 'daily',
            priority: '0.9',
            sitemapFilename: 'sitemap-products.xml',
            merge: true
        },
    }
});

If SitemapConfig is export it could be used to make sitemapConfig type-safe:

import { getSitemapPlugin, SitemapConfig } from '@gammastream/scully-plugin-sitemap';

const SitemapPlugin = getSitemapPlugin();
const sitemapConfig: SitemapConfig = {
    urlPrefix: 'https://gamma.stream',
    sitemapFilename: 'sitemap.xml',
    merge: false,
    trailingSlash: false,
    changeFreq: 'monthly',
    priority: ['1.0', '0.9', '0.8', '0.7', '0.6', '0.5', '0.4', '0.3', '0.2', '0.1', '0.0'],
    ignoredRoutes: ['/404'],
    routes: {
        '/products/:productId': {
            changeFreq: 'daily',
            priority: '0.9',
            sitemapFilename: 'sitemap-products.xml',
            merge: true
        },
    }
};

setPluginConfig(SitemapPlugin, sitemapConfig);
msacket commented 4 years ago

I like it @marcjulian. I'll make sure to do that in the next release. Thank you!

msacket commented 3 years ago

@marcjulian. I've exported the SitemapConfig interface and updated the package to 1.0.5.