diff --git a/.changeset/green-llamas-turn.md b/.changeset/green-llamas-turn.md new file mode 100644 index 0000000..1b38f58 --- /dev/null +++ b/.changeset/green-llamas-turn.md @@ -0,0 +1,5 @@ +--- +'starlight-blog': patch +--- + +Adds support for passing [`Infinity`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Infinity) to the [`postCount`](https://starlight-blog-docs.vercel.app/configuration#postcount) and [`recentPostCount`](https://starlight-blog-docs.vercel.app/configuration#recentpostcount) configuration options. diff --git a/packages/starlight-blog/libs/config.ts b/packages/starlight-blog/libs/config.ts index a8877ea..ab3c53d 100644 --- a/packages/starlight-blog/libs/config.ts +++ b/packages/starlight-blog/libs/config.ts @@ -35,11 +35,11 @@ const configSchema = z /** * The number of blog posts to display per page in the blog post list. */ - postCount: z.number().min(1).default(5), + postCount: z.number().min(1).default(5).transform(infinityToMax), /** * The number of recent blog posts to display in the sidebar. */ - recentPostCount: z.number().min(1).default(10), + recentPostCount: z.number().min(1).default(10).transform(infinityToMax), /** * The title of the blog. * @@ -71,5 +71,9 @@ ${Object.entries(errors.fieldErrors) return config.data } +function infinityToMax(value: number): number { + return value === Infinity ? Number.MAX_SAFE_INTEGER : value +} + export type StarlightBlogUserConfig = z.input export type StarlightBlogConfig = z.output