nuxt-hpcaptcha
Version:
Nuxt 3 HPCaptcha component library is a plain utility whereby you can have an advanced yet hassle-free captcha in an instant
37 lines (34 loc) • 1.11 kB
JavaScript
import { defineNuxtModule, createResolver, addComponentsDir, installModule, addPlugin } from '@nuxt/kit';
const module = defineNuxtModule({
meta: {
name: "nuxt3-hpcaptcha",
configKey: "nuxtHPCaptcha"
},
// Default configuration options of the Nuxt module
defaults: {},
async setup(_options, _nuxt) {
const resolver = createResolver(import.meta.url);
addComponentsDir({
path: resolver.resolve("./runtime/components"),
// path of components
pathPrefix: false,
// Prefix component name by its path.
prefix: "",
// Prefix all matched components.
global: true
// Registers components to be globally available.
});
_nuxt.hook("nitro:config", async (nitroConfig) => {
nitroConfig.publicAssets ||= [];
nitroConfig.publicAssets.push({
dir: resolver.resolve("./runtime/assets"),
//path of assets
maxAge: 60 * 60 * 24 * 365
//cache assets for 1 year
});
});
await installModule("nuxt-icon");
addPlugin(resolver.resolve("./runtime/plugin"));
}
});
export { module as default };