Skip to content

Commit 061192c

Browse files
committed
fix: update types and imports
1 parent d255c89 commit 061192c

File tree

21 files changed

+31
-27
lines changed

21 files changed

+31
-27
lines changed

docs/app.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ const { data: files } = useLazyFetch('/api/search.json', {
3535
const { data: nav } = await useAsyncData('navigation', () => fetchContentNavigation())
3636
3737
const navigation = computed(() => {
38-
const main = nav.value.filter(item => item._path !== '/v1')
39-
const v1 = nav.value.find(item => item._path === '/v1')?.children
38+
const main = nav.value?.filter(item => item._path !== '/v1')
39+
const v1 = nav.value?.find(item => item._path === '/v1')?.children
4040
4141
return route.path.startsWith('/v1/') ? v1 : main
4242
})
@@ -81,7 +81,7 @@ provide('navigation', navigation)
8181
<!-- Mobile panel -->
8282
<template v-if="$route.path !== '/'" #panel>
8383
<LazyUDocsSearchButton size="md" class="mb-4 w-full" />
84-
<LazyUNavigationTree :links="mapContentNavigation(navigation)" default-open :multiple="false" />
84+
<LazyUNavigationTree :links="mapContentNavigation(navigation!)" default-open :multiple="false" />
8585
</template>
8686
</UHeader>
8787

docs/editor/Monaco.vue

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script setup lang="ts">
2+
// @ts-nocheck
23
const emit = defineEmits<(e: 'change', content: string) => void>()
34
const editorState = ref('loading')
45
const props = defineProps<{ language: string; value: string, readOnly: boolean }>()

docs/editor/useMonacoEditor.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { watch, Ref, unref, ref } from 'vue'
1+
// @ts-nocheck
2+
import { watch, type Ref, unref, ref } from 'vue'
23
import type { editor as Editor } from 'monaco-editor-core'
34
import { createSingletonPromise } from '@vueuse/core'
45
import { language as mdcLanguage } from '@nuxtlabs/monarch-mdc'

playground/document-driven/components/content/ShowArticle.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts" setup>
2-
import { ParsedArticle } from '../../types/article'
2+
import type { ParsedArticle } from '../../types/article'
33
44
const { data } = await useAsyncData('key', () => queryContent('data').findOne())
55

playground/document-driven/types/article.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ParsedContent } from '../../../src/runtime/types'
1+
import type { ParsedContent } from '../../../src/runtime/types'
22

33
export interface ParsedArticle extends ParsedContent {
44
cover: {

src/runtime/composables/client-db.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { createQuery } from '../query/query'
77
import type { NavItem, ParsedContent, ParsedContentMeta } from '../types'
88
import { createNav } from '../server/navigation'
99
import { createPipelineFetcher } from '../query/match/pipeline'
10-
import { ContentQueryBuilderParams } from '../types/query'
10+
import type { ContentQueryBuilderParams } from '../types/query'
1111
import { useContentPreview } from './preview'
1212

1313
const withContentBase = (url: string) => withBase(url, useRuntimeConfig().public.content.api.baseURL)

src/runtime/composables/navigation.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useRuntimeConfig } from '#app'
33
import type { NavItem, QueryBuilder, QueryBuilderParams } from '../types'
44
import { encodeQueryParams } from '../utils/query'
55
import { jsonStringify } from '../utils/json'
6-
import { ContentQueryBuilder } from '../types/query'
6+
import type { ContentQueryBuilder } from '../types/query'
77
import { addPrerenderPath, shouldUseClientDB, withContentBase } from './utils'
88
import { queryContent } from './query'
99
import { useContentPreview } from './preview'

src/runtime/composables/query.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { createQuery } from '../query/query'
55
import type { ParsedContent } from '../types'
66
import { encodeQueryParams } from '../utils/query'
77
import { jsonStringify } from '../utils/json'
8-
import { ContentQueryBuilder, ContentQueryBuilderParams } from '../types/query'
8+
import type { ContentQueryBuilder, ContentQueryBuilderParams } from '../types/query'
99
import { addPrerenderPath, shouldUseClientDB, withContentBase } from './utils'
1010
import { useContentPreview } from './preview'
1111

src/runtime/legacy/composables/client-db.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { createQuery } from '../../query/query'
88
import type { NavItem, ParsedContent, ParsedContentMeta, QueryBuilderParams } from '../../types'
99
import { createNav } from '../../server/navigation'
1010
import { useContentPreview } from '../../composables/preview'
11-
import { ContentQueryBuilderParams, ContentQueryFetcher } from '../../types/query'
11+
import type { ContentQueryBuilderParams, ContentQueryFetcher } from '../../types/query'
1212

1313
const withContentBase = (url: string) => withBase(url, useRuntimeConfig().public.content.api.baseURL)
1414

src/runtime/legacy/composables/navigation.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useRuntimeConfig } from '#app'
33
import type { NavItem, QueryBuilder, QueryBuilderParams } from '../../types'
44
import { encodeQueryParams } from '../../utils/query'
55
import { jsonStringify } from '../../utils/json'
6-
import { ContentQueryBuilder } from '../../types/query'
6+
import type { ContentQueryBuilder } from '../../types/query'
77
import { addPrerenderPath, shouldUseClientDB, withContentBase } from '../../composables/utils'
88
import { useContentPreview } from '../../composables/preview'
99
import { queryContent } from './query'

src/runtime/pages/document-driven.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script setup lang="ts">
22
import { useRuntimeConfig } from '#app'
3+
import type { LayoutKey } from '#build/types/layouts'
34
import { useContent, useContentHead, useRequestEvent } from '#imports'
45
56
const { contentHead } = useRuntimeConfig().public.content
@@ -18,7 +19,7 @@ if (contentHead) {
1819

1920
<template>
2021
<div class="document-driven-page">
21-
<NuxtLayout :name="layout as string || 'default'">
22+
<NuxtLayout :name="layout as LayoutKey || 'default'">
2223
<ContentRenderer v-if="page" :key="(page as any)._id" :value="page">
2324
<template #empty="{ value }">
2425
<DocumentDrivenEmpty :value="value" />

src/runtime/query/match/utils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ export const withKeys = (keys: string[] = []) => (obj: any) => {
6060
export const sortList = (data: any[], params: SortOptions) => {
6161
const comperable = new Intl.Collator(params.$locale as string, {
6262
numeric: params.$numeric as boolean,
63-
caseFirst: params.$caseFirst as string,
64-
sensitivity: params.$sensitivity as string
63+
caseFirst: params.$caseFirst as any,
64+
sensitivity: params.$sensitivity as any
6565
})
6666
const keys = Object.keys(params).filter(key => !key.startsWith('$'))
6767
for (const key of keys) {

src/runtime/server/api/navigation.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { defineEventHandler } from 'h3'
22
import { cacheStorage, serverQueryContent } from '../storage'
33
import { createNav } from '../navigation'
4-
import { ParsedContent, ParsedContentMeta } from '../../types'
4+
import type { ParsedContent, ParsedContentMeta } from '../../types'
55
import { getContentQuery } from '../../utils/query'
66
import { isPreview } from '../preview'
77

src/runtime/server/navigation.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { NavItem, ParsedContentMeta } from '../types'
1+
import type { NavItem, ParsedContentMeta } from '../types'
22
import { generateTitle } from '../transformers/path-meta'
33
import { useRuntimeConfig } from '#imports'
44

src/runtime/server/search.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { H3Event } from 'h3'
2-
import { ParsedContent, QueryBuilderWhere } from '../types'
2+
import type { ParsedContent, QueryBuilderWhere } from '../types'
33
import { serverQueryContent } from '#content/server'
44

55
export async function serverSearchContent (event: H3Event, filterQuery?: QueryBuilderWhere): Promise<ParsedContent[]> {
@@ -41,8 +41,9 @@ export function splitPageIntoSections (page: ParsedContent, { ignoredTags }: { i
4141
let previousHeadingLevel = 0
4242
const titles = []
4343
for (const item of page.body.children) {
44-
if (isHeading(item.tag)) {
45-
const currentHeadingLevel: number = Number(item.tag.match(HEADING)?.[1]) ?? 0
44+
const tag = item.tag || ''
45+
if (isHeading(tag)) {
46+
const currentHeadingLevel: number = Number(tag.match(HEADING)?.[1]) ?? 0
4647

4748
const title = extractTextFromAst(item).trim()
4849

@@ -58,7 +59,7 @@ export function splitPageIntoSections (page: ParsedContent, { ignoredTags }: { i
5859
}
5960

6061
sections.push({
61-
id: `${path}#${item.props.id}`,
62+
id: `${path}#${item.props?.id}`,
6263
title,
6364
titles: [...titles],
6465
content: '',
@@ -72,7 +73,7 @@ export function splitPageIntoSections (page: ParsedContent, { ignoredTags }: { i
7273
section += 1
7374
}
7475

75-
if (!isHeading(item.tag)) {
76+
if (!isHeading(tag)) {
7677
if (!sections[section]) {
7778
sections[section] = {
7879
id: '',

src/runtime/server/storage.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { transformContent } from '../transformers'
1010
import { makeIgnored } from '../utils/config'
1111
import type { ModuleOptions } from '../../module'
1212
import { createPipelineFetcher } from '../query/match/pipeline'
13-
import { ContentQueryBuilder, ContentQueryBuilderParams } from '../types/query'
13+
import type { ContentQueryBuilder, ContentQueryBuilderParams } from '../types/query'
1414
import { getPreview, isPreview } from './preview'
1515
import { getIndexedContentsList } from './content-index'
1616
// @ts-ignore

src/runtime/transformers/component-resolver.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { pascalCase } from 'scule'
2-
import { ParsedContent } from '../types'
2+
import type { ParsedContent } from '../types'
33
import htmlTags from '../utils/html-tags'
44
import { defineTransformer } from './utils'
55

src/runtime/transformers/path-meta.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { pascalCase } from 'scule'
22
import slugify from 'slugify'
33
import { withoutTrailingSlash, withLeadingSlash } from 'ufo'
4-
import { ParsedContent } from '../types'
4+
import type { ParsedContent } from '../types'
55
import { defineTransformer } from './utils'
66

77
const SEMVER_REGEX = /^(\d+)(\.\d+)*(\.x)?$/

src/runtime/transformers/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ContentTransformer } from '../types'
1+
import type { ContentTransformer } from '../types'
22

33
export const defineTransformer = (transformer: ContentTransformer) => {
44
return transformer

src/runtime/transformers/yaml.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { parseFrontMatter } from 'remark-mdc'
2-
import { ParsedContent } from '../types'
2+
import type { ParsedContent } from '../types'
33
import { defineTransformer } from './utils'
44

55
export default defineTransformer({

src/runtime/types/index.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export interface ParsedContent extends ParsedContentMeta {
6262
/**
6363
* Content body
6464
*/
65-
body: MarkdownRoot
65+
body: MarkdownRoot | null
6666
}
6767

6868
//

0 commit comments

Comments
 (0)