Skip to content

Commit 2353854

Browse files
committed
Merge remote-tracking branch 'upstream/master' into working
# Conflicts resolved: # README.md # en/api/configuration-generate.md # en/api/configuration-loading.md # en/api/configuration-transition.md # en/api/context.md # en/api/internals-nuxt.md # en/api/pages-transition.md # en/faq/ios-phone-numbers.md # en/faq/now-deployment.md # en/guide/installation.md # en/guide/menu.json # en/guide/plugins.md # fr/faq/menu.json # fr/faq/netlify-deployment.md # fr/guide/assets.md # fr/guide/installation.md Signed-off-by: MachinisteWeb <[email protected]>
2 parents d19edb1 + 4a17fd8 commit 2353854

File tree

160 files changed

+4726
-1287
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

160 files changed

+4726
-1287
lines changed

de/api/configuration-router.md

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,14 @@ const scrollBehavior = function (to, from, savedPosition) {
153153
// will retain current scroll position.
154154
let position = false
155155

156-
// if no children detected
157-
if (to.matched.length < 2) {
156+
// if no children detected and scrollToTop is not explicitly disabled
157+
if (
158+
to.matched.length < 2 &&
159+
to.matched.every(r => r.components.default.options.scrollToTop !== false)
160+
) {
158161
// scroll to the top of the page
159162
position = { x: 0, y: 0 }
160-
} else if (to.matched.some((r) => r.components.default.options.scrollToTop)) {
163+
} else if (to.matched.some(r => r.components.default.options.scrollToTop)) {
161164
// if one of the children has scrollToTop option set to true
162165
position = { x: 0, y: 0 }
163166
}
@@ -167,14 +170,25 @@ const scrollBehavior = function (to, from, savedPosition) {
167170
position = savedPosition
168171
}
169172

170-
return new Promise(resolve => {
173+
return new Promise((resolve) => {
171174
// wait for the out transition to complete (if necessary)
172175
window.$nuxt.$once('triggerScroll', () => {
173176
// coords will be used if no selector is provided,
174177
// or if the selector didn't match any element.
175-
if (to.hash && document.querySelector(to.hash)) {
176-
// scroll to anchor by returning the selector
177-
position = { selector: to.hash }
178+
if (to.hash) {
179+
let hash = to.hash
180+
// CSS.escape() is not supported with IE and Edge.
181+
if (typeof window.CSS !== 'undefined' && typeof window.CSS.escape !== 'undefined') {
182+
hash = '#' + window.CSS.escape(hash.substr(1))
183+
}
184+
try {
185+
if (document.querySelector(hash)) {
186+
// scroll to anchor by returning the selector
187+
position = { selector: hash }
188+
}
189+
} catch (e) {
190+
console.warn('Failed to save scroll position. Please add CSS.escape() polyfill (https://github.com/mathiasbynens/CSS.escape).')
191+
}
178192
}
179193
resolve(position)
180194
})

en/api/configuration-generate.md

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ export default {
2020
}
2121
```
2222

23+
## concurrency
24+
25+
- Type: `Number`
26+
- Default: `500`
27+
28+
The generation of routes are concurrent, `generate.concurrency` specifies the amount of routes that run in one thread.
29+
30+
2331
## dir
2432

2533
- Type : `String`
@@ -36,6 +44,39 @@ Configure whether to allow [vue-devtools](https://github.com/vuejs/vue-devtools)
3644

3745
If you already activated through nuxt.config.js or otherwise, devtools enable regardless of the flag.
3846

47+
## exclude
48+
49+
- Type: `Array`
50+
51+
It accepts an array of regular expressions and will prevent generation of routes matching them. The routes will still be accessible when `generate.fallback` is used.
52+
53+
By default, running `nuxt generate` will create a file for each route.
54+
55+
```bash
56+
-| dist/
57+
---| index.html
58+
---| ignore/
59+
-----| about.html
60+
-----| item.html
61+
```
62+
63+
When adding a regular expression which matches all routes with "ignore", it will prevent the generation of these routes.
64+
65+
nuxt.config.js
66+
```js
67+
export default {
68+
generate: {
69+
exclude: [
70+
/^(?=.*\bignore\b).*$/,
71+
],
72+
}
73+
}
74+
```
75+
76+
```bash
77+
-| dist/
78+
---| index.html
79+
```
3980

4081
## fallback
4182

@@ -229,10 +270,3 @@ export default {
229270
```
230271

231272
_Note : cette option peut être utile en utilisant [Netlify](https://netlify.com) ou n'importe quel hébergement utilisant des alternatives HTML._
232-
233-
## concurrence
234-
235-
- Type: `Number`
236-
- Default: `500`
237-
238-
La génération de routes est concurrente, `generate.concurrency` spécifie le nombre de routes qui peuvent être exécuté par un thread.

en/api/configuration-loading.md

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ description: Nuxt.js uses its own component to show a progress bar between the r
77

88
- Type: `Boolean` or `Object` or `String`
99

10-
> Nuxt.js uses its own component to show a progress bar between the routes. You can customize it, disable it or create your own component.
10+
> Out of the box, Nuxt.js gives you its own loading progress bar component that's shown between routes. You can customize it, disable it or create your own component.
1111
12-
In your component you can use `this.$nuxt.$loading.start()` to start the loading bar and `this.$nuxt.$loading.finish()` to finish it.
12+
The loading bar can also be programmatically started in your components by calling `this.$nuxt.$loading.start()` to start the loading bar and `this.$nuxt.$loading.finish()` to finish it.
13+
14+
During your page's component's mounting process, the `$loading` property may not be immediately available to access. To work around this, if you want to start the loader in the `mounted` method, make sure to wrap your `$loading` method calls inside ` this.$nextTick` as shown below.
1315

1416
```javascript
1517
export default {
@@ -23,8 +25,6 @@ export default {
2325
}
2426
```
2527

26-
> If you want to start it in the `mounted` method, make sure to use ` this.$nextTick`, because $loading may not be available immediately.
27-
2828
## Disable the Progress Bar
2929

3030
- Type: `Boolean`
@@ -37,10 +37,23 @@ export default {
3737
}
3838
```
3939

40-
## Customize the Progress Bar
40+
## Customizing the Progress Bar
4141

4242
- Type: `Object`
4343

44+
Among other properties, the color, size, duration and direction of the progress bar can be customized to suit your application's needs. This is done by updating the `loading` property of the `nuxt.config.js` with the corresponding properties.
45+
46+
For example, to set a blue progress bar with a height of 5px, we update the `nuxt.config.js` to the following:
47+
48+
```js
49+
export default {
50+
loading: {
51+
color: 'blue',
52+
height: '5px'
53+
}
54+
}
55+
```
56+
4457
List of properties to customize the progress bar.
4558

4659
| Key | Type | Default | Description |
@@ -54,22 +67,26 @@ List of properties to customize the progress bar.
5467
| `css` | Boolean | `true` | Set to false to remove default progress bar styles (and add your own). |
5568
| `rtl` | Boolean | `false` | Set the direction of the progress bar from right to left. |
5669

57-
For a blue progress bar with 5px of height, we update the `nuxt.config.js` to the following:
5870

59-
```js
60-
export default {
61-
loading: {
62-
color: 'blue',
63-
height: '5px'
64-
}
65-
}
66-
```
71+
## Internals of the Progress Bar
72+
73+
Unfortunately, it is not possible for the Loading component to know in advance how long loading a new page will take. Therefore, it is not possible to accurately animate the progress bar to 100% of the loading time.
74+
75+
Nuxt's loading component partially solves this by letting you set the `duration`, this should be set to a _guestimate_ of how long the loading process will take. Unless you use a custom loading component, the progress bar will always move from 0% to 100% in `duration` time (regardless of actual progression). When the loading takes longer than `duration` time, the progress bar will stay at 100% until the loading finishes.
76+
77+
You can change the default behaviour by setting `continuous` to true, then after reaching 100% the progress bar will start shrinking back to 0% again in `duration` time. When the loading is still not finished after reaching 0% it will start growing from 0% to 100% again, this repeats until the loading finishes.
78+
79+
*Example of a continuous progress bar:*
80+
81+
82+
<img src="/api-continuous-loading.gif" alt="continuous loading"/>
83+
6784

68-
## Use a Custom Loading Component
85+
## Using a Custom Loading Component
6986

7087
- Type: `String`
7188

72-
You can create your own component that Nuxt.js will call instead of its default component. To do so, you need to give a path to your component in the `loading` option. Then, your component will be called directly by Nuxt.js.
89+
You can also create your own component that Nuxt.js will call instead of its default loading progress bar component. To do so, you need to give a path to your component in the `loading` option. Then, your component will be called directly by Nuxt.js.
7390

7491
**Your component has to expose some of these methods:**
7592

en/api/configuration-router.md

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,14 @@ const scrollBehavior = function (to, from, savedPosition) {
255255
// will retain current scroll position.
256256
let position = false
257257

258-
// if no children detected
259-
if (to.matched.length < 2) {
258+
// if no children detected and scrollToTop is not explicitly disabled
259+
if (
260+
to.matched.length < 2 &&
261+
to.matched.every(r => r.components.default.options.scrollToTop !== false)
262+
) {
260263
// scroll to the top of the page
261264
position = { x: 0, y: 0 }
262-
} else if (to.matched.some((r) => r.components.default.options.scrollToTop)) {
265+
} else if (to.matched.some(r => r.components.default.options.scrollToTop)) {
263266
// if one of the children has scrollToTop option set to true
264267
position = { x: 0, y: 0 }
265268
}
@@ -269,14 +272,25 @@ const scrollBehavior = function (to, from, savedPosition) {
269272
position = savedPosition
270273
}
271274

272-
return new Promise(resolve => {
275+
return new Promise((resolve) => {
273276
// wait for the out transition to complete (if necessary)
274277
window.$nuxt.$once('triggerScroll', () => {
275278
// coords will be used if no selector is provided,
276279
// or if the selector didn't match any element.
277-
if (to.hash && document.querySelector(to.hash)) {
278-
// scroll to anchor by returning the selector
279-
position = { selector: to.hash }
280+
if (to.hash) {
281+
let hash = to.hash
282+
// CSS.escape() is not supported with IE and Edge.
283+
if (typeof window.CSS !== 'undefined' && typeof window.CSS.escape !== 'undefined') {
284+
hash = '#' + window.CSS.escape(hash.substr(1))
285+
}
286+
try {
287+
if (document.querySelector(hash)) {
288+
// scroll to anchor by returning the selector
289+
position = { selector: hash }
290+
}
291+
} catch (e) {
292+
console.warn('Failed to save scroll position. Please add CSS.escape() polyfill (https://github.com/mathiasbynens/CSS.escape).')
293+
}
280294
}
281295
resolve(position)
282296
})

en/api/configuration-transition.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
---
2-
title: "API: The transition Property (EN)"
3-
description: Set the default properties of the page transitions.
2+
title: "API: The pageTransition and layoutTransition Properties (EN)"
3+
description: Set the default properties of the page and layout transitions.
44
---
55

6-
# The transition Property (EN)
6+
> Nuxt v2.7.0 introduces key "pageTransition" in favor of the "transition" key to consolidate the naming with layout transition keys.
7+
8+
# The pageTransition Property (EN)
79

810
- Type: `String` or `Object`
911

@@ -21,9 +23,9 @@ Example (`nuxt.config.js`):
2123

2224
```js
2325
export default {
24-
transition: 'page'
26+
pageTransition: 'page'
2527
// or
26-
transition: {
28+
pageTransition: {
2729
name: 'page',
2830
mode: 'out-in',
2931
beforeEnter (el) {

en/api/context.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: L'objet `context` fournit des objets et paramètres additionnels en
55

66
# The Context (EN)
77

8-
> L'objet `context` fournit des objets et paramètres additionnels en provenance de Nuxt qui ne sont pas traditionnellement disponibles dans les composants Vue. Le `context` est disponible dans des aires de cycle de vie spécifique à Nuxt. On y retrouve, par exemple, `asyncData`, `plugins`, 'middlewares', 'modules', et 'store/nuxtServerInit`.
8+
> The `context` provides additional objects/params from Nuxt to Vue components. The `context` is available in special nuxt lifecycle areas like `asyncData`, `fetch`, `plugins`, `middleware`, `modules`, and `nuxtServerInit`.
99
1010
## Available keys (EN)
1111

en/api/menu.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,15 @@
9191
{
9292
"name": "generate", "to": "/configuration-generate",
9393
"contents": [
94+
{ "name": "concurrency", "to": "#concurrency" },
9495
{ "name": "dir", "to": "#dir" },
9596
{ "name": "devtools", "to": "#devtools" },
97+
{ "name": "exclude", "to": "#exclude" },
9698
{ "name": "fallback", "to": "#fallback" },
9799
{ "name": "interval", "to": "#interval" },
98100
{ "name": "minify", "to": "#minify" },
99101
{ "name": "routes", "to": "#routes" },
100-
{ "name": "subFolders", "to": "#subfolders" },
101-
{ "name": "concurrency", "to": "#concurrency" }
102+
{ "name": "subFolders", "to": "#subfolders" }
102103
]
103104
},
104105
{ "name": "head (EN)", "to": "/configuration-head" },

0 commit comments

Comments
 (0)