-
Notifications
You must be signed in to change notification settings - Fork 15
/
enhanceApp.js
49 lines (43 loc) · 1.16 KB
/
enhanceApp.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import Vuex from "vuex";
import CodeToggle from "./components/CodeToggle";
import { setStorage } from "./Storage";
export default ({ Vue, options, router, siteData }) => {
const base = siteData.base;
Vue.component("code-toggle", CodeToggle);
Vue.use(Vuex);
Vue.mixin({
computed: {
$title() {
const page = this.$page;
const siteTitle = this.$siteTitle;
const selfTitle = page.frontmatter.home
? null
: page.frontmatter.title || // explicit title
(page.title ? page.title.replace(/[_`]/g, "") : ""); // inferred title
return siteTitle
? selfTitle
? selfTitle + " | " + siteTitle
: siteTitle
: selfTitle || "VuePress";
},
},
});
Object.assign(options, {
data: {
codeLanguage: null,
smallerSidebarHeadings: false,
widerSidebar: false,
},
store: new Vuex.Store({
state: {
codeLanguage: null,
},
mutations: {
changeCodeLanguage(state, language) {
state.codeLanguage = language;
setStorage("codeLanguage", language, base);
},
},
}),
});
};