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

4.0 #136

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

4.0 #136

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
# Changelog

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [4.0.0](https://github.com/victorgarciaesgi/nuxt-typed-router/compare/v3.5.0...v4.0.0) (2023-12-07)

New features

- `ignoreRoutes` option now support Globs pattern

Fixs

- Fixed strict:true errors when using `router.push('xxx')`
- Fixed import of `NuxtLocaleRoute`




Changelog
All notable changes to this project will be documented in this file.

Expand Down
5 changes: 3 additions & 2 deletions docs/content/3.options/4.ignoreRoutes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ title: ignoreRoutes
# ignoreRoutes

Allow to ignore selected files to be typed, for exemple 404 routes or catch-all routes.
You can pass an array of file paths (taking base of your `pagesDir`).
You can pass an array of file paths or glob patterns (taking base of your `pagesDir`).


Usage:

```ts
ignoreRoutes: ["[...404].vue", "admin/[...slug].vue"];
ignoreRoutes: ["[...404].vue", "admin/[...slug].vue", "ignored/**/*"];
```

## Type
Expand Down
4 changes: 2 additions & 2 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"preview": "nuxi preview"
},
"devDependencies": {
"@nuxt-themes/docus": "1.14.3",
"nuxt": "3.8.1"
"@nuxt-themes/docus": "1.15.0",
"nuxt": "3.10.1"
}
}
107 changes: 56 additions & 51 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "nuxt-typed-router",
"version": "3.5.1",
"description": "Provide autocompletion for routes paths, names and params in Nuxt apps",
"version": "4.0.0",
"description": "Provide a type safe router to Nuxt",
"type": "module",
"main": "./dist/module.cjs",
"main": "./dist/module.mjs",
"types": "./dist/types.d.ts",
"exports": {
".": {
Expand All @@ -15,23 +15,24 @@
"dist"
],
"scripts": {
"prepack": "nuxt-module-build build",
"build": "nuxt-module-build build",
"prepack": "pnpm run typecheck && pnpm build",
"dev": "nuxi dev playground",
"dev:build": "nuxi build playground",
"prepare:playground": "nuxi prepare playground",
"dev:prepare": "nuxt-module-build build --stub && nuxi prepare playground && pnpm run test:prepare-fixtures",
"build:test": "cross-env NUXT_BUILD_TYPE=stub pnpm run prepack && pnpm run dev:build",
"test:prepare-fixtures": "nuxi prepare test/fixtures/simple && nuxi prepare test/fixtures/withOptions && nuxi prepare test/fixtures/complex",
"test:fixtures": "vitest run --dir test",
"test:types": "pnpm run typecheck && pnpm run test:vue",
"test:vue": "vue-tsc -p test/fixtures/simple/tsconfig.json --noEmit && vue-tsc -p test/fixtures/complex/tsconfig.json --noEmit",
"test": "pnpm run dev:prepare && pnpm run test:types && pnpm run test:fixtures",
"dev:prepare": "nuxt-module-build build --stub && nuxi prepare playground",
"build:test": "cross-env NUXT_BUILD_TYPE=stub pnpm run build && pnpm run dev:build",
"lint": "eslint --ext .ts --ext .vue .",
"docs:dev": "cd docs && pnpm run dev",
"docs:prepare": "nuxt-module-build --stub && nuxi prepare playground",
"docs:build": "npm run docs:prepare && cd docs && nuxi generate",
"docs:build": "cd docs && nuxt generate",
"typecheck": "tsc --noEmit",
"release": "bumpp && npm publish && git push --follow-tags"
"release": "bumpp && npm publish && git push --follow-tags",
"test:prepare-fixtures": "nuxi prepare test/fixtures/sample-project",
"test:types-fixtures": "nuxi typecheck test/fixtures/sample-project",
"test:fixtures": "vitest run --dir test ",
"test:types": "pnpm run typecheck",
"test": "pnpm run dev:prepare && pnpm run test:prepare-fixtures && pnpm run test:types && pnpm run test:fixtures",
"test:debug": "NUXT_ROUTER_CONFIG_NAME=$CONFIG pnpm run test:types-fixtures"
},
"publishConfig": {
"access": "public"
Expand Down Expand Up @@ -63,54 +64,58 @@
"prettier": "^2.5.x || 3.x"
},
"dependencies": {
"@nuxt/kit": "3.8.2",
"@nuxt/kit": "3.10.1",
"chalk": "5.3.0",
"defu": "6.1.3",
"defu": "6.1.4",
"globby": "14.0.1",
"lodash-es": "4.17.21",
"log-symbols": "6.0.0",
"mkdirp": "3.0.1",
"nanoid": "5.0.3",
"pathe": "1.1.1",
"prettier": "3.1.0"
"nanoid": "5.0.5",
"pathe": "1.1.2",
"prettier": "3.2.5"
},
"devDependencies": {
"@nuxt/devtools": "1.0.3",
"@nuxt/schema": "3.8.2",
"@nuxt/module-builder": "0.5.4",
"@nuxt/test-utils": "3.8.1",
"@nuxt/types": "2.17.2",
"@intlify/core-base": "9.9.1",
"@intlify/message-compiler": "9.9.1",
"@intlify/shared": "9.9.1",
"@intlify/vue-i18n-bridge": "1.1.0",
"@intlify/vue-router-bridge": "1.1.0",
"@nuxt/content": "2.12.0",
"@nuxt/devtools": "1.0.8",
"@nuxt/module-builder": "0.5.5",
"@nuxt/schema": "3.10.1",
"@nuxt/test-utils": "3.11.0",
"@nuxt/types": "2.17.3",
"@nuxtjs/eslint-config-typescript": "12.1.0",
"@nuxt/content": "2.9.0",
"@nuxtjs/i18n": "8.0.0-rc.5",
"@nuxtjs/i18n": "8.1.0",
"@nuxtjs/web-vitals": "0.2.6",
"@playwright/test": "1.41.2",
"@types/lodash-es": "4.17.12",
"@types/node": "20.10.0",
"@typescript-eslint/eslint-plugin": "6.12.0",
"@typescript-eslint/parser": "6.12.0",
"@vue/test-utils": "2.4.2",
"bumpp": "9.2.0",
"changelogithub": "0.13.2",
"@types/node": "20.11.17",
"@typescript-eslint/eslint-plugin": "6.21.0",
"@typescript-eslint/parser": "6.21.0",
"@vue/test-utils": "2.4.4",
"bumpp": "9.3.0",
"changelogithub": "0.13.3",
"cross-env": "7.0.3",
"eslint": "8.54.0",
"eslint-config-prettier": "9.0.0",
"eslint-plugin-vue": "9.18.1",
"nuxt": "3.8.2",
"eslint": "8.56.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-vue": "9.21.1",
"nuxt": "3.10.1",
"nuxt-seo-kit": "1.3.13",
"playwright": "1.40.1",
"@playwright/test": "1.40.1",
"tsd": "0.29.0",
"typescript": "5.3.2",
"vitest": "0.34.6",
"vue": "3.3.10",
"vue-eslint-parser": "9.3.2",
"playwright": "1.41.2",
"prettier": "3.1.1",
"tsd": "0.30.4",
"tslib": "2.6.2",
"typescript": "5.3.3",
"vitest": "1.2.2",
"vue": "3.4.18",
"vue-eslint-parser": "9.4.2",
"vue-i18n": "9.9.1",
"vue-i18n-routing": "1.2.0",
"vue-router": "4.2.5",
"vue-tsc": "1.8.22",
"vue-i18n": "9.8.0",
"@intlify/shared": "9.8.0",
"@intlify/message-compiler": "9.8.0",
"@intlify/core-base": "9.8.0",
"@intlify/vue-router-bridge": "1.1.0",
"@intlify/vue-i18n-bridge": "1.1.0",
"vue-i18n-routing": "1.2.0"
"vue-tsc": "1.8.27",
"zx": "7.2.3"
}
}
7 changes: 6 additions & 1 deletion playground/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { fileURLToPath } from 'url';

