File tree Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -2,4 +2,19 @@ module.exports = (options = {}) => ({
22 async extendPageData ( $page ) {
33 $page . global = options . variables || { }
44 } ,
5+ enhanceAppFiles ( ) {
6+ return [
7+ {
8+ name : 'global-variable' ,
9+ content : `
10+ export default ({ Vue }) => { Vue.mixin({
11+ computed: {
12+ $var() {
13+ return this.$page.global
14+ }
15+ }
16+ }) }` . trim ( ) ,
17+ } ,
18+ ]
19+ } ,
520} )
Original file line number Diff line number Diff line change 11{
22 "name" : " vuepress-plugin-global-variables" ,
3- "version" : " 0.1.1 " ,
3+ "version" : " 0.2.0 " ,
44 "main" : " index.js" ,
55 "author" : " Artur Mędrygał" ,
66 "license" : " MIT" ,
Original file line number Diff line number Diff line change @@ -25,11 +25,15 @@ module.exports = {
2525}
2626```
2727
28- Now, you can simply use ` this.$page.global[key] ` to get your variable in any template or component.
28+ Now, you can simply use ` $var[key] ` or ` this.$page.global[key] ` to get your variable in any template or component.
2929
3030Example:
3131
3232``` vue
33+ {{ $var.example }}
34+
35+ // or
36+
3337{{ $page.global.example }}
3438```
3539
You can’t perform that action at this time.
0 commit comments