Skip to content

Commit

Permalink
chore: reduce UX issues (lazy loading and jump)
Browse files Browse the repository at this point in the history
  • Loading branch information
atinux committed Jul 8, 2021
1 parent 215f4a9 commit 58adb6c
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 33 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,8 @@
},
"peerDependencies": {
"vuex": "^3.6.2"
},
"resolutions": {
"@nuxt/components": "npm:@pi0/components"
}
}
29 changes: 17 additions & 12 deletions src/app/pages/_.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,23 @@ export default defineComponent({
page.template = $docus.getPageTemplate(page)
// Preload the component on client-side navigation
const component = await Vue.component(page.template)()
let component = Vue.component(page.template)
if (typeof component === 'function' && !component.options) {
component = await component()
if (!component.options) {
component = Vue.extend(component)
}
}
// Set layout defaults for this template
if (component.templateOptions) templateOptions = { ...templateOptions, ...component.templateOptions }
if (component.options.templateOptions) {
templateOptions = { ...templateOptions, ...component.options.templateOptions }
}
// Set layout from page
if (page.layout) templateOptions = { ...templateOptions, ...page.layout }
// Set template options
$docus.layout.value = templateOptions
// Set Docus runtime current page
$docus.currentPage.value = page
if (page.layout) {
templateOptions = { ...templateOptions, ...page.layout }
}
// Redirect to another page if `navigation.redirect` is declared
if (page.navigation && page.navigation.redirect) redirect(localePath(page.navigation.redirect))
Expand Down Expand Up @@ -106,15 +110,16 @@ export default defineComponent({
]
}
},
created() {
// Set template options
this.$docus.layout.value = this.templateOptions
},
// Set Docus runtime current page
this.$docus.currentPage.value = this.page
},
mounted() {
if (this.page?.version) localStorage.setItem(`page-${this.page.slug}-version`, this.page.version)
},
methods: {
mergeMeta(to, from) {
from.forEach(newMeta => {
Expand Down
22 changes: 11 additions & 11 deletions src/defaultTheme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ const themeConfig: NuxtConfig = nuxtConfig({
{
path: r('./components/atoms'),
prefix: '',
global: true,
isAsync: false,
level: 2
},
{
path: r('./components/atoms/icons'),
prefix: '',
global: true,
isAsync: false,
level: 2
},
{
path: r('./components/atoms/prose'),
prefix: '',
global: true,
isAsync: false,
level: 2
},
/**
Expand All @@ -53,7 +53,7 @@ const themeConfig: NuxtConfig = nuxtConfig({
{
path: r('./components/molecules'),
prefix: '',
global: true,
isAsync: false,
level: 2
},
/**
Expand All @@ -62,37 +62,37 @@ const themeConfig: NuxtConfig = nuxtConfig({
{
path: r('./components/organisms'),
prefix: '',
global: true,
isAsync: false,
level: 2
},
{
path: r('./components/organisms/app'),
prefix: '',
global: true,
isAsync: false,
level: 2
},
{
path: r('./components/organisms/blog'),
prefix: '',
global: true,
isAsync: false,
level: 2
},
{
path: r('./components/organisms/dev-slots'),
prefix: '',
global: true,
isAsync: false,
level: 2
},
{
path: r('./components/organisms/page'),
prefix: '',
global: true,
isAsync: false,
level: 2
},
{
path: r('./components/organisms/slots'),
prefix: '',
global: true,
isAsync: false,
level: 2
},
/**
Expand All @@ -101,7 +101,7 @@ const themeConfig: NuxtConfig = nuxtConfig({
{
path: r('./components/templates'),
prefix: '',
global: true,
isAsync: false,
level: 2
}
],
Expand Down
2 changes: 1 addition & 1 deletion src/defaultTheme/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export default <Module>function themeSetupModule() {
// Register the root `components` directory
dirs.push({
path: componentsDirPath,
global: true
isAsync: false
})

// Check for sub directories
Expand Down
60 changes: 51 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1499,19 +1499,19 @@
upath "^2.0.1"
wrap-ansi "^7.0.0"

"@nuxt/components@^2.1.8":
"@nuxt/components@^2.1.8", "@nuxt/components@npm:@pi0/components":
version "2.1.8"
resolved "https://registry.yarnpkg.com/@nuxt/components/-/components-2.1.8.tgz#2d07fe077768d0a3041a5685c08ad8825ea2f2cd"
integrity sha512-gdVzBiM9V28svAKWlGg+IrvRXF9sHlWaVNKDNNYpYg0zh7f9xNxYAk6DtQeBBJshbAsPaXC9J2ZFxfrREX3H8w==
resolved "https://registry.yarnpkg.com/@pi0/components/-/components-2.1.8.tgz#9d95e781b9ab797e5befb1c7bb4b3571985dc4d1"
integrity sha512-ibyKBG9OcUnxJVBgkgnoJHcstQ/imCuHJMYzvZbRh+8sg2q6TpMx0paFfNcc5f+gLIvbatGM5LFg9+AZgUuZUA==
dependencies:
chalk "^4.1.1"
chokidar "^3.5.1"
glob "^7.1.6"
globby "^11.0.3"
chokidar "^3.5.2"
glob "^7.1.7"
globby "^11.0.4"
scule "^0.2.1"
semver "^7.3.5"
upath "^2.0.1"
vue-template-compiler "^2.6.12"
vue-template-compiler "^2.6.14"

"@nuxt/[email protected]":
version "2.16.0-27084973.0742f59e"
Expand Down Expand Up @@ -3104,7 +3104,7 @@ anymatch@^2.0.0:
micromatch "^3.1.4"
normalize-path "^2.1.1"

anymatch@^3.1.1, anymatch@~3.1.1:
anymatch@^3.1.1, anymatch@~3.1.1, anymatch@~3.1.2:
version "3.1.2"
resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.2.tgz#c0557c096af32f106198f4f4e2a383537e378716"
integrity sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==
Expand Down Expand Up @@ -4364,6 +4364,21 @@ chokidar@^3.4.1, chokidar@^3.4.2, chokidar@^3.5.1:
optionalDependencies:
fsevents "~2.3.1"

chokidar@^3.5.2:
version "3.5.2"
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.2.tgz#dba3976fcadb016f66fd365021d91600d01c1e75"
integrity sha512-ekGhOnNVPgT77r4K/U3GDhu+FQ2S8TnK/s2KbIGXi0SZWuwkZ2QNyfWdZW+TVfn84DpEP7rLeCt2UI6bJ8GwbQ==
dependencies:
anymatch "~3.1.2"
braces "~3.0.2"
glob-parent "~5.1.2"
is-binary-path "~2.1.0"
is-glob "~4.0.1"
normalize-path "~3.0.0"
readdirp "~3.6.0"
optionalDependencies:
fsevents "~2.3.2"

chownr@^1.1.1:
version "1.1.4"
resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.4.tgz#6fc9d7b42d32a583596337666e7d08084da2cc6b"
Expand Down Expand Up @@ -6877,7 +6892,7 @@ glob-parent@^3.1.0:
is-glob "^3.1.0"
path-dirname "^1.0.0"

glob-parent@^5.1.0, glob-parent@^5.1.2, glob-parent@~5.1.0:
glob-parent@^5.1.0, glob-parent@^5.1.2, glob-parent@~5.1.0, glob-parent@~5.1.2:
version "5.1.2"
resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4"
integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==
Expand Down Expand Up @@ -6951,6 +6966,18 @@ globby@^11.0.1, globby@^11.0.3:
merge2 "^1.3.0"
slash "^3.0.0"

globby@^11.0.4:
version "11.0.4"
resolved "https://registry.yarnpkg.com/globby/-/globby-11.0.4.tgz#2cbaff77c2f2a62e71e9b2813a67b97a3a3001a5"
integrity sha512-9O4MVG9ioZJ08ffbcyVYyLOJLk5JQ688pJ4eMGLpdWLHq/Wr1D9BlriLQyL0E+jbkuePVZXYFj47QM/v093wHg==
dependencies:
array-union "^2.1.0"
dir-glob "^3.0.1"
fast-glob "^3.1.1"
ignore "^5.1.4"
merge2 "^1.3.0"
slash "^3.0.0"

good-listener@^1.2.2:
version "1.2.2"
resolved "https://registry.yarnpkg.com/good-listener/-/good-listener-1.2.2.tgz#d53b30cdf9313dffb7dc9a0d477096aa6d145c50"
Expand Down Expand Up @@ -11330,6 +11357,13 @@ readdirp@~3.5.0:
dependencies:
picomatch "^2.2.1"

readdirp@~3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7"
integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==
dependencies:
picomatch "^2.2.1"

[email protected]:
version "0.20.4"
resolved "https://registry.yarnpkg.com/recast/-/recast-0.20.4.tgz#db55983eac70c46b3fff96c8e467d65ffb4a7abc"
Expand Down Expand Up @@ -13660,6 +13694,14 @@ vue-template-compiler@^2.6.11, vue-template-compiler@^2.6.12, vue-template-compi
de-indent "^1.0.2"
he "^1.1.0"

vue-template-compiler@^2.6.14:
version "2.6.14"
resolved "https://registry.yarnpkg.com/vue-template-compiler/-/vue-template-compiler-2.6.14.tgz#a2f0e7d985670d42c9c9ee0d044fed7690f4f763"
integrity sha512-ODQS1SyMbjKoO1JBJZojSw6FE4qnh9rIpUZn2EUT86FKizx9uH5z6uXiIrm4/Nb/gwxTi/o17ZDEGWAXHvtC7g==
dependencies:
de-indent "^1.0.2"
he "^1.1.0"

vue-template-es2015-compiler@^1.9.0, vue-template-es2015-compiler@^1.9.1:
version "1.9.1"
resolved "https://registry.yarnpkg.com/vue-template-es2015-compiler/-/vue-template-es2015-compiler-1.9.1.tgz#1ee3bc9a16ecbf5118be334bb15f9c46f82f5825"
Expand Down

0 comments on commit 58adb6c

Please sign in to comment.