Skip to content

Commit

Permalink
fix: update types and imports
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz committed Oct 27, 2023
1 parent d255c89 commit 061192c
Show file tree
Hide file tree
Showing 21 changed files with 31 additions and 27 deletions.
6 changes: 3 additions & 3 deletions docs/app.vue
Expand Up @@ -35,8 +35,8 @@ const { data: files } = useLazyFetch('/api/search.json', {
const { data: nav } = await useAsyncData('navigation', () => fetchContentNavigation())
const navigation = computed(() => {
const main = nav.value.filter(item => item._path !== '/v1')
const v1 = nav.value.find(item => item._path === '/v1')?.children
const main = nav.value?.filter(item => item._path !== '/v1')
const v1 = nav.value?.find(item => item._path === '/v1')?.children
return route.path.startsWith('/v1/') ? v1 : main
})
Expand Down Expand Up @@ -81,7 +81,7 @@ provide('navigation', navigation)
<!-- Mobile panel -->
<template v-if="$route.path !== '/'" #panel>
<LazyUDocsSearchButton size="md" class="mb-4 w-full" />
<LazyUNavigationTree :links="mapContentNavigation(navigation)" default-open :multiple="false" />
<LazyUNavigationTree :links="mapContentNavigation(navigation!)" default-open :multiple="false" />
</template>
</UHeader>

Expand Down
1 change: 1 addition & 0 deletions docs/editor/Monaco.vue
@@ -1,4 +1,5 @@
<script setup lang="ts">
// @ts-nocheck
const emit = defineEmits<(e: 'change', content: string) => void>()
const editorState = ref('loading')
const props = defineProps<{ language: string; value: string, readOnly: boolean }>()
Expand Down
3 changes: 2 additions & 1 deletion docs/editor/useMonacoEditor.ts
@@ -1,4 +1,5 @@
import { watch, Ref, unref, ref } from 'vue'
// @ts-nocheck
import { watch, type Ref, unref, ref } from 'vue'
import type { editor as Editor } from 'monaco-editor-core'
import { createSingletonPromise } from '@vueuse/core'
import { language as mdcLanguage } from '@nuxtlabs/monarch-mdc'
Expand Down
@@ -1,5 +1,5 @@
<script lang="ts" setup>
import { ParsedArticle } from '../../types/article'
import type { ParsedArticle } from '../../types/article'
const { data } = await useAsyncData('key', () => queryContent('data').findOne())
Expand Down
2 changes: 1 addition & 1 deletion playground/document-driven/types/article.ts
@@ -1,4 +1,4 @@
import { ParsedContent } from '../../../src/runtime/types'
import type { ParsedContent } from '../../../src/runtime/types'

export interface ParsedArticle extends ParsedContent {
cover: {
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/composables/client-db.ts
Expand Up @@ -7,7 +7,7 @@ import { createQuery } from '../query/query'
import type { NavItem, ParsedContent, ParsedContentMeta } from '../types'
import { createNav } from '../server/navigation'
import { createPipelineFetcher } from '../query/match/pipeline'
import { ContentQueryBuilderParams } from '../types/query'
import type { ContentQueryBuilderParams } from '../types/query'
import { useContentPreview } from './preview'

const withContentBase = (url: string) => withBase(url, useRuntimeConfig().public.content.api.baseURL)
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/composables/navigation.ts
Expand Up @@ -3,7 +3,7 @@ import { useRuntimeConfig } from '#app'
import type { NavItem, QueryBuilder, QueryBuilderParams } from '../types'
import { encodeQueryParams } from '../utils/query'
import { jsonStringify } from '../utils/json'
import { ContentQueryBuilder } from '../types/query'
import type { ContentQueryBuilder } from '../types/query'
import { addPrerenderPath, shouldUseClientDB, withContentBase } from './utils'
import { queryContent } from './query'
import { useContentPreview } from './preview'
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/composables/query.ts
Expand Up @@ -5,7 +5,7 @@ import { createQuery } from '../query/query'
import type { ParsedContent } from '../types'
import { encodeQueryParams } from '../utils/query'
import { jsonStringify } from '../utils/json'
import { ContentQueryBuilder, ContentQueryBuilderParams } from '../types/query'
import type { ContentQueryBuilder, ContentQueryBuilderParams } from '../types/query'
import { addPrerenderPath, shouldUseClientDB, withContentBase } from './utils'
import { useContentPreview } from './preview'

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/legacy/composables/client-db.ts
Expand Up @@ -8,7 +8,7 @@ import { createQuery } from '../../query/query'
import type { NavItem, ParsedContent, ParsedContentMeta, QueryBuilderParams } from '../../types'
import { createNav } from '../../server/navigation'
import { useContentPreview } from '../../composables/preview'
import { ContentQueryBuilderParams, ContentQueryFetcher } from '../../types/query'
import type { ContentQueryBuilderParams, ContentQueryFetcher } from '../../types/query'

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

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/legacy/composables/navigation.ts
Expand Up @@ -3,7 +3,7 @@ import { useRuntimeConfig } from '#app'
import type { NavItem, QueryBuilder, QueryBuilderParams } from '../../types'
import { encodeQueryParams } from '../../utils/query'
import { jsonStringify } from '../../utils/json'
import { ContentQueryBuilder } from '../../types/query'
import type { ContentQueryBuilder } from '../../types/query'
import { addPrerenderPath, shouldUseClientDB, withContentBase } from '../../composables/utils'
import { useContentPreview } from '../../composables/preview'
import { queryContent } from './query'
Expand Down
3 changes: 2 additions & 1 deletion src/runtime/pages/document-driven.vue
@@ -1,5 +1,6 @@
<script setup lang="ts">
import { useRuntimeConfig } from '#app'
import type { LayoutKey } from '#build/types/layouts'
import { useContent, useContentHead, useRequestEvent } from '#imports'
const { contentHead } = useRuntimeConfig().public.content
Expand All @@ -18,7 +19,7 @@ if (contentHead) {

<template>
<div class="document-driven-page">
<NuxtLayout :name="layout as string || 'default'">
<NuxtLayout :name="layout as LayoutKey || 'default'">
<ContentRenderer v-if="page" :key="(page as any)._id" :value="page">
<template #empty="{ value }">
<DocumentDrivenEmpty :value="value" />
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/query/match/utils.ts
Expand Up @@ -60,8 +60,8 @@ export const withKeys = (keys: string[] = []) => (obj: any) => {
export const sortList = (data: any[], params: SortOptions) => {
const comperable = new Intl.Collator(params.$locale as string, {
numeric: params.$numeric as boolean,
caseFirst: params.$caseFirst as string,
sensitivity: params.$sensitivity as string
caseFirst: params.$caseFirst as any,
sensitivity: params.$sensitivity as any
})
const keys = Object.keys(params).filter(key => !key.startsWith('$'))
for (const key of keys) {
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/server/api/navigation.ts
@@ -1,7 +1,7 @@
import { defineEventHandler } from 'h3'
import { cacheStorage, serverQueryContent } from '../storage'
import { createNav } from '../navigation'
import { ParsedContent, ParsedContentMeta } from '../../types'
import type { ParsedContent, ParsedContentMeta } from '../../types'
import { getContentQuery } from '../../utils/query'
import { isPreview } from '../preview'

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/server/navigation.ts
@@ -1,4 +1,4 @@
import { NavItem, ParsedContentMeta } from '../types'
import type { NavItem, ParsedContentMeta } from '../types'
import { generateTitle } from '../transformers/path-meta'
import { useRuntimeConfig } from '#imports'

Expand Down
11 changes: 6 additions & 5 deletions src/runtime/server/search.ts
@@ -1,5 +1,5 @@
import { H3Event } from 'h3'
import { ParsedContent, QueryBuilderWhere } from '../types'
import type { ParsedContent, QueryBuilderWhere } from '../types'
import { serverQueryContent } from '#content/server'

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

const title = extractTextFromAst(item).trim()

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

sections.push({
id: `${path}#${item.props.id}`,
id: `${path}#${item.props?.id}`,
title,
titles: [...titles],
content: '',
Expand All @@ -72,7 +73,7 @@ export function splitPageIntoSections (page: ParsedContent, { ignoredTags }: { i
section += 1
}

if (!isHeading(item.tag)) {
if (!isHeading(tag)) {
if (!sections[section]) {
sections[section] = {
id: '',
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/server/storage.ts
Expand Up @@ -10,7 +10,7 @@ import { transformContent } from '../transformers'
import { makeIgnored } from '../utils/config'
import type { ModuleOptions } from '../../module'
import { createPipelineFetcher } from '../query/match/pipeline'
import { ContentQueryBuilder, ContentQueryBuilderParams } from '../types/query'
import type { ContentQueryBuilder, ContentQueryBuilderParams } from '../types/query'
import { getPreview, isPreview } from './preview'
import { getIndexedContentsList } from './content-index'
// @ts-ignore
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/transformers/component-resolver.ts
@@ -1,5 +1,5 @@
import { pascalCase } from 'scule'
import { ParsedContent } from '../types'
import type { ParsedContent } from '../types'
import htmlTags from '../utils/html-tags'
import { defineTransformer } from './utils'

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/transformers/path-meta.ts
@@ -1,7 +1,7 @@
import { pascalCase } from 'scule'
import slugify from 'slugify'
import { withoutTrailingSlash, withLeadingSlash } from 'ufo'
import { ParsedContent } from '../types'
import type { ParsedContent } from '../types'
import { defineTransformer } from './utils'

const SEMVER_REGEX = /^(\d+)(\.\d+)*(\.x)?$/
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/transformers/utils.ts
@@ -1,4 +1,4 @@
import { ContentTransformer } from '../types'
import type { ContentTransformer } from '../types'

export const defineTransformer = (transformer: ContentTransformer) => {
return transformer
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/transformers/yaml.ts
@@ -1,5 +1,5 @@
import { parseFrontMatter } from 'remark-mdc'
import { ParsedContent } from '../types'
import type { ParsedContent } from '../types'
import { defineTransformer } from './utils'

export default defineTransformer({
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/types/index.d.ts
Expand Up @@ -62,7 +62,7 @@ export interface ParsedContent extends ParsedContentMeta {
/**
* Content body
*/
body: MarkdownRoot
body: MarkdownRoot | null
}

//
Expand Down

0 comments on commit 061192c

Please sign in to comment.