From f650f18ed66fffe467d09626235e40ba3fad1f99 Mon Sep 17 00:00:00 2001 From: Matt Kane Date: Thu, 29 Aug 2024 12:22:59 +0100 Subject: [PATCH] Remove integration-specific code --- packages/astro/src/@types/astro.ts | 1 - packages/astro/src/content/loaders/types.ts | 2 -- packages/astro/src/integrations/hooks.ts | 10 ------ .../fixtures/content-layer/astro.config.mjs | 33 +------------------ 4 files changed, 1 insertion(+), 45 deletions(-) diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index 9661eeb47385d..87ddb65e26990 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -3290,7 +3290,6 @@ declare global { server: vite.ViteDevServer; logger: AstroIntegrationLogger; toolbar: ReturnType; - refreshContent?: (options: RefreshContentOptions) => Promise; }) => void | Promise; 'astro:server:start': (options: { address: AddressInfo; diff --git a/packages/astro/src/content/loaders/types.ts b/packages/astro/src/content/loaders/types.ts index 4224ec4b6e940..67e7e13f08257 100644 --- a/packages/astro/src/content/loaders/types.ts +++ b/packages/astro/src/content/loaders/types.ts @@ -31,8 +31,6 @@ export interface LoaderContext { /** When running in dev, this is a filesystem watcher that can be used to trigger updates */ watcher?: FSWatcher; - /** If the loader has been triggered by an integration, this may optionally contain extra data set by that integration */ - refreshContextData?: Record; entryTypes: Map; } diff --git a/packages/astro/src/integrations/hooks.ts b/packages/astro/src/integrations/hooks.ts index 10b56153d705a..18d8d3811636c 100644 --- a/packages/astro/src/integrations/hooks.ts +++ b/packages/astro/src/integrations/hooks.ts @@ -12,11 +12,9 @@ import type { ContentEntryType, DataEntryType, HookParameters, - RefreshContentOptions, RouteData, RouteOptions, } from '../@types/astro.js'; -import { globalContentLayer } from '../content/content-layer.js'; import astroIntegrationActionsRouteHandler from '../actions/integration.js'; import { isActionsFilePresent } from '../actions/utils.js'; import type { SerializedSSRManifest } from '../core/app/types.js'; @@ -375,13 +373,6 @@ export async function runHookServerSetup({ server: ViteDevServer; logger: Logger; }) { - let refreshContent: undefined | ((options: RefreshContentOptions) => Promise); - if (config.experimental?.contentLayer) { - refreshContent = async (options: RefreshContentOptions) => { - const contentLayer = await globalContentLayer.get(); - await contentLayer?.sync(options); - }; - } for (const integration of config.integrations) { if (integration?.hooks?.['astro:server:setup']) { @@ -392,7 +383,6 @@ export async function runHookServerSetup({ server, logger: getLogger(integration, logger), toolbar: getToolbarServerCommunicationHelpers(server), - refreshContent, }), logger, }); diff --git a/packages/astro/test/fixtures/content-layer/astro.config.mjs b/packages/astro/test/fixtures/content-layer/astro.config.mjs index 3548ef7e290a5..3266e5e8c0adf 100644 --- a/packages/astro/test/fixtures/content-layer/astro.config.mjs +++ b/packages/astro/test/fixtures/content-layer/astro.config.mjs @@ -3,38 +3,7 @@ import { defineConfig } from 'astro/config'; import { fileURLToPath } from 'node:url'; export default defineConfig({ - integrations: [mdx(), { - name: '@astrojs/my-integration', - hooks: { - 'astro:server:setup': async ({ server, refreshContent }) => { - server.middlewares.use('/_refresh', async (req, res) => { - if(req.method !== 'POST') { - res.statusCode = 405 - res.end('Method Not Allowed'); - return - } - let body = ''; - req.on('data', chunk => { - body += chunk.toString(); - }); - req.on('end', async () => { - try { - const webhookBody = JSON.parse(body); - await refreshContent({ - context: { webhookBody }, - loaders: ['increment-loader'] - }); - res.writeHead(200, { 'Content-Type': 'application/json' }); - res.end(JSON.stringify({ message: 'Content refreshed successfully' })); - } catch (error) { - res.writeHead(500, { 'Content-Type': 'application/json' }); - res.end(JSON.stringify({ error: 'Failed to refresh content' })); - } - }); - }); - } - } -}], + integrations: [mdx()], vite: { resolve: { alias: {