Skip to content

Commit 6f2a2af

Browse files
committed
chore: fix types
1 parent b5833f3 commit 6f2a2af

File tree

11 files changed

+77
-22
lines changed

11 files changed

+77
-22
lines changed

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
"dependencies": {
9393
"@docsearch/css": "^3.5.2",
9494
"@docsearch/js": "^3.5.2",
95+
"@types/markdown-it": "^13.0.1",
9596
"@vue/devtools-api": "^6.5.0",
9697
"@vueuse/core": "^10.4.1",
9798
"@vueuse/integrations": "^10.4.1",
@@ -135,7 +136,6 @@
135136
"@types/fs-extra": "^11.0.2",
136137
"@types/lodash.template": "^4.5.1",
137138
"@types/mark.js": "^8.11.8",
138-
"@types/markdown-it": "^13.0.1",
139139
"@types/markdown-it-attrs": "^4.1.0",
140140
"@types/markdown-it-container": "^2.0.6",
141141
"@types/markdown-it-emoji": "^2.0.2",

Diff for: pnpm-lock.yaml

+3-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: src/node/contentLoader.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import glob from 'fast-glob'
44
import type { SiteConfig } from './config'
55
import matter from 'gray-matter'
66
import { normalizePath } from 'vite'
7-
import { createMarkdownRenderer, type MarkdownRenderer } from './markdown'
7+
import {
8+
createMarkdownRenderer,
9+
type MarkdownRenderer
10+
} from './markdown/markdown'
811

912
export interface ContentOptions<T = ContentData[]> {
1013
/**

Diff for: src/node/index.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
export * from './config'
2-
export * from './server'
3-
export * from './markdown'
1+
export { loadEnv, type Plugin } from 'vite'
42
export * from './build/build'
5-
export * from './serve/serve'
6-
export * from './init/init'
3+
export * from './config'
74
export * from './contentLoader'
8-
export * from './postcss'
5+
export * from './init/init'
6+
export * from './markdown/markdown'
97
export { defineLoader, type LoaderModule } from './plugins/staticDataPlugin'
10-
export { loadEnv, type Plugin } from 'vite'
8+
export * from './postcss/isolateStyles'
9+
export * from './serve/serve'
10+
export * from './server'
1111

1212
// shared types
1313
export type {
14-
SiteData,
14+
DefaultTheme,
1515
HeadConfig,
1616
Header,
17-
DefaultTheme
17+
SiteData
1818
} from '../../types/shared'
File renamed without changes.

Diff for: src/node/markdown/plugins/highlight.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
type Processor
1818
} from 'shiki-processor'
1919
import type { Logger } from 'vite'
20-
import type { ThemeOptions } from '..'
20+
import type { ThemeOptions } from '../markdown'
2121

2222
const nanoid = customAlphabet('abcdefghijklmnopqrstuvwxyz', 10)
2323

Diff for: src/node/markdownToVue.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
createMarkdownRenderer,
99
type MarkdownOptions,
1010
type MarkdownRenderer
11-
} from './markdown'
11+
} from './markdown/markdown'
1212
import {
1313
EXTERNAL_URL_RE,
1414
slash,

Diff for: src/node/plugins/localSearchPlugin.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import MiniSearch from 'minisearch'
44
import path from 'path'
55
import type { Plugin, ViteDevServer } from 'vite'
66
import type { SiteConfig } from '../config'
7-
import { createMarkdownRenderer } from '../markdown'
7+
import { createMarkdownRenderer } from '../markdown/markdown'
88
import {
99
resolveSiteDataByRoute,
1010
slash,
File renamed without changes.

Diff for: src/node/siteConfig.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { UseDarkOptions } from '@vueuse/core'
33
import type { SitemapStreamOptions } from 'sitemap'
44
import type { Logger, UserConfig as ViteConfig } from 'vite'
55
import type { SitemapItem } from './build/generateSitemap'
6-
import type { MarkdownOptions } from './markdown'
6+
import type { MarkdownOptions } from './markdown/markdown'
77
import type {
88
Awaitable,
99
HeadConfig,

Diff for: types/shared.d.ts

+56-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// types shared between server and client
2-
import type { MarkdownSfcBlocks } from '@mdit-vue/plugin-sfc'
32
import type { UseDarkOptions } from '@vueuse/core'
43
import type { SSRContext } from 'vue/server-renderer'
54
export type { DefaultTheme } from './default-theme.js'
@@ -19,6 +18,62 @@ export interface PageData {
1918
lastUpdated?: number
2019
}
2120

21+
/**
22+
* SFC block extracted from markdown
23+
*/
24+
export interface SfcBlock {
25+
/**
26+
* The type of the block
27+
*/
28+
type: string
29+
/**
30+
* The content, including open-tag and close-tag
31+
*/
32+
content: string
33+
/**
34+
* The content that stripped open-tag and close-tag off
35+
*/
36+
contentStripped: string
37+
/**
38+
* The open-tag
39+
*/
40+
tagOpen: string
41+
/**
42+
* The close-tag
43+
*/
44+
tagClose: string
45+
}
46+
47+
export interface MarkdownSfcBlocks {
48+
/**
49+
* The `<template>` block
50+
*/
51+
template: SfcBlock | null
52+
/**
53+
* The common `<script>` block
54+
*/
55+
script: SfcBlock | null
56+
/**
57+
* The `<script setup>` block
58+
*/
59+
scriptSetup: SfcBlock | null
60+
/**
61+
* All `<script>` blocks.
62+
*
63+
* By default, SFC only allows one `<script>` block and one `<script setup>` block.
64+
* However, some tools may support different types of `<script>`s, so we keep all of them here.
65+
*/
66+
scripts: SfcBlock[]
67+
/**
68+
* All `<style>` blocks.
69+
*/
70+
styles: SfcBlock[]
71+
/**
72+
* All custom blocks.
73+
*/
74+
customBlocks: SfcBlock[]
75+
}
76+
2277
export interface Header {
2378
/**
2479
* The level of the header

0 commit comments

Comments
 (0)