AIK Plugin
Getting Started
Add the plugin to your withPlugins
call:
import { defineIntegration, withPlugins } from 'astro-integration-kit';import aikMod from '@inox-tools/aik-mod';
export default defineIntegration({ name: 'my-integration', setup: ({ name }) => { return withPlugins({ name, plugins: [aikMod], hooks: { 'astro:config:setup': ({ defineMiddleware }) => { defineMiddleware('pre', (context, next) => { // Your inline middleware return next(); }); }, }, }); },});
API
The plugin exposes multiple entrypoints, all of them accept normal values and factory wrappers as values to be included in the virtual modules.
inlineModule
inlineModule
allows you to define a module inline, returning the name of the defined module.
It receives the definition of the virtual module.
import { defineIntegration, withPlugins } from 'astro-integration-kit';import aikMod from '@inox-tools/aik-mod';
export default defineIntegration({ name: 'my-integration', setup: ({ name }) => { return withPlugins({ name, plugins: [aikMod], hooks: { 'astro:config:setup': ({ inlineModule }) => { const moduleName = inlineModule({ defaultExport: 'some value', constExports: {}, assignExports: {}, }); }, }, }); },});
defineModule
defineModule
allows you to define a module inline with a given import name.
It receives the definition of the virtual module.
import { defineIntegration, withPlugins } from 'astro-integration-kit';import aikMod from '@inox-tools/aik-mod';
export default defineIntegration({ name: 'my-integration', setup: ({ name }) => { return withPlugins({ name, plugins: [aikMod], hooks: { 'astro:config:setup': ({ defineModule }) => { defineModule('virtual:my-integration/module', { defaultExport: 'some value', constExports: {}, assignExports: {}, }); }, }, }); },});
defineMiddleware
defineMiddleware
allows you to define an Astro middleware inline.
import { defineIntegration, withPlugins } from 'astro-integration-kit';import aikMod from '@inox-tools/aik-mod';
export default defineIntegration({ name: 'my-integration', setup: ({ name }) => { return withPlugins({ name, plugins: [aikMod], hooks: { 'astro:config:setup': ({ defineMiddleware }) => { defineMiddleware('pre', (context, next) => { // This runs in the Astro middleware return next(); }); }, }, }); },});