From 4fcefa34f979e23b8c48940b5a5da57fdabc32a4 Mon Sep 17 00:00:00 2001 From: vic1707 <28602203+vic1707@users.noreply.github.com> Date: Fri, 17 Feb 2023 19:46:00 +0100 Subject: [PATCH] update `ChangeFreq` to support typescript configurations with string literal (#6262) * update `ChangeFreq` * `pnpm exec changeset` * use @Princesseuh suggested change * Revert "use @Princesseuh suggested change" This reverts commit a1e5660c25cb20b79444b27adffeec24b65e1fd6. * use @Princesseuh suggested change and an `as` --- .changeset/shiny-years-beg.md | 5 +++++ packages/integrations/sitemap/src/generate-sitemap.ts | 3 ++- packages/integrations/sitemap/src/index.ts | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changeset/shiny-years-beg.md diff --git a/.changeset/shiny-years-beg.md b/.changeset/shiny-years-beg.md new file mode 100644 index 0000000000..a7c834e696 --- /dev/null +++ b/.changeset/shiny-years-beg.md @@ -0,0 +1,5 @@ +--- +'@astrojs/sitemap': minor +--- + +update `ChangeFreq` to support typescript configurations with string literal or predefined value. diff --git a/packages/integrations/sitemap/src/generate-sitemap.ts b/packages/integrations/sitemap/src/generate-sitemap.ts index c115048224..cb10bf2f6a 100644 --- a/packages/integrations/sitemap/src/generate-sitemap.ts +++ b/packages/integrations/sitemap/src/generate-sitemap.ts @@ -1,3 +1,4 @@ +import { EnumChangefreq } from 'sitemap'; import type { SitemapItem, SitemapOptions } from './index.js'; import { parseUrl } from './utils/parse-url.js'; @@ -44,7 +45,7 @@ export function generateSitemap(pages: string[], finalSiteUrl: string, opts: Sit links, lastmod, priority, - changefreq, + changefreq: changefreq as EnumChangefreq, }; }); diff --git a/packages/integrations/sitemap/src/index.ts b/packages/integrations/sitemap/src/index.ts index bab3d5af6f..4feee29587 100644 --- a/packages/integrations/sitemap/src/index.ts +++ b/packages/integrations/sitemap/src/index.ts @@ -12,7 +12,7 @@ import { generateSitemap } from './generate-sitemap.js'; import { Logger } from './utils/logger.js'; import { validateOptions } from './validate-options.js'; -export type ChangeFreq = EnumChangefreq; +export type ChangeFreq = `${EnumChangefreq}`; export type SitemapItem = Pick< SitemapItemLoose, 'url' | 'lastmod' | 'changefreq' | 'priority' | 'links'