initial commit
This commit is contained in:
parent
358d1dc92f
commit
76653d991f
5 changed files with 23 additions and 0 deletions
|
@ -7,4 +7,7 @@ import sitemap from '@astrojs/sitemap';
|
|||
export default defineConfig({
|
||||
site: 'https://example.com',
|
||||
integrations: [mdx(), sitemap()],
|
||||
experimental: {
|
||||
router: 'spa'
|
||||
}
|
||||
});
|
||||
|
|
|
@ -146,6 +146,7 @@
|
|||
"js-yaml": "^4.1.0",
|
||||
"kleur": "^4.1.4",
|
||||
"magic-string": "^0.27.0",
|
||||
"micromorph": "^0.4.4",
|
||||
"mime": "^3.0.0",
|
||||
"ora": "^6.1.0",
|
||||
"path-to-regexp": "^6.2.1",
|
||||
|
|
|
@ -43,6 +43,7 @@ const ASTRO_CONFIG_DEFAULTS: AstroUserConfig & any = {
|
|||
customClientDirectives: false,
|
||||
inlineStylesheets: 'never',
|
||||
middleware: false,
|
||||
router: 'mpa'
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -209,6 +210,10 @@ export const AstroConfigSchema = z.object({
|
|||
.default(ASTRO_CONFIG_DEFAULTS.experimental.inlineStylesheets),
|
||||
middleware: z.oboolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.middleware),
|
||||
hybridOutput: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.experimental.hybridOutput),
|
||||
router: z
|
||||
.enum(['mpa', 'spa'])
|
||||
.optional()
|
||||
.default(ASTRO_CONFIG_DEFAULTS.experimental.router),
|
||||
})
|
||||
.passthrough()
|
||||
.refine(
|
||||
|
|
|
@ -59,6 +59,10 @@ export async function runHookConfigSetup({
|
|||
let updatedConfig: AstroConfig = { ...settings.config };
|
||||
let updatedSettings: AstroSettings = { ...settings, config: updatedConfig };
|
||||
let addedClientDirectives = new Map<string, Promise<string>>();
|
||||
|
||||
if (settings.config.experimental.router === 'spa') {
|
||||
updatedSettings.scripts.push({ stage: 'page', content: 'import "astro/client/router.js"' });
|
||||
}
|
||||
|
||||
for (const integration of settings.config.integrations) {
|
||||
/**
|
||||
|
|
10
packages/astro/src/runtime/client/router.ts
Normal file
10
packages/astro/src/runtime/client/router.ts
Normal file
|
@ -0,0 +1,10 @@
|
|||
import listen from 'micromorph/spa';
|
||||
|
||||
listen({
|
||||
beforeDiff(doc) {
|
||||
console.log('before diff')
|
||||
},
|
||||
afterDiff() {
|
||||
console.log('after diff')
|
||||
}
|
||||
})
|
Loading…
Reference in a new issue