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