Skip to content

Commit

Permalink
Automatically injecting helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
weotch committed May 31, 2022
1 parent f0ec0aa commit 3324170
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions nuxt.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions plugins/helpers.js
Original file line number Diff line number Diff line change
@@ -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)
}
}

0 comments on commit 3324170

Please sign in to comment.