Skip to content

Commit 2d3e808

Browse files
committed
fixing emoji not showing on sidebars
1 parent 911b78c commit 2d3e808

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

Diff for: docs/guide/markdown.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ meta:
6767
| col 2 is | centered | $12 |
6868
| zebra stripes | are neat | $1 |
6969

70-
## Emoji
70+
## Emoji :tada:
7171

7272
**Input**
7373

Diff for: lib/util/index.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
const parseEmojis = str => {
2+
const emojiData = require('markdown-it-emoji/lib/data/full.json')
3+
return str.replace(/:(.+?):/g, (placeholder, key) => emojiData[key] || placeholder)
4+
}
5+
16
exports.normalizeHeadTag = tag => {
27
if (typeof tag === 'string') {
38
tag = [tag]
@@ -30,11 +35,11 @@ exports.inferTitle = function (frontmatter) {
3035
return 'Home'
3136
}
3237
if (frontmatter.title) {
33-
return frontmatter.title
38+
return parseEmojis(frontmatter.title)
3439
}
3540
const match = frontmatter.__content.trim().match(/^#+\s+(.*)/)
3641
if (match) {
37-
return match[1]
42+
return parseEmojis(match[1])
3843
}
3944
}
4045

@@ -58,7 +63,7 @@ exports.extractHeaders = (content, include = [], md) => {
5863
const res = []
5964
tokens.forEach((t, i) => {
6065
if (t.type === 'heading_open' && include.includes(t.tag)) {
61-
const title = tokens[i + 1].content
66+
const title = parseEmojis(tokens[i + 1].content)
6267
const slug = t.attrs.find(([name]) => name === 'id')[1]
6368
res.push({
6469
level: parseInt(t.tag.slice(1), 10),

0 commit comments

Comments
 (0)