Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update ChangeFreq to support typescript configurations with string literal #6262

Merged
merged 5 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/shiny-years-beg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/sitemap': minor
---

update `ChangeFreq` to support typescript configurations with string literal or predefined value.
4 changes: 2 additions & 2 deletions packages/integrations/sitemap/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 const ChangeFreq = { ...EnumChangefreq } as const;
export type SitemapItem = Pick<
SitemapItemLoose,
'url' | 'lastmod' | 'changefreq' | 'priority' | 'links'
Expand All @@ -32,7 +32,7 @@ export type SitemapOptions =
entryLimit?: number;

// sitemap specific
changefreq?: ChangeFreq;
changefreq?: EnumChangefreq;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be technically be replaced with

Suggested change
changefreq?: EnumChangefreq;
changefreq?: typeof ChangeFreq[keyof typeof ChangeFreq];

if we don't want to reuse EnumChangefreq but EnumChangefreq is way cleaner and readable

lastmod?: Date;
priority?: number;

Expand Down