Skip to content

Commit eb419a5

Browse files
author
reco_luan
authored
Merge pull request #132 from franklinqin0/develop
add custom blocks: right, theorem, details
2 parents 2e0b901 + 093f03d commit eb419a5

File tree

3 files changed

+59
-2
lines changed

3 files changed

+59
-2
lines changed

example/docs/views/other/guide.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@ keys:
3737
3. 你可以打开 [午后南杂](http://recoluan.gitlab.io) 来查看效果。
3838
:::
3939

40+
::: theorem 牛顿第一定律
41+
假若施加于某物体的外力为零,则该物体的运动速度不变。
42+
43+
::: right
44+
来自 [维基百科](https://zh.wikipedia.org/wiki/%E7%89%9B%E9%A1%BF%E8%BF%90%E5%8A%A8%E5%AE%9A%E5%BE%8B)
45+
:::
46+
47+
::: details
48+
这是一个详情块,在 IE / Edge 中不生效
49+
:::
50+
4051
> 测试
4152
4253
## Use

index.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,41 @@ module.exports = (options, ctx) => ({
5858
['container', {
5959
type: 'tip',
6060
defaultTitle: {
61+
'/': '',
6162
'/zh/': '提示'
6263
}
6364
}],
6465
['container', {
6566
type: 'warning',
6667
defaultTitle: {
68+
'/': '',
6769
'/zh/': '注意'
6870
}
6971
}],
7072
['container', {
7173
type: 'danger',
7274
defaultTitle: {
75+
'/': '',
7376
'/zh/': '警告'
7477
}
78+
}],
79+
['container', {
80+
type: 'right',
81+
defaultTitle: ''
82+
}],
83+
['container', {
84+
type: 'theorem',
85+
before: info => `<div class="custom-block theorem"><p class="title">${info}</p>`,
86+
after: '</div>'
87+
}],
88+
['container', {
89+
type: 'details',
90+
before: info => `<details class="custom-block details">${info ? `<summary>${info}</summary>` : ''}\n`,
91+
after: () => '</details>\n',
92+
defaultTitle: {
93+
'/': 'See More',
94+
'/zh/': '更多'
95+
}
7596
}]
7697
]
7798
})

styles/custom-blocks.styl

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,30 @@
2222
border-color #f26d6d
2323
.custom-block-title
2424
color #f26d6d
25-
26-
25+
&.right
26+
color transparentify($textColor, 0.4)
27+
font-size 0.9rem
28+
text-align right
29+
&.theorem
30+
margin 1rem 0
31+
padding .1rem 1.5rem
32+
border-radius 0.4rem
33+
background-color #f0f4f8
34+
.title
35+
font-weight bold
36+
&.details
37+
display block
38+
position relative
39+
border-radius 2px
40+
margin 1em 0
41+
padding 1rem
42+
background-color #eee
43+
h4
44+
margin-top 0
45+
figure, p
46+
&:last-child
47+
margin-bottom 0
48+
padding-bottom 0
49+
summary
50+
outline none
51+
cursor pointer

0 commit comments

Comments
 (0)