mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 15:15:19 +00:00
docs: fix TypeScript errors for examples (#28403)
This commit is contained in:
parent
754fc30e5d
commit
32f1573614
@ -39,6 +39,8 @@ You can add, change or remove pages from the scanned routes with the `pages:exte
|
|||||||
For example, to prevent creating routes for any `.ts` files:
|
For example, to prevent creating routes for any `.ts` files:
|
||||||
|
|
||||||
```ts [nuxt.config.ts]
|
```ts [nuxt.config.ts]
|
||||||
|
import type { NuxtPage } from '@nuxt/schema'
|
||||||
|
|
||||||
export default defineNuxtConfig({
|
export default defineNuxtConfig({
|
||||||
hooks: {
|
hooks: {
|
||||||
'pages:extend' (pages) {
|
'pages:extend' (pages) {
|
||||||
@ -51,9 +53,9 @@ export default defineNuxtConfig({
|
|||||||
|
|
||||||
// remove routes
|
// remove routes
|
||||||
function removePagesMatching (pattern: RegExp, pages: NuxtPage[] = []) {
|
function removePagesMatching (pattern: RegExp, pages: NuxtPage[] = []) {
|
||||||
const pagesToRemove = []
|
const pagesToRemove: NuxtPage[] = []
|
||||||
for (const page of pages) {
|
for (const page of pages) {
|
||||||
if (pattern.test(page.file)) {
|
if (page.file && pattern.test(page.file)) {
|
||||||
pagesToRemove.push(page)
|
pagesToRemove.push(page)
|
||||||
} else {
|
} else {
|
||||||
removePagesMatching(pattern, page.children)
|
removePagesMatching(pattern, page.children)
|
||||||
@ -85,7 +87,7 @@ On top of customizing options for [`vue-router`](https://router.vuejs.org/api/in
|
|||||||
|
|
||||||
This is the recommended way to specify [router options](/docs/api/nuxt-config#router).
|
This is the recommended way to specify [router options](/docs/api/nuxt-config#router).
|
||||||
|
|
||||||
```js [app/router.options.ts]
|
```ts [app/router.options.ts]
|
||||||
import type { RouterConfig } from '@nuxt/schema'
|
import type { RouterConfig } from '@nuxt/schema'
|
||||||
|
|
||||||
export default <RouterConfig> {
|
export default <RouterConfig> {
|
||||||
@ -99,6 +101,8 @@ Adding a router options file in this hook will switch on page-based routing, unl
|
|||||||
::
|
::
|
||||||
|
|
||||||
```ts [nuxt.config.ts]
|
```ts [nuxt.config.ts]
|
||||||
|
import { createResolver } from '@nuxt/kit'
|
||||||
|
|
||||||
export default defineNuxtConfig({
|
export default defineNuxtConfig({
|
||||||
hooks: {
|
hooks: {
|
||||||
'pages:routerOptions' ({ files }) {
|
'pages:routerOptions' ({ files }) {
|
||||||
@ -166,7 +170,7 @@ export default defineNuxtConfig({
|
|||||||
|
|
||||||
You can optionally override history mode using a function that accepts the base URL and returns the history mode. If it returns `null` or `undefined`, Nuxt will fallback to the default history.
|
You can optionally override history mode using a function that accepts the base URL and returns the history mode. If it returns `null` or `undefined`, Nuxt will fallback to the default history.
|
||||||
|
|
||||||
```js [app/router.options.ts]
|
```ts [app/router.options.ts]
|
||||||
import type { RouterConfig } from '@nuxt/schema'
|
import type { RouterConfig } from '@nuxt/schema'
|
||||||
import { createMemoryHistory } from 'vue-router'
|
import { createMemoryHistory } from 'vue-router'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user