-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
85 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const md5 = require('../utils/crypto'); | ||
|
||
hexo.extend.tag.register('fold', (args, content) => { | ||
args = args.join(' ').split('@'); | ||
const classes = args[0] || 'default'; | ||
const text = args[1] || ''; | ||
const id = 'collapse-' + md5(content).slice(0, 8); | ||
|
||
return ` | ||
<div class="fold"> | ||
<div class="fold-title fold-${classes.trim()} collapsed" data-toggle="collapse" href="#${id}" role="button" aria-expanded="false" aria-controls="${id}"> | ||
<div class="fold-arrow">▶</div>${text} | ||
</div> | ||
<div class='fold-content collapse' id="${id}"> | ||
${hexo.render.renderSync({ text: content, engine: 'markdown' }).split('\n').join('')} | ||
</div> | ||
</div>`; | ||
}, { | ||
ends: true | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
'use strict'; | ||
|
||
const crypto = require('crypto'); | ||
|
||
const md5 = (content) => { | ||
return crypto.createHash('md5').update(content).digest('hex'); | ||
} | ||
|
||
module.exports = md5; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters