From 3290f5818270dc6b9ab928fc21204f2d5be8b4fd Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Sun, 1 Dec 2024 10:34:28 -0800 Subject: [PATCH] Refactor developer config and remove viewTransitionAPI The viewTransitionAPI property in the developer config schema has been removed as it is no longer needed. This change simplifies the configuration and reduces unnecessary code. Removed unused middleware files The middleware.ts and middleware2.ts files have been deleted as they are no longer used in the application. This cleanup improves the codebase by removing unnecessary files. Update Layout component The import statement for the Config module has been commented out in the Layout component. This change is made to remove an unused dependency and improve the performance of the component. Update integration setup The addMiddleware function call has been commented out in the integration setup. This change is made to remove an unused middleware and simplify the integration setup. --- .../src/schemas/config/developer.ts | 8 -------- .../src/components/Layout.astro | 14 ------------- .../studiocms_dashboard/src/integration.ts | 7 +------ .../studiocms_dashboard/src/middleware.ts | 20 ------------------- .../studiocms_dashboard/src/middleware2.ts | 18 ----------------- 5 files changed, 1 insertion(+), 66 deletions(-) delete mode 100644 packages/studiocms_dashboard/src/middleware.ts delete mode 100644 packages/studiocms_dashboard/src/middleware2.ts diff --git a/packages/studiocms_core/src/schemas/config/developer.ts b/packages/studiocms_core/src/schemas/config/developer.ts index 8e67408126..37169101b6 100644 --- a/packages/studiocms_core/src/schemas/config/developer.ts +++ b/packages/studiocms_core/src/schemas/config/developer.ts @@ -2,14 +2,6 @@ import { z } from 'astro/zod'; export const developerConfigSchema = z .object({ - /** - * Zero-JavaScript View Transitions - * - * Chrome 126 (released last week) and Microsoft Edge 126 (releasing this week) both support “cross-document view transitions” unlocking zero-JavaScript view transitions in Astro. - * - * @see https://astro.build/blog/future-of-astro-zero-js-view-transitions/ - */ - viewTransitionAPI: z.boolean().optional().default(false), /** * Enable Testing and Demo Mode * diff --git a/packages/studiocms_dashboard/src/components/Layout.astro b/packages/studiocms_dashboard/src/components/Layout.astro index eee0425e77..083cee8c2f 100644 --- a/packages/studiocms_dashboard/src/components/Layout.astro +++ b/packages/studiocms_dashboard/src/components/Layout.astro @@ -1,6 +1,5 @@ --- import { ViewTransitions } from 'astro:transitions'; -// import Config from 'virtual:studiocms/config'; import { Button } from '@studiocms/ui/components'; import Icon from '@studiocms/ui/utils/Icon.astro'; import { BaseHead } from '../components'; @@ -10,12 +9,6 @@ import '@studiocms/ui/css/global.css'; import '@fontsource-variable/onest/index.css'; import '../styles/layout.css'; -// const { -// dashboardConfig: { -// developerConfig: { viewTransitionAPI }, -// }, -// } = Config; - type Props = { title: string; description: string; @@ -31,13 +24,6 @@ const { title, description } = Astro.props; - diff --git a/packages/studiocms_dashboard/src/integration.ts b/packages/studiocms_dashboard/src/integration.ts index 9187e68896..7ff489301f 100644 --- a/packages/studiocms_dashboard/src/integration.ts +++ b/packages/studiocms_dashboard/src/integration.ts @@ -23,7 +23,7 @@ export default defineIntegration({ hooks: { 'astro:config:setup': async (params) => { // Destructure Params - const { logger, injectRoute, addMiddleware } = params; + const { logger, injectRoute } = params; // Destructure Options const { verbose } = options; @@ -122,11 +122,6 @@ export default defineIntegration({ ], }); - // addMiddleware({ - // order: "pre", - // entrypoint: resolve('./middleware.ts'), - // }); - // // OLD ROUTES - TO BE REMOVED // injectRouteArray(params, { // options, diff --git a/packages/studiocms_dashboard/src/middleware.ts b/packages/studiocms_dashboard/src/middleware.ts deleted file mode 100644 index 5c521966fb..0000000000 --- a/packages/studiocms_dashboard/src/middleware.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { defineMiddleware } from "astro/middleware"; - -export const onRequest = defineMiddleware(async (ctx, next) => { - if (ctx.request.method === 'POST' && ctx.url.pathname.startsWith('/_server-islands')) { - const request = ctx.request.clone(); - request.headers.set('Cache-Control', 'max-age=86400'); - - const newReq = new Request(request, { - method: request.method, - }); - - const response = await next(newReq); - - response.headers.set('Cache-Control', 'max-age=86400'); - - return response; - } - - return next(); -}); diff --git a/packages/studiocms_dashboard/src/middleware2.ts b/packages/studiocms_dashboard/src/middleware2.ts deleted file mode 100644 index 8d95e0e9ab..0000000000 --- a/packages/studiocms_dashboard/src/middleware2.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { defineMiddleware } from "astro/middleware"; - -export const onRequest = defineMiddleware((ctx, next) => { - if (ctx.request.method === 'POST' && ctx.url.pathname.startsWith('/_server-islands')) { - const request = ctx.request.clone(); - request.headers.set('Cache-Control', 'max-age=86400'); - - const newReq = new Request(request, { - method: request.method, - }); - - console.log(newReq.url, newReq.headers); - - return next(newReq); - } - - return next(); -});