Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(nuxt-link): Smart prefetching and $nuxt.isOffline #4574

Merged
merged 32 commits into from
Dec 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c019997
feat(nuxt-link): Improve <n-link> and add automatic prefetch
Atinux Dec 17, 2018
355ba63
Update packages/vue-app/template/components/nuxt-link.js
manniL Dec 20, 2018
9d2f5ab
add missing space
manniL Dec 20, 2018
c3a8da4
Merge branch 'dev' into feat-nlink-prefetch
Dec 20, 2018
d9d691f
feat(nuxt-link): Split in two components for smaller bundle
Atinux Dec 21, 2018
27fc3df
fix(vue-app): Use requestIdleCallback
Atinux Dec 21, 2018
8ecc729
chore(vue-app): Improve nuxt prefetch strategy for nuxt links
Atinux Dec 24, 2018
f2f328c
chore(vue-app): Add .isOnline and handle it for prefetch
Atinux Dec 26, 2018
1499ed0
Merge branch 'dev' into feat-nlink-prefetch
Dec 26, 2018
d9e5812
chore(vue-app): Add .isOffline and use it
Atinux Dec 27, 2018
406d210
chore(vue-app): Add .isOffline
Atinux Dec 27, 2018
7f260bf
chore(server): Check is options.modern is given in dev mode
Atinux Dec 27, 2018
42d8191
chore(vue-app): Add intersection-observer polyfill if router.prefetch…
Atinux Dec 27, 2018
9f4f481
chore(vue-app): Remove polyfill
Atinux Dec 27, 2018
485e6e8
chore(vue-app): Use only process.client
Atinux Dec 27, 2018
1bfc8bc
chore(vue-app): Add TS typings for .isOnline and isOffline
Atinux Dec 27, 2018
aecb458
Merge branch 'dev' into feat-nlink-prefetch
Dec 27, 2018
844da5a
chore(vue-app): Update typings by @kevinmarrec
Atinux Dec 27, 2018
316899d
Merge branch 'feat-nlink-prefetch' of github.com:nuxt/nuxt.js into fe…
Atinux Dec 27, 2018
78580a6
chore(vue-app): Reorder names
Atinux Dec 27, 2018
7274c99
examples(nuxt-prefetch): Add Nuxt prefetching example
Atinux Dec 27, 2018
8bdadc9
chore(vue-app): Add router.linkPrefetchedClass
Atinux Dec 27, 2018
85105b8
lint(vue-app): Fix lint
Atinux Dec 28, 2018
28d32ac
chore(vue-app): Use intersectionRatio, recommend by @maoberlehner
Atinux Dec 28, 2018
94360d0
fix(lint): Fix linting issues
Atinux Dec 28, 2018
a2d8673
lint(vue-app): Fix again (lol)
Atinux Dec 28, 2018
0fc946a
types(vue-app): Update TS typings
Atinux Dec 28, 2018
8f70dc9
chore(vue-app): Update Vetur tags description
Atinux Dec 28, 2018
d81fbb0
fix(vue-app): Use prefetchClass
Atinux Dec 28, 2018
bd505fc
chore(vue-app): Disable linkPrefetchedClass by default
Atinux Dec 28, 2018
e02001c
Merge branch 'dev' into feat-nlink-prefetch
Dec 28, 2018
23d53fa
Merge branch 'dev' into feat-nlink-prefetch
Dec 28, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/nuxt-prefetch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Example of Nuxt.js prefetching

Learn more at https://github.com/nuxt/nuxt.js/pull/4574
1 change: 1 addition & 0 deletions examples/nuxt-prefetch/assets/check.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 57 additions & 0 deletions examples/nuxt-prefetch/layouts/default.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<template>
<div>
<div v-if="$nuxt.isOffline" class="offline">
You are offline
</div>
<div class="container">
<h1>{{ $route.name }}</h1>
<Nuxt />
</div>
</div>
</template>

<style>
body {
padding: 0;
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}
.container {
padding: 10px 20px;
padding-bottom: 40px;
}
.offline {
background: #3B8070;
color: white;
position: fixed;
bottom: 0;
left: 0;
right: 0;
padding: 10px;
}
a {
display: block;
padding: 10px 10px 10px 0px;
margin: 20px 0;
font-size: 20px;
border-bottom: 2px #ddd solid;
color: #3B8070;
text-decoration: none;
transition: border-bottom-color 0.3s linear;
}
a:hover,
a.nuxt-link-exact-active {
background-color: rgb(245, 245, 245);
}
a.nuxt-link-prefetched:after {
content: '';
display: inline-block;
background: url('../assets/check.svg') no-repeat;
background-size: 14px;
width: 14px;
height: 14px;
position: relative;
right: -3px;
top: 1px;
}
</style>
12 changes: 12 additions & 0 deletions examples/nuxt-prefetch/nuxt.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export default {
head: {
titleTemplate: '%s - NuxtJS Prefetching'
},
router: {
// To disable prefetching, uncomment the line
// prefetchLinks: false

// Activate prefetched class (default: false)
linkPrefetchedClass: 'nuxt-link-prefetched'
}
}
11 changes: 11 additions & 0 deletions examples/nuxt-prefetch/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "example-hello-world",
"dependencies": {
"nuxt": "latest"
},
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start"
}
}
17 changes: 17 additions & 0 deletions examples/nuxt-prefetch/pages/accelerated.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template>
<div>
<NuxtLink v-for="link of $store.state.links" :key="link" :to="{ name: link }">
/{{ link }}
</NuxtLink>
</div>
</template>

