diff --git a/includes/helpers/site.js b/includes/helpers/site.js
index ef50a0d..08cd226 100644
--- a/includes/helpers/site.js
+++ b/includes/helpers/site.js
@@ -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;
});
diff --git a/layout/widget/links.ejs b/layout/widget/links.ejs
index c87c605..2a1e629 100644
--- a/layout/widget/links.ejs
+++ b/layout/widget/links.ejs
@@ -14,7 +14,7 @@
<%= i %>
- <%- links[i] %>
+ <%- get_domain(links[i]) %>