gammastream / scully-plugins

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

Type error in SitemapConfig `routes: any[]` #14

Closed marcjulian closed 3 years ago

marcjulian commented 3 years ago

I updated the sitemap plugin to use the newly exported SitemapConfig

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);

The types for routes is not matching as it is declared as any[] array.

Error from VSCode

Type '{ '/products/:productId': { changeFreq: string; priority: string; sitemapFilename: string; merge: true; }; }' is not assignable to type 'any[]'.
  Object literal may only specify known properties, and ''/products/:productId'' does not exist in type 'any[]'.ts(2322)
sitemap-config.d.ts(20, 5): The expected type comes from property 'routes' which is declared here on type 'SitemapConfig'
msacket commented 3 years ago

@marcjulian Thanks for the PR! I've merged it and pushed a new package to npm.