mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 00:23:53 +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:
|
||||
|
||||
```ts [nuxt.config.ts]
|
||||
import type { NuxtPage } from '@nuxt/schema'
|
||||
|
||||
export default defineNuxtConfig({
|
||||
hooks: {
|
||||
'pages:extend' (pages) {
|
||||
@ -51,9 +53,9 @@ export default defineNuxtConfig({
|
||||
|
||||
// remove routes
|
||||
function removePagesMatching (pattern: RegExp, pages: NuxtPage[] = []) {
|
||||
const pagesToRemove = []
|
||||
const pagesToRemove: NuxtPage[] = []
|
||||
for (const page of pages) {
|
||||
if (pattern.test(page.file)) {
|
||||
if (page.file && pattern.test(page.file)) {
|
||||
pagesToRemove.push(page)
|
||||
} else {
|
||||
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).
|
||||
|
||||
```js [app/router.options.ts]
|
||||
```ts [app/router.options.ts]
|
||||
import type { RouterConfig } from '@nuxt/schema'
|
||||
|
||||
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]
|
||||
import { createResolver } from '@nuxt/kit'
|
||||
|
||||
export default defineNuxtConfig({
|
||||
hooks: {
|
||||
'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.
|
||||
|
||||
```js [app/router.options.ts]
|
||||
```ts [app/router.options.ts]
|
||||
import type { RouterConfig } from '@nuxt/schema'
|
||||
import { createMemoryHistory } from 'vue-router'
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user