Skip to content

Commit

Permalink
feat: adapt waline emoji cdn
Browse files Browse the repository at this point in the history
  • Loading branch information
YunYouJun committed Jun 8, 2022
1 parent ff7f7e1 commit efeb736
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
6 changes: 3 additions & 3 deletions demo/_config.yun.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ waline:
visitor: true
comment: true
emoji:
- https://fastly.jsdelivr.net/gh/walinejs/emojis@latest/bilibili/
- https://fastly.jsdelivr.net/gh/walinejs/emojis@latest/weibo/
- https://fastly.jsdelivr.net/gh/walinejs/emojis@latest/qq/
- "@waline/emojis@latest/bilibili/"
- "@waline/emojis@latest/weibo/"
- "@waline/emojis@latest/qq/"
locale:
placeholder: 填写邮箱,可以收到回复通知哦~
requiredMeta: [nick]
Expand Down
9 changes: 9 additions & 0 deletions docs/guide/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -1451,6 +1451,15 @@ vendors:
css: '@waline/client@v2/dist/waline.css'
```

::: tip

可选 CDN:

- <https://npm.elemecdn.com/>
- <https://unpkg.zhimg.com/>

:::

## 更多配置

你可以直接查看 [\_config.yml | hexo-theme-yun](https://github.com/YunYouJun/hexo-theme-yun/blob/master/_config.yml) 文件及相关注释。
Expand Down
1 change: 1 addition & 0 deletions packages/hexo-theme-yun-js/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ declare interface Window {
root: string
title: string
vendors: {
host: string
darken: string
}

Expand Down
3 changes: 2 additions & 1 deletion packages/hexo-theme-yun/_vendors.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# you can config it in vendors.host
host: https://cdn.jsdelivr.net/npm/
# Whether to enable local
local: true
# todo
# local: true

# internal
yun_markdown_css: star-markdown-css@0.3.3/dist/yun/yun-markdown.min.css
Expand Down
13 changes: 13 additions & 0 deletions packages/hexo-theme-yun/scripts/helpers/yun-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,23 @@ hexo.extend.helper.register('yun_config', function () {
cdn: theme.vendors.waline.js,
dark: 'html.dark',
}

// adapt waline emoji
const host = theme.vendors.host
if (host) {
const emoji = exportConfig.waline.config.emoji
if (emoji) {
emoji.forEach((e, i) => {
if (e.startsWith('@'))
emoji[i] = host + emoji[i]
})
}
}
}

// vendors
exportConfig.vendors = {
host: theme.vendors.host,
darken: theme.vendors.darken,
}

Expand Down

1 comment on commit efeb736

@vercel
Copy link

@vercel vercel bot commented on efeb736 Jun 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.