diff --git a/docs/app/components/content/ComponentCode.vue b/docs/app/components/content/ComponentCode.vue index 6ac96cae63..e565f32af8 100644 --- a/docs/app/components/content/ComponentCode.vue +++ b/docs/app/components/content/ComponentCode.vue @@ -32,6 +32,10 @@ const props = defineProps<{ * @defaultValue false */ collapse?: boolean + /** + * A list of line numbers to highlight in the code block + */ + highlights?: number[] }>() const route = useRoute() @@ -105,7 +109,7 @@ const code = computed(() => { ` } - code += `\`\`\`vue` + code += `\`\`\`vue${props.highlights?.length ? ` {${props.highlights.join('-')}}` : ''}` if (props.external?.length) { code += ` @@ -201,7 +205,8 @@ const { data: ast } = await useAsyncData(`component-code-${name}-${hash({ props: formatted = await $prettier.format(code.value, { trailingComma: 'none', semi: false, - singleQuote: true + singleQuote: true, + printWidth: 100 }) } catch { formatted = code.value diff --git a/docs/app/components/content/ComponentExample.vue b/docs/app/components/content/ComponentExample.vue index 8e7a62a7dc..c19206d352 100644 --- a/docs/app/components/content/ComponentExample.vue +++ b/docs/app/components/content/ComponentExample.vue @@ -22,13 +22,11 @@ const props = withDefaults(defineProps<{ * @defaultValue true */ preview?: boolean - /** * Whether to show the source code * @defaultValue true */ source?: boolean - /** * A list of variable props to link to the component. */ @@ -40,6 +38,10 @@ const props = withDefaults(defineProps<{ default: any multiple?: boolean }> + /** + * A list of line numbers to highlight in the code block + */ + highlights?: number[] }>(), { preview: true, source: true @@ -65,7 +67,7 @@ const code = computed(() => { ` } - code += `\`\`\`vue${props.preview ? '' : ` [${data.pascalName}.vue]`} + code += `\`\`\`vue ${props.preview ? '' : ` [${data.pascalName}.vue]`}${props.highlights?.length ? `{${props.highlights.join('-')}}` : ''} ${data?.code ?? ''} \`\`\`` @@ -87,7 +89,8 @@ const { data: ast } = await useAsyncData(`component-example-${camelName}`, async formatted = await $prettier.format(code.value, { trailingComma: 'none', semi: false, - singleQuote: true + singleQuote: true, + printWidth: 100 }) } catch { formatted = code.value @@ -113,7 +116,7 @@ const optionsValues = ref(props.options?.reduce((acc, option) => {