export default defineNuxtConfig({
extends: ['nuxt-seo-kit'],
modules: ['nuxt-typed-router', '@nuxtjs/i18n', '@nuxt/content'],
Expand All @@ -8,7 +10,7 @@ export default defineNuxtConfig({
plugin: true,
pathCheck: true,
removeNuxtDefs: true,
ignoreRoutes: ['[...404].vue'],
ignoreRoutes: ['[...404].vue', 'ignoreFolder/**/*'],
},
content: {
documentDriven: false,
Expand All @@ -32,4 +34,7 @@ export default defineNuxtConfig({
},
],
},
alias: {
$$: fileURLToPath(new URL('../src', import.meta.url)),
},
});
8 changes: 2 additions & 6 deletions playground/src/components/TestLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@
<NuxtLink :to="props.to" :external="props.external"></NuxtLink>
</template>

<script
setup
lang="ts"
generic="T extends RoutesNamesList, P extends string, E extends boolean = false"
>
<script setup lang="ts" generic="R extends RoutesNamesList, E extends boolean = false">
import type { RoutesNamesList, NuxtRoute } from '@typed-router';

const props = defineProps<{
to: NuxtRoute<T, P, E>;
to: NuxtRoute<never, never, E>;
external?: E;
}>();
</script>
Expand Down
1 change: 1 addition & 0 deletions playground/src/pages/[lang]/post/[slug].vue
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<template><span>Foo</span></template>
18 changes: 12 additions & 6 deletions playground/src/pages/index.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<template>
<div>
<button @click="navigate"> Navigate button </button>
<nuxt-link :to="{ name: 'admin-id', params: { id: 1 } }">Navigate Link</nuxt-link>
<nuxt-link :to="localePath({ name: 'admin-444', params: { 444: 1 } })">Navigate Link</nuxt-link>
<!-- Should error -->
<nuxt-link to="/foo">Navigate Link</nuxt-link>

<nuxt-link to="/admin/888?foo">Navigate Link</nuxt-link>
<nuxt-link :to="localePath('/admin/888', 'en')">Navigate </nuxt-link>

<nuxt-link :to="{ name: 'admin-id', params: { id: 1 } }">Navigate Link</nuxt-link>
<nuxt-link :to="localePath({ name: 'user' })">Navigate Link</nuxt-link>
<nuxt-layout></nuxt-layout>

Expand All @@ -17,14 +16,19 @@
</template>

<script setup lang="ts">
import type { TypedRouteLocationRawFromName, helpers, TypedRouteLocation } from '@typed-router';
import type {
TypedLocalePathParameter,
helpers,
TypedRouteLocation,
TypedPathParameter,
NuxtRoute,
} from '@typed-router';
import TestLink from '~/components/TestLink.vue';
// definePageMeta({
// redirect: (route) => helpers.route({ name: 'admin-id', params: { id: 1 } }),
// });

definePageMeta({
name: 'foo-bar',
redirect: { name: 'admin-444', params: { '444': 1 } },
});

Expand All @@ -33,6 +37,8 @@ const router = useRouter();
const localePath = useLocalePath();
const localeRoute = useLocaleRoute();

console.log(localePath('/admin/888', 'en'));

// const route = localeRoute({ name: 'index___en', query: { foo: '1' } });
// if (route) {
// navigateTo(route.fullPath);
Expand Down Expand Up @@ -60,7 +66,7 @@ function navigate() {
router.push('/admin'); // Should error

const route = localePath(`/user/${u}/:slug/articles`);
router.push('/');
router.push('/admin/:fj');
navigateTo('ednzelfjle', { external: true });
const route4 = navigateTo('/test/:foo');
router.push({ path: '/' });
Expand Down
Loading
Loading