Skip to content

Commit 245f06d

Browse files
committed
fix: custom block HeaderCode
1 parent e16435c commit 245f06d

File tree

10 files changed

+105
-97
lines changed

10 files changed

+105
-97
lines changed

package-lock.json

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"@vue-a11y/focus-loop": "^0.1.2",
6767
"@vue-a11y/skip-to": "^2.1.2",
6868
"@vue/composition-api": "^1.0.0-beta.11",
69-
"@vueuse/core": "^4.0.0-beta.9",
69+
"@vueuse/core": "^4.0.5",
7070
"vue-disqus": "^4.0.1"
7171
}
7272
}

src/.vuepress/config/plugins.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ module.exports = [
129129
'vuepress-plugin-container',
130130
{
131131
type: 'headerCode',
132-
before: info => customBlock.headerCode[0].replace('%', info),
132+
before: info => customBlock.headerCode[0].replace('%', info === 'HEADERCODE' ? '' : info),
133133
after: customBlock.headerCode[1]
134134
}
135135
],

src/.vuepress/theme/components/headerCodeSnippet.vue

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,44 @@
11
<template>
2-
<div
3-
ref="headerCodeSnippet"
4-
class="flex items-center justify-between w-full header-code"
5-
>
6-
<div class="pl-6 text-sm">
7-
<slot />
8-
</div>
9-
<div class="flex">
10-
<button
11-
type="button"
12-
class="p-4 text-xs uppercase opacity-0 focus:opacity-100"
13-
:aria-label="t.skip.ariaLabel || t.skip.text"
14-
@click="skipCodeSnippet"
15-
>
16-
{{ t.skip.text }}
17-
</button>
18-
<button
19-
type="button"
20-
class="flex items-center p-4 text-xs"
21-
:aria-label="t.copy.ariaLabel || t.copy.text"
22-
@click="copyCondeSnippet"
23-
>
24-
<vp-icon name="copy" />
25-
<span
26-
v-show="!copied"
27-
class="pl-2 uppercase"
2+
<div>
3+
<div
4+
ref="headerCodeSnippet"
5+
class="flex items-center justify-between w-full header-code"
6+
>
7+
<div class="pl-6 text-sm">
8+
{{ info }}
9+
</div>
10+
<div class="flex">
11+
<button
12+
type="button"
13+
class="p-4 text-xs uppercase opacity-0 focus:opacity-100"
14+
:aria-label="t.skip.ariaLabel || t.skip.text"
15+
@click="skipCodeSnippet"
2816
>
29-
{{ t.copy.text }}
30-
</span>
31-
<span
32-
v-show="copied"
33-
class="pl-2 uppercase"
17+
{{ t.skip.text }}
18+
</button>
19+
<button
20+
type="button"
21+
class="flex items-center p-4 text-xs"
22+
:aria-label="t.copy.ariaLabel || t.copy.text"
23+
@click="copyCondeSnippet"
3424
>
35-
{{ t.copy.textCopied }}
36-
</span>
37-
</button>
25+
<vp-icon name="copy" />
26+
<span
27+
v-show="!copied"
28+
class="pl-2 uppercase"
29+
>
30+
{{ t.copy.text }}
31+
</span>
32+
<span
33+
v-show="copied"
34+
class="pl-2 uppercase"
35+
>
36+
{{ t.copy.textCopied }}
37+
</span>
38+
</button>
39+
</div>
3840
</div>
41+
<slot />
3942
</div>
4043
</template>
4144

