From 332417023038b64a5c32db8f966754bf48109d8e Mon Sep 17 00:00:00 2001 From: Robert Reinhard Date: Tue, 31 May 2022 16:00:52 -0700 Subject: [PATCH] Automatically injecting helpers #3 --- nuxt.js | 3 +++ plugins/helpers.js | 11 +++++++++++ 2 files changed, 14 insertions(+) create mode 100644 plugins/helpers.js diff --git a/nuxt.js b/nuxt.js index 186cd55..adc5404 100644 --- a/nuxt.js +++ b/nuxt.js @@ -48,6 +48,9 @@ export default function() { requireOnce(this, join(__dirname, './modules/ssg-variants.js')) } + // Add helpers + this.options.plugins.unshift(join(__dirname, 'plugins/helpers.js')) + } // Required for published modules diff --git a/plugins/helpers.js b/plugins/helpers.js new file mode 100644 index 0000000..9ee602c --- /dev/null +++ b/plugins/helpers.js @@ -0,0 +1,11 @@ +/** + * Inject helpers + */ +import * as helpers from '../helpers' +export default function ({ }, inject) { + + // Not binding to context because it makes Vuei18n methods inaccessible + for (const [name, helper] of Object.entries(helpers)) { + inject(name, helper) + } +}