feat: add web-types.json for JetBrains IDE support

dist/web-types.json is generated at build time so its version stays in
sync with the package.

closes #5157

Co-authored-by: Joaquín Sánchez <userquin@gmail.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
pull/5340/head
Divyansh Singh 1 month ago
parent 8ff1f3e2dd
commit 1d448c9fc1

@ -37,6 +37,7 @@
},
"main": "dist/node/index.js",
"types": "types/index.d.ts",
"web-types": "./dist/web-types.json",
"bin": {
"vitepress": "bin/vitepress.js"
},
@ -58,7 +59,7 @@
"dev:node": "DEV=true pnpm build:node -w",
"dev:shared": "node scripts/copyShared.ts",
"dev:watch": "node scripts/watchAndCopy.ts",
"build": "pnpm build:prepare && pnpm build:client && pnpm build:node",
"build": "pnpm build:prepare && pnpm build:client && pnpm build:node && node scripts/genWebTypes.ts",
"build:prepare": "pnpm clean && node scripts/copyShared.ts",
"build:client": "vue-tsc --noEmit -p src/client && tsc -p src/client && node scripts/copyClient.ts",
"build:node": "tsc -p src/node --noEmit && rollup --config rollup.config.ts --configPlugin esbuild",

@ -0,0 +1,78 @@
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'
const { version } = JSON.parse(readFileSync('package.json', 'utf-8'))
const webTypes = {
$schema: 'http://json.schemastore.org/web-types',
framework: 'vue',
name: 'vitepress',
version,
'js-types-syntax': 'typescript',
'description-markup': 'markdown',
contributions: {
html: {
'vue-components': [
{
name: 'Content',
source: { symbol: 'Content' },
description:
'Displays the rendered markdown contents. Useful when creating your own theme.',
'doc-url': 'https://vitepress.dev/reference/runtime-api#content',
props: [
{
name: 'as',
description:
'The content wrapper. Accepts an HTML tag name, a component name, or a component reference.',
type: ['string', 'object'],
default: 'div'
}
]
},
{
name: 'ClientOnly',
source: { symbol: 'ClientOnly' },
description:
'Renders its slot only at client side. Useful for wrapping components that are not SSR-friendly.',
'doc-url': 'https://vitepress.dev/reference/runtime-api#clientonly',
slots: [
{
name: 'default',
description: 'Content to render once the client app is mounted.'
}
]
},
{
name: 'Badge',
source: { module: 'vitepress/theme', symbol: 'VPBadge' },
description:
"Adds a status label to headers, such as a section's type or supported version. Available when using the default theme.",
'doc-url': 'https://vitepress.dev/reference/default-theme-badge',
props: [
{
name: 'type',
description: 'The badge color type.',
type: "'info' | 'tip' | 'warning' | 'danger'",
default: 'tip'
},
{
name: 'text',
description:
'The text displayed inside the badge. Ignored when the default slot is passed.',
type: 'string'
}
],
slots: [
{
name: 'default',
description:
'Content displayed inside the badge. Takes precedence over the `text` prop.'
}
]
}
]
}
}
}
mkdirSync('dist', { recursive: true })
writeFileSync('dist/web-types.json', JSON.stringify(webTypes, null, 2) + '\n')
Loading…
Cancel
Save