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

fix: types #1912

Merged
merged 4 commits into from
Feb 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/components/content/ReadMore.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const props = defineProps({
}
})

const createTitle = (title?: string, link: string) => (title || link.split('/').filter(Boolean).map(part => splitByCase(part).map(p => upperFirst(p)).join(' ')).join(' > ').replace('Api', 'API'))
const createTitle = (title: string | undefined, link: string) => (title || link.split('/').filter(Boolean).map(part => splitByCase(part).map(p => upperFirst(p)).join(' ')).join(' > ').replace('Api', 'API'))

const computedTitle = computed(() => createTitle(props.title, props.link))
</script>
6 changes: 5 additions & 1 deletion docs/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ export default defineNuxtConfig({
},
runtimeConfig: {
content: {
host: 'https://content.nuxtjs.org'
// @ts-ignore
// TODO: fix types
documentDriven: {
host: 'https://content.nuxtjs.org'
}
},
public: {
algolia: {
Expand Down
3 changes: 2 additions & 1 deletion examples/advanced/transformer/my-module/my-transformer.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// @ts-ignore
import { defineTransformer } from '@nuxt/content/transformers'

export default defineTransformer({
name: 'my-transformer',
extensions: ['.names'],
parse (_id, rawContent) {
parse (_id: string, rawContent: string) {
return {
_id,
body: rawContent.trim().split('\n').map(line => line.trim()).sort()
Expand Down
1 change: 1 addition & 0 deletions examples/advanced/transformer/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import MyModule from './my-module/my-module'

export default defineNuxtConfig({
modules: [
// @ts-ignore
MyModule,
'@nuxt/content'
]
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"@nuxt/schema": "3.1.2",
"@nuxt/test-utils": "3.1.2",
"@nuxtjs/eslint-config-typescript": "latest",
"@types/mdurl": "^1.0.2",
"@types/ws": "^8.5.4",
"c8": "^7.12.0",
"csvtojson": "^2.0.10",
Expand Down
1 change: 1 addition & 0 deletions playground/document-driven/components/content/Debug.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
</template>

<script setup lang="ts">
// @ts-ignore
import { useContent, useTheme } from '#imports'

const { globals, surround, page, navigation } = useContent()
Expand Down
2 changes: 1 addition & 1 deletion playground/document-driven/components/content/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { flatUnwrap } = useUnwrap()

<template>
<ul>
<li v-for="(item, index) of flatUnwrap($slots.default(), ['ul'])" :key="index">
<li v-for="(item, index) of flatUnwrap($slots.default!(), ['ul'])" :key="index">
β˜‘οΈŽ
<span><ContentSlot :use="() => item" unwrap="li" /></span>
</li>
Expand Down
4 changes: 2 additions & 2 deletions playground/document-driven/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ export default defineNuxtConfig({
documentDriven: {
globals: {
theme: {
where: {
where: [{
_id: 'content:_theme.yml'
},
}],
without: ['_']
}
},
Expand Down
5 changes: 4 additions & 1 deletion playground/navigation/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import contentModule from '../../src/module'

export default defineNuxtConfig({
modules: [contentModule],
modules: [
// @ts-ignore
contentModule
],
content: {
documentDriven: true
}
Expand Down
4 changes: 2 additions & 2 deletions playground/shared/components/PagePrevNext.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div style="display: flex; align-items: center; justify-content: space-between;">
<div v-if="prevNext[0]">
<div v-if="prevNext?.[0]">
<NuxtLink :to="prevNext[0]._path">
{{ prevNext[0].title }}
</NuxtLink>
Expand All @@ -9,7 +9,7 @@
No previous page!
</div>

<div v-if="prevNext[1]">
<div v-if="prevNext?.[1]">
<NuxtLink :to="prevNext[1]._path">
{{ prevNext[1].title }}
</NuxtLink>
Expand Down
16 changes: 6 additions & 10 deletions playground/shared/components/QueryPlayground.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,23 @@
import { ref, useAsyncData, queryContent } from '#imports'

const query = ref({
where: {
where: [{
_partial: false
},
sort: {
_path: 1
},
only: [],
}],
without: ['body', 'excerpt'],
skip: 0,
limit: 10
})

const qs = ref(JSON.stringify(query.value, null, 2, ''))
const qs = ref(JSON.stringify(query.value, null, 2))
const parseError = ref(null)
const textarea = ref(null)

watch(qs, (value) => {
try {
query.value = JSON.parse(value)
parseError.value = null
} catch (e) {
} catch (e: any) {
parseError.value = e.message
}
})
Expand All @@ -31,7 +27,7 @@ const { data: docs } = await useAsyncData('query', () => {
return queryContent(query.value).find()
}, { watch: [query] })

const tabber = (event) => {
const tabber = (event: any) => {
const originalSelectionStart = event.target.selectionStart
const startText = qs.value.slice(0, event.target.selectionStart)
const endText = qs.value.slice(event.target.selectionStart)
Expand All @@ -42,7 +38,7 @@ const tabber = (event) => {
})
}

const enterer = (event) => {
const enterer = (event: any) => {
const originalSelectionStart = event.target.selectionStart
const startText = qs.value.slice(0, event.target.selectionStart)
const endText = qs.value.slice(event.target.selectionStart)
Expand Down
5 changes: 4 additions & 1 deletion playground/shared/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ export default defineNuxtConfig({
path: resolveThemeDir('./components/content')
}
],
modules: [contentModule],
modules: [
// @ts-ignore
contentModule
],
content: {
navigation: {
fields: ['icon']
Expand Down