-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
120 additions
and
37 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<template> | ||
<component :is="layout" :slot-key="slotKey || 'default'"/> | ||
</template> | ||
|
||
<script> | ||
import Vue from 'vue' | ||
import components from '@internal/page-components' | ||
import ContentLoading from './ContentLoading' | ||
export default { | ||
components: { ContentLoading }, | ||
props: { | ||
pageKey: String, | ||
slotKey: String | ||
}, | ||
data () { | ||
return { | ||
layout: 'ContentLoading' | ||
} | ||
}, | ||
computed: { | ||
$key () { | ||
return this.pageKey || this.$page.key | ||
} | ||
}, | ||
created () { | ||
this.loadContent(this.$key) | ||
}, | ||
watch: { | ||
$key (key) { | ||
this.loadContent(key) | ||
} | ||
}, | ||
methods: { | ||
loadContent (pageKey) { | ||
if (Vue.component(pageKey)) { | ||
return | ||
} | ||
this.layout = 'ContentLoading' | ||
if (components[pageKey]) { | ||
if (!this.$ssrContext) { | ||
Promise.all([ | ||
components[pageKey](), | ||
new Promise(resolve => setTimeout(resolve, 0)) | ||
]).then(([comp]) => { | ||
this.$vuepress.$emit('AsyncMarkdownAssetLoaded', this.pageKey) | ||
Vue.component(pageKey, comp.default) | ||
this.layout = pageKey | ||
}) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
</script> |
47 changes: 47 additions & 0 deletions
47
packages/@vuepress/core/lib/app/components/ContentLoading.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<template> | ||
<div class="content content-loading"> | ||
<ContentLoader | ||
:height="120" | ||
:width="300" | ||
:speed="0.5" | ||
primaryColor="#f3f3f3" | ||
secondaryColor="#ecebeb" | ||
> | ||
<rect x="0" y="5" rx="5" ry="5" width="117" height="10"/> | ||
<rect x="0" y="25" rx="5" ry="5" width="85" height="10"/> | ||
<rect x="0" y="60" rx="5" ry="5" width="250" height="10"/> | ||
<rect x="0" y="80" rx="5" ry="5" width="280" height="10"/> | ||
<rect x="0" y="100" rx="5" ry="5" width="201" height="10"/> | ||
</ContentLoader> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { ContentLoader } from 'vue-content-loader' | ||
export default { | ||
components: { | ||
ContentLoader | ||
}, | ||
data () { | ||
return { | ||
containerStyle: {} | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style> | ||
@media screen and (min-width: 719px) { | ||
.content.content-loading > svg { | ||
max-width: 400px !important; | ||
} | ||
} | ||
@media screen and (max-width: 719px) { | ||
.content.content-loading > svg { | ||
max-width: 320px !important; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters