feat: add new-york to reproduction links
This commit is contained in:
parent
9527b1656f
commit
06ae5ee00c
|
|
@ -9,6 +9,7 @@ import { type Style } from '@/lib/registry/styles'
|
|||
const props = defineProps<{
|
||||
name: string
|
||||
code: string
|
||||
newYorkCode: string
|
||||
style: Style
|
||||
extraFiles?: string[]
|
||||
}>()
|
||||
|
|
@ -16,7 +17,7 @@ const props = defineProps<{
|
|||
const sources = ref<Record<string, string>>({})
|
||||
|
||||
onMounted(() => {
|
||||
sources.value['App.vue'] = props.code
|
||||
sources.value['App.vue'] = props.style === 'default' ? props.code : props.newYorkCode
|
||||
if (props.extraFiles) {
|
||||
props.extraFiles.forEach((file) => {
|
||||
import(`../../../src/lib/registry/${props.style}/example/${file}.vue?raw`).then((module) => {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ const props = withDefaults(defineProps<{
|
|||
name: string
|
||||
align?: 'center' | 'start' | 'end'
|
||||
sfcTsCode?: string
|
||||
sfcTsNewYorkCode?: string
|
||||
sfcTsHtml?: string
|
||||
extraFiles?: string[]
|
||||
}>(), { align: 'center' })
|
||||
|
|
@ -44,8 +45,8 @@ const { style } = useConfigStore()
|
|||
<StyleSwitcher />
|
||||
|
||||
<div class="flex items-center gap-x-1">
|
||||
<Stackblitz :key="style" :extra-files="extraFiles" :style="style" :name="name" :code="decodeURIComponent(sfcTsCode ?? '')" />
|
||||
<CodeSandbox :key="style" :extra-files="extraFiles" :style="style" :name="name" :code="decodeURIComponent(sfcTsCode ?? '')" />
|
||||
<Stackblitz :key="style" :extra-files="extraFiles" :style="style" :name="name" :code="decodeURIComponent(sfcTsCode ?? '')" :new-york-code="decodeURIComponent(sfcTsNewYorkCode ?? '')" />
|
||||
<CodeSandbox :key="style" :extra-files="extraFiles" :style="style" :name="name" :code="decodeURIComponent(sfcTsCode ?? '')" :new-york-code="decodeURIComponent(sfcTsNewYorkCode ?? '')" />
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import { type Style } from '@/lib/registry/styles'
|
|||
const props = defineProps<{
|
||||
name: string
|
||||
code: string
|
||||
newYorkCode: string
|
||||
style: Style
|
||||
extraFiles?: string[]
|
||||
}>()
|
||||
|
|
@ -16,7 +17,7 @@ const props = defineProps<{
|
|||
const sources = ref<Record<string, string>>({})
|
||||
|
||||
onMounted(() => {
|
||||
sources.value['App.vue'] = props.code
|
||||
sources.value['App.vue'] = props.style === 'default' ? props.code : props.newYorkCode
|
||||
if (props.extraFiles) {
|
||||
props.extraFiles.forEach((file) => {
|
||||
import(`../../../src/lib/registry/${props.style}/example/${file}.vue?raw`).then((module) => {
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ export default function (md: MarkdownRenderer) {
|
|||
const { name, attrs } = props
|
||||
const pluginPath = dirname(__dirname)
|
||||
const srcPath = resolve(pluginPath, '../../src/lib/registry/default/example/', `${name}.vue`).replace(/\\/g, '/')
|
||||
const srcPathNewYork = resolve(pluginPath, '../../src/lib/registry/new-york/example/', `${name}.vue`).replace(/\\/g, '/')
|
||||
|
||||
if (!fs.existsSync(srcPath)) {
|
||||
console.error(`rendering ${path}: ${srcPath} does not exist`)
|
||||
|
|
@ -28,6 +29,7 @@ export default function (md: MarkdownRenderer) {
|
|||
attrs,
|
||||
props,
|
||||
code: fs.readFileSync(srcPath, 'utf-8'),
|
||||
newYorkCode: fs.readFileSync(srcPathNewYork, 'utf-8'),
|
||||
path: srcPath,
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -9,18 +9,20 @@ export interface GenerateOptions {
|
|||
props: Record<string, any>
|
||||
path: string
|
||||
code: string
|
||||
newYorkCode: string
|
||||
}
|
||||
|
||||
export function parse(
|
||||
md: MarkdownRenderer,
|
||||
env: MarkdownEnv,
|
||||
{ code, attrs: _attrs, props }: GenerateOptions,
|
||||
{ newYorkCode, code, attrs: _attrs, props }: GenerateOptions,
|
||||
) {
|
||||
const highlightedHtml = md.options.highlight!(code, 'vue', _attrs || '')
|
||||
const sfcTsHtml = highlightedHtml
|
||||
|
||||
const attrs
|
||||
= `sfcTsCode="${encodeURIComponent(code)}"\n`
|
||||
+ `sfcTsNewYorkCode="${encodeURIComponent(newYorkCode)}"\n`
|
||||
+ `sfcTsHtml="${encodeURIComponent(sfcTsHtml)}"\n`
|
||||
+ `v-bind='${JSON.stringify(props)}'\n`
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user