@@ -61,13 +64,13 @@ export default {
6164
6265
function skipCodeSnippet () {
6366
const parent = refs.headerCodeSnippet.parentElement
64-
if (parent) programmaticFocus(parent.nextSibling)
67+
if (parent && parent.nextElementSibling) programmaticFocus(parent.nextElementSibling)
6568
}
6669
6770
function copyCondeSnippet () {
68-
const { copy, supported } = useClipboard()
69-
if (supported) {
70-
copy(refs.headerCodeSnippet.nextSibling && refs.headerCodeSnippet.nextSibling.textContent)
71+
const { copy, isSupported } = useClipboard()
72+
if (isSupported) {
73+
copy(refs.headerCodeSnippet.nextElementSibling && refs.headerCodeSnippet.nextElementSibling.textContent)
7174
copied.value = true
7275
root.$announcer.assertive(t.value.copy.textCopied)
7376
setTimeout(() => {

src/.vuepress/theme/styles/_markdown.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@
203203
}
204204
}
205205

206+
figure [class*=language-] {
207+
margin-bottom: 0;
208+
}
209+
206210
.token.block-comment,.token.cdata,.token.comment,.token.doctype,.token.prolog { color:#999 }
207211
.token.punctuation { color:#ccc }
208212
.token.attr-name,.token.deleted,.token.namespace,.token.tag { color:#E58A85}

src/posts/2020-09-01-post-test.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,15 @@ Suspendisse rhoncus mauris a sapien gravida, ut pulvinar urna ultrices. Aenean s
1919
Praesent vehicula pharetra tincidunt. Proin nec elit volutpat, lobortis dui eu, hendrerit sapien. Donec sapien quam, dictum sit amet neque eu, malesuada ultrices libero. Morbi blandit augue in turpis porttitor porta.
2020

2121
:::: fig code
22-
::: headerCode
23-
index.html
24-
:::
22+
::: headerCode index.html
2523
```html
2624
<small>
2725
<a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">
2826
Creative Commons Attribution Share-alike license
2927
</a>
3028
</small>
3129
```
30+
:::
3231
::: figcap
3332
Using &lt;small&gt; around a [Creative Commons license](http://creativecommons.org/choose/) link with `rel="license"`
3433
:::

src/project/posts-guide.md

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ After completing, create a PR and request review from members for the latest adj
3535

3636
### Blog posts
3737

38-
::: headerCode
39-
2020-05-12-my-post.md
40-
:::
38+
::: headerCode 2020-05-12-my-post.md
4139
```yaml
4240
---
4341
title: Post title # (Required) - between 50-65 characters
@@ -49,6 +47,7 @@ author: author's nickname # (Optional)
4947
date: YYYY/MM/DD HH:ii:ss # (Required)
5048
---
5149
```
50+
:::
5251

5352
::: alert warning
5453
Available categories: `[news, aria, wcag, tools, packages, spa, html]`.
@@ -75,8 +74,7 @@ Add your author information `src/config/authors.json`, soon we will have a page
7574

7675
### Figure + Blockquote + Figcaption
7776

78-
::: headerCode
79-
:::
77+
::::: headerCode
8078
```
8179
:::: fig bq
8280
::: bq
@@ -87,6 +85,7 @@ VuePress is composed of two parts: a minimalistic static site generator with a V
8785
:::
8886
::::
8987
```
88+
:::::
9089

9190
:::: fig bq
9291
::: bq
@@ -99,8 +98,7 @@ VuePress is composed of two parts: a minimalistic static site generator with a V
9998

10099
### Tip, Note, Warning, Danger
101100

102-
::: headerCode
103-
:::
101+
:::: headerCode
104102
```
105103
::: alert tip
106104
This is a tip
@@ -118,6 +116,7 @@ This is a warning
118116
This is a danger
119117
:::
120118
```
119+
::::
121120

122121
::: alert tip
123122
This is a tip
@@ -137,6 +136,7 @@ This is a danger
137136

138137
### Figure + HeaderCode + Code block + Figcaption
139138

139+
::::: headerCode
140140
```
141141
:::: fig code
142142
::: headerCode
@@ -153,52 +153,53 @@ Basic usage of Vue announcer
153153
:::
154154
::::
155155
```
156+
:::::
156157

157158
:::: fig code
158-
::: headerCode
159-
main.js
160-
:::
159+
::: headerCode main.js
161160
```js
162161
import Vue from 'vue'
163162
import VueAnnouncer from '@vue-a11y/announcer'
164163

165164
Vue.use(VueAnnouncer)
166165
```
166+
:::
167167
::: figcap
168168
Basic usage of Vue announcer
169169
:::
170170
::::
171171

172172
### headerCode + Code block
173173

174+
:::: headerCode
174175
```
175-
::: headerCode
176-
main.js
177-
:::
178-
``js
176+
::: headerCode main.js
177+
```js
179178
import Vue from 'vue'
180179
import VueAnnouncer from '@vue-a11y/announcer'
181180
182181
Vue.use(VueAnnouncer)
183182
``
183+
:::
184184
```
185+
::::
185186

186-
::: headerCode
187-
main.js
188-
:::
187+
::: headerCode main.js
189188
```js
190189
import Vue from 'vue'
191190
import VueAnnouncer from '@vue-a11y/announcer'
192191

193192
Vue.use(VueAnnouncer)
194193
```
194+
:::
195195

196196
## Vue in markdown
197197

198198
### IntersectionObserver component
199199

200200
Use this component for lazy-load of iframes, images, among other media.
201201

202+
::: headerCode
202203
```vue
203204
<intersection-observer>
204205
<template v-slot="data">
@@ -211,4 +212,5 @@ Use this component for lazy-load of iframes, images, among other media.
211212
</iframe>
212213
</template>
213214
</intersection-observer>
214-
```
215+
```
216+
:::

src/pt/posts/2020-09-01-posts-de-teste.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,15 @@ Suspendisse rhoncus mauris a sapien gravida, ut pulvinar urna ultrices. Aenean s
1818
Praesent vehicula pharetra tincidunt. Proin nec elit volutpat, lobortis dui eu, hendrerit sapien. Donec sapien quam, dictum sit amet neque eu, malesuada ultrices libero. Morbi blandit augue in turpis porttitor porta.
1919

2020
:::: fig code
21-
::: headerCode
22-
index.html
23-
:::
21+
::: headerCode index.html
2422
```html
2523
<small>
2624
<a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">
2725
Creative Commons Attribution Share-alike license
2826
</a>
2927
</small>
3028
```
29+
:::
3130
::: figcap
3231
Using &lt;small&gt; around a [Creative Commons license](http://creativecommons.org/choose/) link with `rel="license"`
3332
:::

src/pt/projeto/como-contribuir.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Nós também temos uma [issue](https://github.com/vue-a11y/vue-a11y.com/issues/1
3434
Nossa intenção é recompensar o criador por cada conteúdo publicado no site, em breve iremos conseguir esse feito.
3535

3636
::: alert warning
37-
Criamos um guia com dicas para criar postagens, receitas ou dicas. [Guia de postagens](/pt/projeto/guia.html#posts-guide).
37+
Criamos um guia com dicas para criar postagens, receitas ou dicas. [Guia de postagens](/pt/projeto/guia-de-postagens.html#posts-guide).
3838
:::
3939

4040
## Respondendo perguntas

0 commit comments

Comments
 (0)