UNPKG

nuxt

Version:

Nuxt is a free and open-source framework with an intuitive and extendable way to create type-safe, performant and production-grade full-stack web applications and websites with Vue.js.

26 lines (25 loc) 731 B
import { klona } from "klona"; import _inlineAppConfig from "#internal/nuxt/app-config"; const _sharedAppConfig = _deepFreeze(klona(_inlineAppConfig)); export function useAppConfig(event) { if (!event) { return _sharedAppConfig; } event.context.nuxt ||= {}; if (event.context.nuxt.appConfig) { return event.context.nuxt.appConfig; } const appConfig = klona(_inlineAppConfig); event.context.nuxt.appConfig = appConfig; return appConfig; } function _deepFreeze(object) { const propNames = Object.getOwnPropertyNames(object); for (const name of propNames) { const value = object[name]; if (value && typeof value === "object") { _deepFreeze(value); } } return Object.freeze(object); }