File tree Expand file tree Collapse file tree 5 files changed +85
-2
lines changed Expand file tree Collapse file tree 5 files changed +85
-2
lines changed Original file line number Diff line number Diff line change 22
33'use strict' ;
44
5- const crypto = require ( 'crypto' ) ;
5+ const md5 = require ( '../utils/ crypto' ) ;
66const { decodeURL } = require ( 'hexo-util' ) ;
77const compareVersions = require ( '../../scripts/utils/compare-versions' ) ;
88
99hexo . extend . helper . register ( 'md5' , function ( string ) {
10- return crypto . createHash ( ' md5' ) . update ( string ) . digest ( 'hex' ) ;
10+ return md5 ( string ) ;
1111} ) ;
1212
1313hexo . 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 ( ) } collapsed" data-toggle="collapse" href="#${ id } " role="button" aria-expanded="false" aria-controls="${ id } ">
12+ <div class="fold-arrow">▶</div>${ 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 1919 --button-hover-bg-color $button-hover-bg-color
2020 --highlight-bg-color $highlight-bg-color
2121 --inlinecode-bg-color $inlinecode-bg-color
22+ --fold-title-color $text-color
23+ --fold-border-color $line-color
2224
2325dark-colors ()
2426 --body-bg-color $body-bg-color-dark
@@ -40,6 +42,8 @@ dark-colors()
4042 --button-hover-bg-color $button-hover-bg-color-dark
4143 --highlight-bg-color $highlight-bg-color-dark
4244 --inlinecode-bg-color $inlinecode-bg-color-dark
45+ --fold-title-color $text-color
46+ --fold-border-color $line-color
4347
4448 img
4549 -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+ & :not (.collapsed ) > .fold-arrow
17+ transform rotate (90deg )
18+ transform-origin center center
19+
20+ .fold-arrow
21+ display inline-block
22+ margin-right 0.35rem
23+ transition transform .3s ease-out
24+
25+ .fold-content
26+ & > *
27+ margin 0
28+
29+ & > p
30+ padding 1rem 1rem
31+
32+ .fold-default
33+ background rgba (#bb bb bb , 0.25 )
34+
35+ .fold-primary
36+ background rgba (#b7 a0 e0 , 0.25 )
37+
38+ .fold-info
39+ background rgba (#a0 c5 e4 , 0.25 )
40+
41+ .fold-success
42+ background rgba (#ae dc ae , 0.25 )
43+
44+ .fold-warning
45+ background rgba (#f8 d6 a6 , 0.25 )
46+
47+ .fold-danger
48+ background rgba (#ec a9 a7 , 0.25 )
49+
50+
151// note
252.note
353 padding 0.75rem
You can’t perform that action at this time.
0 commit comments