Skip to content

Commit 6737d12

Browse files
committed
feat: DemoBlock 支持多内容项共享同一标题
1 parent d811d9c commit 6737d12

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

.vitepress/theme/components/DemoBlock.vue

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,22 @@ const renderList = computed<DemoItem[]>(() => {
2626

2727
<template>
2828
<div class="demo-block-container">
29-
<div v-for="(item, index) in renderList" :key="index" class="wrapper">
29+
<div class="wrapper">
30+
<!-- 单个标题区域 -->
3031
<div class="section-code">
31-
<div class="title">
32-
Markdown 语法
33-
</div>
34-
<div class="code" v-html="item.code" />
32+
<div class="title">Markdown 语法</div>
33+
<!-- 多个内容项共享该标题 -->
34+
<div v-for="(item, index) in renderList" :key="index" class="code" v-html="item.code" />
3535
</div>
36+
3637
<div class="section-html">
37-
<div class="title">
38-
HTML
39-
</div>
40-
<div class="html">
41-
{{ item.html }}
42-
</div>
38+
<div class="title">HTML</div>
39+
<div v-for="(item, index) in renderList" :key="index" class="html">{{ item.html }}</div>
4340
</div>
41+
4442
<div class="section-preview">
45-
<div class="title">
46-
预览效果
47-
</div>
48-
<div class="preview" v-html="item.html" />
43+
<div class="title">预览效果</div>
44+
<div v-for="(item, index) in renderList" :key="index" class="preview" v-html="item.html" />
4945
</div>
5046
</div>
5147
</div>
@@ -69,11 +65,19 @@ const renderList = computed<DemoItem[]>(() => {
6965
display: flex;
7066
border-radius: 8px;
7167
overflow: hidden;
72-
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
68+
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.102);
7369
align-items: stretch; /* 确保子元素高度拉伸以填满容器 */
7470
height: auto;
7571
}
7672
73+
.section-code .code:not(:last-child),
74+
.section-html .html:not(:last-child),
75+
.section-preview .preview:not(:last-child) {
76+
/* margin-bottom: 0.5rem; */
77+
padding-bottom: 0.5rem;
78+
border-bottom: 5px solid rgba(51, 51, 51, 0.750);
79+
}
80+
7781
.section-code .title {background-color: var(--demoblock-title-c-bg)}
7882
.section-html .title {background-color: var(--demoblock-title-c-bg-html)}
7983
.section-preview .title {background-color: var(--demoblock-title-c-bg-preview);}

0 commit comments

Comments
 (0)