Skip to content

Commit f9cd031

Browse files
authored
Add zod schema validation (withastro#1198)
* add zod schema validation * update pageUrlFormat config name * add trailing slash support to config
1 parent 010c71e commit f9cd031

File tree

32 files changed

+378
-361
lines changed

32 files changed

+378
-361
lines changed

.changeset/fifty-books-jam.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
Fix TypeScript "types" reference in package.json

.changeset/gentle-carrots-decide.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
Improve schema validation using zod
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
export default {
2-
// projectRoot: '.', // Where to resolve all URLs relative to. Useful if you have a monorepo project.
3-
// pages: './src/pages', // Path to Astro components, pages, and data
4-
// dist: './dist', // When running `astro build`, path to final static output
5-
// public: './public', // A folder of static files Astro will copy to the root. Useful for favicons, images, and other files that don’t need processing.
6-
buildOptions: {
7-
site: 'http://example.com', // Your public domain, e.g.: https://my-site.dev/. Used to generate sitemaps and canonical URLs.
8-
sitemap: true, // Generate sitemap (set to "false" to disable)
9-
},
10-
devOptions: {
11-
// port: 3000, // The port to run the dev server on.
12-
// tailwindConfig: '', // Path to tailwind.config.js if used, e.g. './tailwind.config.js'
13-
},
1+
// Full Astro Configuration API Documentation:
2+
// https://docs.astro.build/reference/configuration-reference
3+
4+
// @type-check enabled!
5+
// VSCode and other TypeScript-enabled text editors will provide auto-completion,
6+
// helpful tooltips, and warnings if your exported object is invalid.
7+
// You can disable this by removing "@ts-check" and `@type` comments below.
8+
9+
// @ts-check
10+
export default /** @type {import('astro').AstroUserConfig} */ ({
11+
// Enable the Preact renderer to support Preact JSX components.
1412
renderers: ['@astrojs/renderer-preact'],
15-
};
13+
});

examples/blog/astro.config.mjs

+12-14
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
export default {
2-
// projectRoot: '.', // Where to resolve all URLs relative to. Useful if you have a monorepo project.
3-
// pages: './src/pages', // Path to Astro components, pages, and data
4-
// dist: './dist', // When running `astro build`, path to final static output
5-
// public: './public', // A folder of static files Astro will copy to the root. Useful for favicons, images, and other files that don’t need processing.
6-
buildOptions: {
7-
// site: 'http://example.com', // Your public domain, e.g.: https://my-site.dev/. Used to generate sitemaps and canonical URLs.
8-
sitemap: true, // Generate sitemap (set to "false" to disable)
9-
},
10-
devOptions: {
11-
// port: 3000, // The port to run the dev server on.
12-
// tailwindConfig: '', // Path to tailwind.config.js if used, e.g. './tailwind.config.js'
13-
},
1+
// Full Astro Configuration API Documentation:
2+
// https://docs.astro.build/reference/configuration-reference
3+
4+
// @type-check enabled!
5+
// VSCode and other TypeScript-enabled text editors will provide auto-completion,
6+
// helpful tooltips, and warnings if your exported object is invalid.
7+
// You can disable this by removing "@ts-check" and `@type` comments below.
8+
9+
// @ts-check
10+
export default /** @type {import('astro').AstroUserConfig} */ ({
11+
// Enable the Preact renderer to support Preact JSX components.
1412
renderers: ['@astrojs/renderer-preact'],
15-
};
13+
});

examples/docs/astro.config.mjs

+12-14
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
export default {
2-
// projectRoot: '.', // Where to resolve all URLs relative to. Useful if you have a monorepo project.
3-
// pages: './src/pages', // Path to Astro components, pages, and data
4-
// dist: './dist', // When running `astro build`, path to final static output
5-
// public: './public', // A folder of static files Astro will copy to the root. Useful for favicons, images, and other files that don’t need processing.
6-
buildOptions: {
7-
// site: 'http://example.com', // Your public domain, e.g.: https://my-site.dev/. Used to generate sitemaps and canonical URLs.
8-
// sitemap: true, // Generate sitemap (set to "false" to disable)
9-
},
10-
devOptions: {
11-
// port: 3000, // The port to run the dev server on.
12-
// tailwindConfig: '', // Path to tailwind.config.js if used, e.g. './tailwind.config.js'
13-
},
1+
// Full Astro Configuration API Documentation:
2+
// https://docs.astro.build/reference/configuration-reference
3+
4+
// @type-check enabled!
5+
// VSCode and other TypeScript-enabled text editors will provide auto-completion,
6+
// helpful tooltips, and warnings if your exported object is invalid.
7+
// You can disable this by removing "@ts-check" and `@type` comments below.
8+
9+
// @ts-check
10+
export default /** @type {import('astro').AstroUserConfig} */ ({
11+
// Enable the Preact renderer to support Preact JSX components.
1412
renderers: ['@astrojs/renderer-preact'],
15-
};
13+
});
+12-14
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
export default {
2-
// projectRoot: '.', // Where to resolve all URLs relative to. Useful if you have a monorepo project.
3-
// pages: './src/pages', // Path to Astro components, pages, and data
4-
// dist: './dist', // When running `astro build`, path to final static output
5-
// public: './public', // A folder of static files Astro will copy to the root. Useful for favicons, images, and other files that don’t need processing.
6-
buildOptions: {
7-
// site: 'http://example.com', // Your public domain, e.g.: https://my-site.dev/. Used to generate sitemaps and canonical URLs.
8-
// sitemap: true, // Generate sitemap (set to "false" to disable)
9-
},
10-
devOptions: {
11-
// port: 3000, // The port to run the dev server on.
12-
// tailwindConfig: '', // Path to tailwind.config.js if used, e.g. './tailwind.config.js'
13-
},
1+
// Full Astro Configuration API Documentation:
2+
// https://docs.astro.build/reference/configuration-reference
3+
4+
// @type-check enabled!
5+
// VSCode and other TypeScript-enabled text editors will provide auto-completion,
6+
// helpful tooltips, and warnings if your exported object is invalid.
7+
// You can disable this by removing "@ts-check" and `@type` comments below.
8+
9+
// @ts-check
10+
export default /** @type {import('astro').AstroUserConfig} */ ({
11+
// Enable the lit renderer to support LitHTML components and templates.
1412
renderers: ['@astrojs/renderer-lit'],
15-
};
13+
});
+12-14
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
export default {
2-
// projectRoot: '.', // Where to resolve all URLs relative to. Useful if you have a monorepo project.
3-
// pages: './src/pages', // Path to Astro components, pages, and data
4-
// dist: './dist', // When running `astro build`, path to final static output
5-
// public: './public', // A folder of static files Astro will copy to the root. Useful for favicons, images, and other files that don’t need processing.
6-
buildOptions: {
7-
// site: 'http://example.com', // Your public domain, e.g.: https://my-site.dev/. Used to generate sitemaps and canonical URLs.
8-
// sitemap: true, // Generate sitemap (set to "false" to disable)
9-
},
10-
devOptions: {
11-
// port: 3000, // The port to run the dev server on.
12-
// tailwindConfig: '', // Path to tailwind.config.js if used, e.g. './tailwind.config.js'
13-
},
1+
// Full Astro Configuration API Documentation:
2+
// https://docs.astro.build/reference/configuration-reference
3+
4+
// @type-check enabled!
5+
// VSCode and other TypeScript-enabled text editors will provide auto-completion,
6+
// helpful tooltips, and warnings if your exported object is invalid.
7+
// You can disable this by removing "@ts-check" and `@type` comments below.
8+
9+
// @ts-check
10+
export default /** @type {import('astro').AstroUserConfig} */ ({
11+
// Enable many renderers to support all different kinds of components.
1412
renderers: ['@astrojs/renderer-preact', '@astrojs/renderer-react', '@astrojs/renderer-svelte', '@astrojs/renderer-vue', '@astrojs/renderer-solid'],
15-
};
13+
});
+12-14
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
export default {
2-
// projectRoot: '.', // Where to resolve all URLs relative to. Useful if you have a monorepo project.
3-
// pages: './src/pages', // Path to Astro components, pages, and data
4-
// dist: './dist', // When running `astro build`, path to final static output
5-
// public: './public', // A folder of static files Astro will copy to the root. Useful for favicons, images, and other files that don’t need processing.
6-
buildOptions: {
7-
// site: 'http://example.com', // Your public domain, e.g.: https://my-site.dev/. Used to generate sitemaps and canonical URLs.
8-
// sitemap: true, // Generate sitemap (set to "false" to disable)
9-
},
10-
devOptions: {
11-
// port: 3000, // The port to run the dev server on.
12-
// tailwindConfig: '', // Path to tailwind.config.js if used, e.g. './tailwind.config.js'
13-
},
1+
// Full Astro Configuration API Documentation:
2+
// https://docs.astro.build/reference/configuration-reference
3+
4+
// @type-check enabled!
5+
// VSCode and other TypeScript-enabled text editors will provide auto-completion,
6+
// helpful tooltips, and warnings if your exported object is invalid.
7+
// You can disable this by removing "@ts-check" and `@type` comments below.
8+
9+
// @ts-check
10+
export default /** @type {import('astro').AstroUserConfig} */ ({
11+
// Enable the Preact renderer to support Preact JSX components.
1412
renderers: ['@astrojs/renderer-preact'],
15-
};
13+
});
+12-14
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
export default {
2-
// projectRoot: '.', // Where to resolve all URLs relative to. Useful if you have a monorepo project.
3-
// pages: './src/pages', // Path to Astro components, pages, and data
4-
// dist: './dist', // When running `astro build`, path to final static output
5-
// public: './public', // A folder of static files Astro will copy to the root. Useful for favicons, images, and other files that don’t need processing.
6-
buildOptions: {
7-
// site: 'http://example.com', // Your public domain, e.g.: https://my-site.dev/. Used to generate sitemaps and canonical URLs.
8-
// sitemap: true, // Generate sitemap (set to "false" to disable)
9-
},
10-
devOptions: {
11-
// port: 3000, // The port to run the dev server on.
12-
// tailwindConfig: '', // Path to tailwind.config.js if used, e.g. './tailwind.config.js'
13-
},
1+
// Full Astro Configuration API Documentation:
2+
// https://docs.astro.build/reference/configuration-reference
3+
4+
// @type-check enabled!
5+
// VSCode and other TypeScript-enabled text editors will provide auto-completion,
6+
// helpful tooltips, and warnings if your exported object is invalid.
7+
// You can disable this by removing "@ts-check" and `@type` comments below.
8+
9+
// @ts-check
10+
export default /** @type {import('astro').AstroUserConfig} */ ({
11+
// Enable the React renderer to support React JSX components.
1412
renderers: ['@astrojs/renderer-react'],
15-
};
13+
});
+12-14
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
export default {
2-
// projectRoot: '.', // Where to resolve all URLs relative to. Useful if you have a monorepo project.
3-
// pages: './src/pages', // Path to Astro components, pages, and data
4-
// dist: './dist', // When running `astro build`, path to final static output
5-
// public: './public', // A folder of static files Astro will copy to the root. Useful for favicons, images, and other files that don’t need processing.
6-
buildOptions: {
7-
// site: 'http://example.com', // Your public domain, e.g.: https://my-site.dev/. Used to generate sitemaps and canonical URLs.
8-
// sitemap: true, // Generate sitemap (set to "false" to disable)
9-
},
10-
devOptions: {
11-
// port: 3000, // The port to run the dev server on.
12-
// tailwindConfig: '', // Path to tailwind.config.js if used, e.g. './tailwind.config.js'
13-
},
1+
// Full Astro Configuration API Documentation:
2+
// https://docs.astro.build/reference/configuration-reference
3+
4+
// @type-check enabled!
5+
// VSCode and other TypeScript-enabled text editors will provide auto-completion,
6+
// helpful tooltips, and warnings if your exported object is invalid.
7+
// You can disable this by removing "@ts-check" and `@type` comments below.
8+
9+
// @ts-check
10+
export default /** @type {import('astro').AstroUserConfig} */ ({
11+
// Enable the Solid renderer to support Solid JSX components.
1412
renderers: ['@astrojs/renderer-solid'],
15-
};
13+
});
+12-14
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
export default {
2-
// projectRoot: '.', // Where to resolve all URLs relative to. Useful if you have a monorepo project.
3-
// pages: './src/pages', // Path to Astro components, pages, and data
4-
// dist: './dist', // When running `astro build`, path to final static output
5-
// public: './public', // A folder of static files Astro will copy to the root. Useful for favicons, images, and other files that don’t need processing.
6-
buildOptions: {
7-
// site: 'http://example.com', // Your public domain, e.g.: https://my-site.dev/. Used to generate sitemaps and canonical URLs.
8-
// sitemap: true, // Generate sitemap (set to "false" to disable)
9-
},
10-
devOptions: {
11-
// port: 3000, // The port to run the dev server on.
12-
// tailwindConfig: '', // Path to tailwind.config.js if used, e.g. './tailwind.config.js'
13-
},
1+
// Full Astro Configuration API Documentation:
2+
// https://docs.astro.build/reference/configuration-reference
3+
4+
// @type-check enabled!
5+
// VSCode and other TypeScript-enabled text editors will provide auto-completion,
6+
// helpful tooltips, and warnings if your exported object is invalid.
7+
// You can disable this by removing "@ts-check" and `@type` comments below.
8+
9+
// @ts-check
10+
export default /** @type {import('astro').AstroUserConfig} */ ({
11+
// Enable the Svelte renderer to support Svelte components.
1412
renderers: ['@astrojs/renderer-svelte'],
15-
};
13+
});
+12-14
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
export default {
2-
// projectRoot: '.', // Where to resolve all URLs relative to. Useful if you have a monorepo project.
3-
// pages: './src/pages', // Path to Astro components, pages, and data
4-
// dist: './dist', // When running `astro build`, path to final static output
5-
// public: './public', // A folder of static files Astro will copy to the root. Useful for favicons, images, and other files that don’t need processing.
6-
buildOptions: {
7-
// site: 'http://example.com', // Your public domain, e.g.: https://my-site.dev/. Used to generate sitemaps and canonical URLs.
8-
// sitemap: true, // Generate sitemap (set to "false" to disable)
9-
},
10-
devOptions: {
11-
// port: 3000, // The port to run the dev server on.
12-
// tailwindConfig: '', // Path to tailwind.config.js if used, e.g. './tailwind.config.js'
13-
},
1+
// Full Astro Configuration API Documentation:
2+
// https://docs.astro.build/reference/configuration-reference
3+
4+
// @type-check enabled!
5+
// VSCode and other TypeScript-enabled text editors will provide auto-completion,
6+
// helpful tooltips, and warnings if your exported object is invalid.
7+
// You can disable this by removing "@ts-check" and `@type` comments below.
8+
9+
// @ts-check
10+
export default /** @type {import('astro').AstroUserConfig} */ ({
11+
// Enable the Vue renderer to support Vue components.
1412
renderers: ['@astrojs/renderer-vue'],
15-
};
13+
});

examples/minimal/astro.config.mjs

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1-
export default {
1+
// Full Astro Configuration API Documentation:
2+
// https://docs.astro.build/reference/configuration-reference
3+
4+
// @type-check enabled!
5+
// VSCode and other TypeScript-enabled text editors will provide auto-completion,
6+
// helpful tooltips, and warnings if your exported object is invalid.
7+
// You can disable this by removing "@ts-check" and `@type` comments below.
8+
9+
// @ts-check
10+
export default /** @type {import('astro').AstroUserConfig} */ ({
11+
// Set "renderers" to "[]" to disable all default, builtin component support.
212
renderers: [],
3-
};
13+
});

examples/portfolio/astro.config.mjs

+12-14
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
export default {
2-
// projectRoot: '.', // Where to resolve all URLs relative to. Useful if you have a monorepo project.
3-
// pages: './src/pages', // Path to Astro components, pages, and data
4-
// dist: './dist', // When running `astro build`, path to final static output
5-
// public: './public', // A folder of static files Astro will copy to the root. Useful for favicons, images, and other files that don’t need processing.
6-
buildOptions: {
7-
// site: 'http://example.com', // Your public domain, e.g.: https://my-site.dev/. Used to generate sitemaps and canonical URLs.
8-
// sitemap: true, // Generate sitemap (set to "false" to disable)
9-
},
10-
devOptions: {
11-
// port: 3000, // The port to run the dev server on.
12-
// tailwindConfig: '', // Path to tailwind.config.js if used, e.g. './tailwind.config.js'
13-
},
1+
// Full Astro Configuration API Documentation:
2+
// https://docs.astro.build/reference/configuration-reference
3+
4+
// @type-check enabled!
5+
// VSCode and other TypeScript-enabled text editors will provide auto-completion,
6+
// helpful tooltips, and warnings if your exported object is invalid.
7+
// You can disable this by removing "@ts-check" and `@type` comments below.
8+
9+
// @ts-check
10+
export default /** @type {import('astro').AstroUserConfig} */ ({
11+
// Enable the Preact renderer to support Preact JSX components.
1412
renderers: ['@astrojs/renderer-preact'],
15-
};
13+
});

examples/starter/astro.config.mjs

+12-14
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
export default {
2-
// projectRoot: '.', // Where to resolve all URLs relative to. Useful if you have a monorepo project.
3-
// pages: './src/pages', // Path to Astro components, pages, and data
4-
// dist: './dist', // When running `astro build`, path to final static output
5-
// public: './public', // A folder of static files Astro will copy to the root. Useful for favicons, images, and other files that don’t need processing.
6-
buildOptions: {
7-
// site: 'http://example.com', // Your public domain, e.g.: https://my-site.dev/. Used to generate sitemaps and canonical URLs.
8-
// sitemap: true, // Generate sitemap (set to "false" to disable)
9-
},
10-
devOptions: {
11-
// port: 3000, // The port to run the dev server on.
12-
// tailwindConfig: '', // Path to tailwind.config.js if used, e.g. './tailwind.config.js'
13-
},
14-
};
1+
// Full Astro Configuration API Documentation:
2+
// https://docs.astro.build/reference/configuration-reference
3+
4+
// @type-check enabled!
5+
// VSCode and other TypeScript-enabled text editors will provide auto-completion,
6+
// helpful tooltips, and warnings if your exported object is invalid.
7+
// You can disable this by removing "@ts-check" and `@type` comments below.
8+
9+
// @ts-check
10+
export default /** @type {import('astro').AstroUserConfig} */ ({
11+
// ...
12+
});
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1-
export default {
2-
// projectRoot: '.', // Where to resolve all URLs relative to. Useful if you have a monorepo project.
3-
// pages: './src/pages', // Path to Astro components, pages, and data
4-
// dist: './dist', // When running `astro build`, path to final static output
5-
// public: './public', // A folder of static files Astro will copy to the root. Useful for favicons, images, and other files that don’t need processing.
6-
buildOptions: {
7-
site: 'http://example.com', // Your public domain, e.g.: https://my-site.dev/. Used to generate sitemaps and canonical URLs.
8-
// sitemap: true, // Generate sitemap (set to "false" to disable)
9-
},
1+
// Full Astro Configuration API Documentation:
2+
// https://docs.astro.build/reference/configuration-reference
3+
4+
// @type-check enabled!
5+
// VSCode and other TypeScript-enabled text editors will provide auto-completion,
6+
// helpful tooltips, and warnings if your exported object is invalid.
7+
// You can disable this by removing "@ts-check" and `@type` comments below.
8+
9+
// @ts-check
10+
export default /** @type {import('astro').AstroUserConfig} */ ({
11+
// Enable Custom Markdown options, plugins, etc.
1012
markdownOptions: {
1113
remarkPlugins: ['remark-code-titles', 'remark-slug', ['remark-autolink-headings', { behavior: 'prepend' }]],
1214
rehypePlugins: [
1315
['rehype-toc', { headings: ['h2', 'h3'] }],
1416
['rehype-add-classes', { 'h1,h2,h3': 'title' }],
1517
],
1618
},
17-
devOptions: {
18-
// port: 3000, // The port to run the dev server on.
19-
// tailwindConfig: '', // Path to tailwind.config.js if used, e.g. './tailwind.config.js'
20-
},
21-
};
19+
});

0 commit comments

Comments
 (0)