chore(widget): show domain name instead of full url in links widget
This commit is contained in:
parent
90414e8062
commit
51e291c615
|
@ -3,12 +3,14 @@
|
|||
*
|
||||
* @example
|
||||
* <%- is_same_link(url_a, url_b) %>
|
||||
* <%- get_domain(url) %>
|
||||
* <%- post_count() %>
|
||||
* <%- category_count() %>
|
||||
* <%- tag_count() %>
|
||||
* <%- duration() %>
|
||||
* <%- word_count(content) %>
|
||||
*/
|
||||
const URL = require('url').URL;
|
||||
const moment = require('moment');
|
||||
|
||||
module.exports = function (hexo) {
|
||||
|
@ -23,6 +25,11 @@ module.exports = function (hexo) {
|
|||
return santize(this.url_for(a)) == santize(this.url_for(b));
|
||||
});
|
||||
|
||||
hexo.extend.helper.register('get_domain', function (link) {
|
||||
const url = new URL(link);
|
||||
return url.hostname;
|
||||
});
|
||||
|
||||
hexo.extend.helper.register('post_count', function () {
|
||||
return this.site.posts.length;
|
||||
});
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<span class="level-item"><%= i %></span>
|
||||
</span>
|
||||
<span class="level-right">
|
||||
<span class="level-item tag"><%- links[i] %></span>
|
||||
<span class="level-item tag"><%- get_domain(links[i]) %></span>
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
|
|
Loading…
Reference in New Issue