Add Utterances comment system (#625)

This commit is contained in:
沙漠之子 2020-02-17 23:02:16 +08:00 committed by GitHub
parent 6c57464b63
commit e1cffe7827
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 46 additions and 1 deletions

View File

@ -124,6 +124,33 @@ const ValineSpec = {
}
};
const UtterancesSpec = {
repo: {
[type]: 'string',
[doc]: 'The repository willed connect to utterances',
[required]: true,
[requires]: comment => comment.type === 'utterances'
},
issue_term: {
[type]: 'string',
[doc]: 'Blog Post ↔️ Issue Mapping',
[defaultValue]: 'pathname',
[requires]: comment => comment.type === 'utterances'
},
label: {
[type]: 'string',
[doc]: 'Issue Label',
[defaultValue]: '',
[requires]: comment => comment.type === 'utterances'
},
theme: {
[type]: 'string',
[doc]: 'Utterances theme',
[defaultValue]: 'github-light',
[requires]: comment => comment.type === 'utterances'
}
};
module.exports = {
[type]: 'object',
[doc]: 'Comment plugin settings\nhttps://ppoffice.github.io/hexo-theme-icarus/categories/Plugins/Comment',
@ -137,5 +164,6 @@ module.exports = {
...GitmentGitalkSpec,
...IssoSpec,
...LiveReSpec,
...ValineSpec
...ValineSpec,
...UtterancesSpec
}

View File

@ -0,0 +1,14 @@
<% if (!has_config('comment.repo')) { %>
<div class="notification is-danger">
You forgot to set the <code>repo</code> for utteranc.es Please set it in <code>_config.yml</code>.
</div>
<% } else { %>
<script src="https://utteranc.es/client.js"
repo="<%= get_config('comment.repo') %>"
issue-term="<%= get_config('comment.issue-term') %>"
label="<%= get_config('comment.label') %>"
theme="<%= get_config('comment.theme') %>"
crossorigin="anonymous"
async>
</script>
<% } %>

View File

@ -0,0 +1,3 @@
module.exports = (ctx, locals) => {
return locals;
}