diff --git a/.changeset/gentle-kids-worry.md b/.changeset/gentle-kids-worry.md deleted file mode 100644 index 48da2c75..00000000 --- a/.changeset/gentle-kids-worry.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@inox-tools/custom-routing': patch ---- - -Refactor internally to use new Inox Tools template diff --git a/packages/custom-routing/CHANGELOG.md b/packages/custom-routing/CHANGELOG.md index d73b8ecd..4603157c 100644 --- a/packages/custom-routing/CHANGELOG.md +++ b/packages/custom-routing/CHANGELOG.md @@ -1,5 +1,11 @@ # @inox-tools/inline-mod +## 1.0.2 + +### Patch Changes + +- f2e76e2: Refactor internally to use new Inox Tools template + ## 1.0.1 ### Patch Changes diff --git a/packages/custom-routing/package.json b/packages/custom-routing/package.json index babd03e3..6a48d9e8 100644 --- a/packages/custom-routing/package.json +++ b/packages/custom-routing/package.json @@ -1,6 +1,6 @@ { "name": "@inox-tools/custom-routing", - "version": "1.0.1", + "version": "1.0.2", "description": "Define custom routing instead of Astro's default file-based routing.", "keywords": [ "astro-integration", diff --git a/packages/custom-routing/src/index.ts b/packages/custom-routing/src/index.ts index 6f0f36c7..9e922913 100644 --- a/packages/custom-routing/src/index.ts +++ b/packages/custom-routing/src/index.ts @@ -7,50 +7,50 @@ import { resolve, sep as PATH_SEP } from 'node:path'; type CustomRoute = string; // | APIRoute; type Options = { - strict: boolean; - routes: Record; + strict: boolean; + routes: Record; }; function customRoutingInner({ strict, routes }: Options): AstroIntegration { - return { - name: '@inox-tools/custom-routing', - hooks: { - 'astro:config:setup': ({ injectRoute }) => { - for (const [route, handle] of Object.entries(routes)) { - injectRoute({ - entrypoint: handle, - pattern: route, - }); - } - }, - ...(strict && { - 'astro:build:setup': ({ vite, pages }) => { - const pagesFolder = resolve(vite.root ?? '', './src/pages') + PATH_SEP; - for (const page of pages.values()) { - const componentPath = resolve(vite.root ?? '', page.component); - if (componentPath.startsWith(pagesFolder)) { - throw new AstroError( - 'Custom routing used alongside pages route.', - 'Either use disable strict mode of custom routing or remove any file-based routes.' - ); - } - } - }, - }), - }, - }; + return { + name: '@inox-tools/custom-routing', + hooks: { + 'astro:config:setup': ({ injectRoute }) => { + for (const [route, handle] of Object.entries(routes)) { + injectRoute({ + entrypoint: handle, + pattern: route, + }); + } + }, + ...(strict && { + 'astro:build:setup': ({ vite, pages }) => { + const pagesFolder = resolve(vite.root ?? '', './src/pages') + PATH_SEP; + for (const page of pages.values()) { + const componentPath = resolve(vite.root ?? '', page.component); + if (componentPath.startsWith(pagesFolder)) { + throw new AstroError( + 'Custom routing used alongside pages route.', + 'Either use disable strict mode of custom routing or remove any file-based routes.' + ); + } + } + }, + }), + }, + }; } export function customRouting(routes: Options['routes']): AstroIntegration { - return customRoutingInner({ - strict: false, - routes: routes, - }); + return customRoutingInner({ + strict: false, + routes: routes, + }); } export function strictCustomRouting(routes: Options['routes']): AstroIntegration { - return customRoutingInner({ - strict: true, - routes: routes, - }); + return customRoutingInner({ + strict: true, + routes: routes, + }); }