<script>
export default {
head() {
return {
title: this.$route.name
}
}
}
</script>
17 changes: 17 additions & 0 deletions examples/nuxt-prefetch/pages/active.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template>
<div>
<NuxtLink v-for="link of $store.state.links" :key="link" :to="{ name: link }">
/{{ link }}
</NuxtLink>
</div>
</template>

<script>
export default {
head() {
return {
title: this.$route.name
}
}
}
</script>
17 changes: 17 additions & 0 deletions examples/nuxt-prefetch/pages/agile.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template>
<div>
<NuxtLink v-for="link of $store.state.links" :key="link" :to="{ name: link }">
/{{ link }}
</NuxtLink>
</div>
</template>

<script>
export default {
head() {
return {
title: this.$route.name
}
}
}
</script>
17 changes: 17 additions & 0 deletions examples/nuxt-prefetch/pages/brisk.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template>
<div>
<NuxtLink v-for="link of $store.state.links" :key="link" :to="{ name: link }">
/{{ link }}
</NuxtLink>
</div>
</template>

<script>
export default {
head() {
return {
title: this.$route.name
}
}
}
</script>
17 changes: 17 additions & 0 deletions examples/nuxt-prefetch/pages/dashing.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template>
<div>
<NuxtLink v-for="link of $store.state.links" :key="link" :to="{ name: link }">
/{{ link }}
</NuxtLink>
</div>
</template>

<script>
export default {
head() {
return {
title: this.$route.name
}
}
}
</script>
17 changes: 17 additions & 0 deletions examples/nuxt-prefetch/pages/electric.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template>
<div>
<NuxtLink v-for="link of $store.state.links" :key="link" :to="{ name: link }">
/{{ link }}
</NuxtLink>
</div>
</template>

<script>
export default {
head() {
return {
title: this.$route.name
}
}
}
</script>
17 changes: 17 additions & 0 deletions examples/nuxt-prefetch/pages/flashing.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template>
<div>
<NuxtLink v-for="link of $store.state.links" :key="link" :to="{ name: link }">
/{{ link }}
</NuxtLink>
</div>
</template>

<script>
export default {
head() {
return {
title: this.$route.name
}
}
}
</script>
17 changes: 17 additions & 0 deletions examples/nuxt-prefetch/pages/fleet.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template>
<div>
<NuxtLink v-for="link of $store.state.links" :key="link" :to="{ name: link }">
/{{ link }}
</NuxtLink>
</div>
</template>

<script>
export default {
head() {
return {
title: this.$route.name
}
}
}
</script>
17 changes: 17 additions & 0 deletions examples/nuxt-prefetch/pages/fleeting.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template>
<div>
<NuxtLink v-for="link of $store.state.links" :key="link" :to="{ name: link }">
/{{ link }}
</NuxtLink>
</div>
</template>

<script>
export default {
head() {
return {
title: this.$route.name
}
}
}
</script>
17 changes: 17 additions & 0 deletions examples/nuxt-prefetch/pages/flying.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template>
<div>
<NuxtLink v-for="link of $store.state.links" :key="link" :to="{ name: link }">
/{{ link }}
</NuxtLink>
</div>
</template>

<script>
export default {
head() {
return {
title: this.$route.name
}
}
}
</script>
17 changes: 17 additions & 0 deletions examples/nuxt-prefetch/pages/hot.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template>
<div>
<NuxtLink v-for="link of $store.state.links" :key="link" :to="{ name: link }">
/{{ link }}
</NuxtLink>
</div>
</template>

<script>
export default {
head() {
return {
title: this.$route.name
}
}
}
</script>
17 changes: 17 additions & 0 deletions examples/nuxt-prefetch/pages/hurried.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template>
<div>
<NuxtLink v-for="link of $store.state.links" :key="link" :to="{ name: link }">
/{{ link }}
</NuxtLink>
</div>
</template>

<script>
export default {
head() {
return {
title: this.$route.name
}
}
}
</script>
17 changes: 17 additions & 0 deletions examples/nuxt-prefetch/pages/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template>
<div>
<NuxtLink v-for="link of $store.state.links" :key="link" :to="{ name: link }">
/{{ link }}
</NuxtLink>
</div>
</template>

<script>
export default {
head() {
return {
title: this.$route.name
}
}
}
</script>
17 changes: 17 additions & 0 deletions examples/nuxt-prefetch/pages/nimble.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template>
<div>
<NuxtLink v-for="link of $store.state.links" :key="link" :to="{ name: link }">
/{{ link }}
</NuxtLink>
</div>
</template>

<script>
export default {
head() {
return {
title: this.$route.name
}
}
}
</script>
17 changes: 17 additions & 0 deletions examples/nuxt-prefetch/pages/quick.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template>
<div>
<NuxtLink v-for="link of $store.state.links" :key="link" :to="{ name: link }">
/{{ link }}
</NuxtLink>
</div>
</template>

<script>
export default {
head() {
return {
title: this.$route.name
}
}
}
</script>
17 changes: 17 additions & 0 deletions examples/nuxt-prefetch/pages/racing.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template>
<div>
<NuxtLink v-for="link of $store.state.links" :key="link" :to="{ name: link }">
/{{ link }}
</NuxtLink>
</div>
</template>

<script>
export default {
head() {
return {
title: this.$route.name
}
}
}
</script>
17 changes: 17 additions & 0 deletions examples/nuxt-prefetch/pages/rapid.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template>
<div>
<NuxtLink v-for="link of $store.state.links" :key="link" :to="{ name: link }">
/{{ link }}
</NuxtLink>
</div>
</template>

<script>
export default {
head() {
return {
title: this.$route.name
}
}
}
</script>