File tree 5 files changed +80
-2
lines changed
5 files changed +80
-2
lines changed Original file line number Diff line number Diff line change 2
2
3
3
'use strict' ;
4
4
5
- const crypto = require ( 'crypto' ) ;
5
+ const md5 = require ( '../utils/ crypto' ) ;
6
6
const { decodeURL } = require ( 'hexo-util' ) ;
7
7
const compareVersions = require ( '../../scripts/utils/compare-versions' ) ;
8
8
9
9
hexo . extend . helper . register ( 'md5' , function ( string ) {
10
- return crypto . createHash ( ' md5' ) . update ( string ) . digest ( 'hex' ) ;
10
+ return md5 ( string ) ;
11
11
} ) ;
12
12
13
13
hexo . extend . helper . register ( 'require_version' , function ( current , require ) {
Original file line number Diff line number Diff line change
1
+ const md5 = require ( '../utils/crypto' ) ;
2
+
3
+ hexo . extend . tag . register ( 'fold' , ( args , content ) => {
4
+ args = args . join ( ' ' ) . split ( '@' ) ;
5
+ const classes = args [ 0 ] || 'default' ;
6
+ const text = args [ 1 ] || '' ;
7
+ const id = 'collapse-' + md5 ( content ) . slice ( 0 , 8 ) ;
8
+
9
+ return `
10
+ <div class="fold">
11
+ <div class="fold-title fold-${ classes . trim ( ) } " data-toggle="collapse" href="#${ id } " role="button" aria-expanded="false" aria-controls="${ id } ">
12
+ ${ text }
13
+ </div>
14
+ <div class='fold-content collapse' id="${ id } ">
15
+ ${ hexo . render . renderSync ( { text : content , engine : 'markdown' } ) . split ( '\n' ) . join ( '' ) }
16
+ </div>
17
+ </div>` ;
18
+ } , {
19
+ ends : true
20
+ } ) ;
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ const crypto = require ( 'crypto' ) ;
4
+
5
+ const md5 = ( content ) => {
6
+ return crypto . createHash ( 'md5' ) . update ( content ) . digest ( 'hex' ) ;
7
+ }
8
+
9
+ module . exports = md5 ;
Original file line number Diff line number Diff line change 19
19
--button-hover-bg-color $button-hover-bg-color
20
20
--highlight-bg-color $highlight-bg-color
21
21
--inlinecode-bg-color $inlinecode-bg-color
22
+ --fold-title-color $text-color
23
+ --fold-border-color $line-color
22
24
23
25
dark-colors ()
24
26
--body-bg-color $body-bg-color-dark
@@ -40,6 +42,8 @@ dark-colors()
40
42
--button-hover-bg-color $button-hover-bg-color-dark
41
43
--highlight-bg-color $highlight-bg-color-dark
42
44
--inlinecode-bg-color $inlinecode-bg-color-dark
45
+ --fold-title-color $text-color
46
+ --fold-border-color $line-color
43
47
44
48
img
45
49
-webkit- filter brightness (.9 )
Original file line number Diff line number Diff line change
1
+ // fold
2
+ .fold
3
+ margin 1rem 0
4
+ border 0.5px solid var (-- fold-border-color )
5
+ position relative
6
+ clear both
7
+ border-radius 0.125rem
8
+
9
+ .fold-title
10
+ color var (-- fold-title-color )
11
+ padding 0.5rem 0.75rem
12
+ font-size 0.9rem
13
+ font-weight bold
14
+ border-radius 0.125rem
15
+
16
+ .fold-title :before
17
+ content "▶ "
18
+ font-weight bold
19
+
20
+ .fold-content
21
+ & > *
22
+ margin 0
23
+
24
+ & > p
25
+ padding 1rem 1rem
26
+
27
+ .fold-default
28
+ background rgba (#bb bb bb , 0.25 )
29
+
30
+ .fold-primary
31
+ background rgba (#b7 a0 e0 , 0.25 )
32
+
33
+ .fold-info
34
+ background rgba (#a0 c5 e4 , 0.25 )
35
+
36
+ .fold-success
37
+ background rgba (#ae dc ae , 0.25 )
38
+
39
+ .fold-warning
40
+ background rgba (#f8 d6 a6 , 0.25 )
41
+
42
+ .fold-danger
43
+ background rgba (#ec a9 a7 , 0.25 )
44
+
45
+
1
46
// note
2
47
.note
3
48
padding 0.75rem
You can’t perform that action at this time.
0 commit comments