makdown 的超链接显示 其实我看的真不怎么喜欢,就想找找看有没有好的,这不发现一篇相关的修改也进行了尝试,当然想看原版 张洪Heo网址卡片外置标签 点击查看,很多步骤都相似,但是css是我自己更改的,适用于我自己的博客。

效果预览

1
{% link 获取网站的Favicon图标并显示在你的网页上,owen0o0,https://github.com/owen0o0/getFavicon %}

添加外置标签

新建文件themes/butterfly/scripts/tag/link.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function link(args) {
args = args.join(' ').split(',');
let title = args[0];
let sitename = args[1];
let link = args[2];

// 获取网页favicon
let urlNoProtocol = link.replace(/^https?\:\/\//i, "");
let imgUrl = "https://api.iowen.cn/favicon/" + urlNoProtocol + ".png";

return `<a class="tag-Link" target="_blank" href="${link}">
<div class="tag-link-tips">引用站外地址</div>
<div class="tag-link-bottom">
<div class="tag-link-left" style="background-image: url(${imgUrl});"></div>
<div class="tag-link-right">
<div class="tag-link-title">${title}</div>
<div class="tag-link-sitename">${sitename}</div>
</div>
<i class="fa-solid fa-angle-right"></i>
</div>
</a>`
}

hexo.extend.tag.register('link',link, { ends: false })

添加css

新建文件themes/butterfly/source/css/custom.css

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
* 网址卡片外置标签 */

#article-container .tag-Link {
background: #f1f3f8;
border-radius: 8px!important;
display: flex;
border: 1px solid #e3e8f7;
flex-direction: column;
padding: 0.3rem 1rem 0.6rem;
border-width: 1px!important;
margin-top: 1rem;
margin-bottom: 1rem!important;
}



#article-container .tag-Link:hover {
border: 1px solid #2c2c2c;
text-decoration: none;
}

#article-container .tag-Link .tag-link-tips {
border-bottom: 1px solid #e3e8f7 ;
padding-bottom: 4px;
font-size: 0.6rem;
color: #999999;
font-weight: normal;
pointer-events: none;
}

#article-container .tag-Link:hover .tag-link-tips {
color: #2c2c2c;
}

#article-container .tag-Link .tag-link-bottom {
display: flex;
margin-top: 1rem;
margin-bottom: 0.5rem;
align-items: center;
justify-content: space-around;
pointer-events: none;
}


#article-container .tag-Link .tag-link-bottom .tag-link-left {
width: 40px;
min-width: 40px;
height: 40px;
background-size: cover !important;
border-radius: 8px;
background: #fff;
pointer-events: none;
display: flex;
}


#article-container .tag-Link .tag-link-bottom .tag-link-right {
margin-left: 1rem;
pointer-events: none;
}

#article-container .tag-Link .tag-link-bottom .tag-link-right .tag-link-title {
font-size: 1rem;
line-height: 1.2;
color: #111;
font-weight: bold;
}

#article-container .tag-Link .tag-link-bottom .tag-link-right .tag-link-sitename {
font-size: 0.8rem;
color: #999999;
font-weight: normal;
margin-top: 8px;
pointer-events: none;
line-height: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

#article-container .tag-Link:hover .tag-link-bottom .tag-link-right .tag-link-sitename {
color: #2c2c2c;
}

#article-container .tag-Link .tag-link-bottom i {
margin-left: auto;
padding-left: 0.5rem;
pointer-events: none;
color: #111;
font-size: 16px;
line-height: 1;
}