Skip to content

Commit

Permalink
chore: upgrade to nuxt rc9 (#1498)
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz committed Sep 7, 2022
1 parent 5167a6c commit 96e1e60
Show file tree
Hide file tree
Showing 6 changed files with 647 additions and 745 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"test:unit": "nuxi prepare test/fixtures/basic && nuxi prepare test/fixtures/document-driven && vitest run"
},
"dependencies": {
"@nuxt/kit": "^3.0.0-rc.8",
"@nuxt/kit": "^3.0.0-rc.9",
"consola": "^2.15.3",
"defu": "^6.1.0",
"destr": "^1.1.1",
Expand Down Expand Up @@ -80,8 +80,8 @@
},
"devDependencies": {
"@nuxt/module-builder": "^0.1.7",
"@nuxt/schema": "^3.0.0-rc.8",
"@nuxt/test-utils": "npm:@nuxt/test-utils-edge@latest",
"@nuxt/schema": "^3.0.0-rc.9",
"@nuxt/test-utils": "^3.0.0-rc.9",
"@nuxthq/admin": "npm:@nuxthq/admin-edge@latest",
"@nuxtjs/eslint-config-typescript": "latest",
"@types/ws": "^8.5.3",
Expand All @@ -92,7 +92,7 @@
"husky": "^8.0.1",
"jiti": "^1.14.0",
"lint-staged": "^13.0.3",
"nuxt": "npm:nuxt3@latest",
"nuxt": "^3.0.0-rc.9",
"rehype-figure": "^1.0.1",
"remark-oembed": "^1.2.2",
"vitest": "^0.22.1",
Expand Down
6 changes: 3 additions & 3 deletions playground/shared/components/NavItem.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<script setup lang="ts">
const { navItem } = defineProps<{
const props = defineProps<{
navItem: any
}>()
const icon = computed(() => {
if (navItem.icon) { return navItem.icon }
if (navItem.children && navItem.children.length) { return '📁' }
if (props.navItem.icon) { return props.navItem.icon }
if (props.navItem.children && props.navItem.children.length) { return '📁' }
return '📄'
})
</script>
Expand Down
16 changes: 8 additions & 8 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
defineNuxtModule,
resolveModule,
createResolver,
addAutoImport,
addImports,
addComponentsDir,
addTemplate
} from '@nuxt/kit'
Expand Down Expand Up @@ -331,7 +331,7 @@ export default defineNuxtModule<ModuleOptions>({
})

// Register composables
addAutoImport([
addImports([
{ name: 'queryContent', as: 'queryContent', from: resolveRuntimeModule('./composables/query') },
{ name: 'useContentHelpers', as: 'useContentHelpers', from: resolveRuntimeModule('./composables/helpers') },
{ name: 'useContentHead', as: 'useContentHead', from: resolveRuntimeModule('./composables/head') },
Expand All @@ -348,18 +348,18 @@ export default defineNuxtModule<ModuleOptions>({
global: true
})

addTemplate({
const typesPath = addTemplate({
filename: 'types/content.d.ts',
getContents: () => [
'declare module \'#content/server\' {',
` const serverQueryContent: typeof import('${resolve('./runtime/server')}').serverQueryContent`,
` const parseContent: typeof import('${resolve('./runtime/server')}').parseContent`,
'}'
].join('\n')
})
}).dst

nuxt.hook('prepare:types', (options) => {
options.references.push({ path: resolve(nuxt.options.buildDir, 'types/content.d.ts') })
options.references.push({ path: typesPath })
})

// Register user global components
Expand Down Expand Up @@ -393,7 +393,7 @@ export default defineNuxtModule<ModuleOptions>({

// Register navigation
if (options.navigation) {
addAutoImport({ name: 'fetchContentNavigation', as: 'fetchContentNavigation', from: resolveRuntimeModule('./composables/navigation') })
addImports({ name: 'fetchContentNavigation', as: 'fetchContentNavigation', from: resolveRuntimeModule('./composables/navigation') })

nuxt.hook('nitro:config', (nitroConfig) => {
nitroConfig.handlers = nitroConfig.handlers || []
Expand Down Expand Up @@ -453,7 +453,7 @@ export default defineNuxtModule<ModuleOptions>({
options.navigation.fields.push('layout')
}

addAutoImport([
addImports([
{ name: 'useContentState', as: 'useContentState', from: resolveRuntimeModule('./composables/content') },
{ name: 'useContent', as: 'useContent', from: resolveRuntimeModule('./composables/content') }
])
Expand Down Expand Up @@ -490,7 +490,7 @@ export default defineNuxtModule<ModuleOptions>({
}
} else {
// Noop useContent
addAutoImport([
addImports([
{ name: 'useContentDisabled', as: 'useContentState', from: resolveRuntimeModule('./composables/utils') },
{ name: 'useContentDisabled', as: 'useContent', from: resolveRuntimeModule('./composables/utils') }
])
Expand Down
8 changes: 0 additions & 8 deletions src/runtime/index.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/runtime/utils/query.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useQuery, CompatibilityEvent, createError } from 'h3'
import { getQuery, CompatibilityEvent, createError } from 'h3'
import { QueryBuilderParams } from '../types'
import { jsonParse } from './json'

Expand All @@ -13,7 +13,7 @@ const parseQueryParams = (body: string) => {
const memory = {}
export const getContentQuery = (event: CompatibilityEvent): QueryBuilderParams => {
const qid = event.context.params.qid?.replace(/.json$/, '')
const query: any = useQuery(event) || {}
const query: any = getQuery(event) || {}

// Using /api/_content/query/:qid?_params=....
if (qid && query._params) {
Expand Down
Loading

0 comments on commit 96e1e60

Please sign in to comment.