Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 28 additions & 14 deletions packages/@vuepress/theme-default/layouts/404.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,40 @@

<blockquote>{{ getMsg() }}</blockquote>

<RouterLink to="/">
Take me home.
</RouterLink>
<RouterLink to="/"> Take me home. </RouterLink>
</div>
</div>
</template>

<script>
const msgs = [
`There's nothing here.`,
`How did we get here?`,
`That's a Four-Oh-Four.`,
`Looks like we've got some broken links.`
]
const msgs = {
en: [
`There's nothing here.`,
`How did we get here?`,
`That's a Four-Oh-Four.`,
`Looks like we've got some broken links.`,
],
zh: [
`这里什么都没有。`,
`我们是如何来到这里的?`,
`那是一个4-0-4。`,
`看起来我们有一些破碎的链接。`,
],
};

export default {
methods: {
getMsg () {
return msgs[Math.floor(Math.random() * msgs.length)]
}
}
}
getMsg() {
const localMsgs = this.localizeMsgs();
return localMsgs[Math.floor(Math.random() * localMsgs.length)];
},
localizeMsgs() {
const routesFirstPath = this.$route.path.match("\/.+?\/");
if (routesFirstPath != null && routesFirstPath[0] === "/zh/") {
return msgs.zh;
}
return msgs.en;
},
},
};
</script>