docs: add documentation

This commit is contained in:
Daniel Roe 2024-11-27 14:16:16 +00:00
parent 020f212114
commit 4b5b8ce38a
No known key found for this signature in database
GPG Key ID: 3714AB03996F442B
2 changed files with 62 additions and 1 deletions

View File

@ -73,7 +73,8 @@ export default defineNuxtConfig({
// resetAsyncDataToUndefined: true, // resetAsyncDataToUndefined: true,
// templateUtils: true, // templateUtils: true,
// relativeWatchPaths: true, // relativeWatchPaths: true,
// normalizeComponentNames: false // normalizeComponentNames: false,
// spaLoadingTemplateLocation: 'within',
// defaults: { // defaults: {
// useAsyncData: { // useAsyncData: {
// deep: true // deep: true
@ -237,6 +238,45 @@ export default defineNuxtConfig({
}) })
``` ```
#### New DOM Location for SPA Loading Screen
🚦 **Impact Level**: Minimal
##### What Changed
When rendering a client-only page (with `ssr: false`), we optionally render a loading screen (from `app/spa-loading-template.html`), within the Nuxt app root:
```html
<div id="__nuxt">
<!-- spa loading template -->
</div>
```
Now, we default to rendering the template alongside the Nuxt app root:
```html
<div id="__nuxt"></div>
<!-- spa loading template -->
```
##### Reasons for Change
This allows the spa loading template to remain in the DOM until the Vue app suspense resolves, preventing a flash of white.
##### Migration Steps
If you were targeting the spa loading template with CSS or `document.queryElement` you will need to update your selectors. For this purpose you can use the new `app.spaLoaderTag` and `app.spaLoaderAttrs` configuration options.
Alternatively, you can revert to the previous behaviour with:
```ts twoslash [nuxt.config.ts]
export default defineNuxtConfig({
experimental: {
spaLoadingTemplateLocation: 'within',
}
})
```
#### Scan Page Meta After Resolution #### Scan Page Meta After Resolution
🚦 **Impact Level**: Minimal 🚦 **Impact Level**: Minimal

View File

@ -422,3 +422,24 @@ In this case, the component name would be `MyComponent`, as far as Vue is concer
But in order to auto-import it, you would need to use `SomeFolderMyComponent`. But in order to auto-import it, you would need to use `SomeFolderMyComponent`.
By setting `experimental.normalizeComponentNames`, these two values match, and Vue will generate a component name that matches the Nuxt pattern for component naming. By setting `experimental.normalizeComponentNames`, these two values match, and Vue will generate a component name that matches the Nuxt pattern for component naming.
## spaLoadingTemplateLocation
When rendering a client-only page (with `ssr: false`), we optionally render a loading screen (from `app/spa-loading-template.html`).
It can be set to `within`, which will render it like this:
```html
<div id="__nuxt">
<!-- spa loading template -->
</div>
```
Alternatively, you can render the template alongside the Nuxt app root by setting it to `body`:
```html
<div id="__nuxt"></div>
<!-- spa loading template -->
```
This avoids a white flash when hydrating a client-only page.