Skip to content

Commit 0df39f6

Browse files
authored
feat(friend_card color):友链块颜色添加 (#938)
经测试无问题。
1 parent cbec449 commit 0df39f6

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

_config.yml

+3
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@ pages:
202202
# 友链页面配置
203203
friends:
204204
layout_scheme: traditional # simple: 简单布局, traditional: 传统布局
205+
link_block_color:
206+
enable: false #友链块颜色开关,用 color: '颜色' 字段
207+
unified_font: false # 是否统一友链块文字,true则所有文字都会成黑,false只有
205208

206209
############################### Article Layout ############################### > start
207210
# 文章布局

layout/friends.ejs

+17-3
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,15 @@
1717
<div class='friend-content'>
1818
<% getList(group.items).forEach(function(item){ %>
1919
<% if (item.url && item.title) { %>
20-
<a class='friend-card'
21-
target="_blank" rel="external noopener noreferrer" href="<%- url_for(item.url || '/') %>">
20+
<a class='friend-card <% if (theme.pages.friends.link_block_color.enable === true && item.color) { %>color-bk-dark<% } %>'
21+
target="_blank" rel="external noopener noreferrer" href="<%- url_for(item.url || '/') %>"
22+
<% if (theme.pages.friends.link_block_color.enable === true) { %>
23+
style="<% if (item.color) { %>background-color: <%- item.color %>;<% } %>
24+
<% if (theme.pages.friends.link_block_color.unified_font === true) { %>color: var(--link-color);<% } else { %>
25+
<% if (item.color) { %>color: var(--link-color);<% } %>
26+
<% } %>"
27+
<% } %>
28+
>
2229
<div class='friend-left'>
2330
<% if (item.avatar) { %>
2431
<img class='avatar' src='<%- item.avatar || (theme.plugins.lazyload && theme.plugins.lazyload.loadingImg) %>'/>
@@ -47,7 +54,14 @@
4754
<div class='simpleuser-group'>
4855
<% getList(group.items).forEach(function(item){ %>
4956
<% if (item.url && item.title) { %>
50-
<a class="simpleuser" target="_blank" rel="external noopener noreferrer" href="<%- url_for(item.url || '/') %>">
57+
<a class="simpleuser <% if (theme.pages.friends.link_block_color.enable === true && item.color) { %>color-bk-dark<% } %>" target="_blank" rel="external noopener noreferrer" href="<%- url_for(item.url || '/') %>"
58+
<% if (theme.pages.friends.link_block_color.enable === true) { %>
59+
style="<% if (item.color) { %>background-color: <%- item.color %>;<% } %>
60+
<% if (theme.pages.friends.link_block_color.unified_font === true) { %>color: var(--link-color);<% } else { %>
61+
<% if (item.color) { %>color: var(--link-color);<% } %>
62+
<% } %>"
63+
<% } %>
64+
>
5165
<img src="<%- item.avatar || (theme.plugins.lazyload && theme.plugins.lazyload.loadingImg) %>"/>
5266
<span><%- item.title %></span>
5367
</a>

source/css/_first/base_first.styl

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
--color-read-bkg: $color-read-bkg
2222
--color-read-post: $color-read-post
2323
--color-copyright-bkg: $color-copyright-bkg
24+
--link-color: #00323c
2425

2526
*
2627
box-sizing: border-box

source/css/_first/dark_first.styl

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ fitst_dark()
2525
--color-meta: $color-dark-meta
2626
--color-link: $color-dark-link
2727
--color-copyright-bkg: $color-dark-copyright-bkg
28+
--link-color:rgb(228, 228, 228)
2829

2930
img
3031
filter: brightness(convert(hexo-config('color_scheme.dark.brightness'))) !important
@@ -75,3 +76,6 @@ if hexo-config('plugins.darkmode.enable')
7576
fitst_dark()
7677
[color-scheme='dark']
7778
fitst_dark()
79+
.friend-card.color-bk-dark {
80+
filter: brightness(0.8);
81+
}

0 commit comments

Comments
 (0)