Skip to content

Commit

Permalink
Add Utterances comment system (#625)
Browse files Browse the repository at this point in the history
  • Loading branch information
maboloshi committed Feb 17, 2020
1 parent 6c57464 commit e1cffe7
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
30 changes: 29 additions & 1 deletion includes/specs/comment.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -137,5 +164,6 @@ module.exports = {
...GitmentGitalkSpec,
...IssoSpec,
...LiveReSpec,
...ValineSpec
...ValineSpec,
...UtterancesSpec
}
14 changes: 14 additions & 0 deletions layout/comment/utterances.ejs
Original file line number Diff line number Diff line change
@@ -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>
<% } %>
3 changes: 3 additions & 0 deletions layout/comment/utterances.locals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = (ctx, locals) => {
return locals;
}

0 comments on commit e1cffe7

Please sign in to comment.