Skip to content

feat(friend_card color):友链块颜色添加 #938

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
May 5, 2025
3 changes: 3 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ pages:
# 友链页面配置
friends:
layout_scheme: traditional # simple: 简单布局, traditional: 传统布局
link_block_color:
enable: false #友链块颜色开关,用 color: '颜色' 字段
unified_font: false # 是否统一友链块文字,true则所有文字都会成黑,false只有

############################### Article Layout ############################### > start
# 文章布局
Expand Down
20 changes: 17 additions & 3 deletions layout/friends.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,15 @@
<div class='friend-content'>
<% getList(group.items).forEach(function(item){ %>
<% if (item.url && item.title) { %>
<a class='friend-card'
target="_blank" rel="external noopener noreferrer" href="<%- url_for(item.url || '/') %>">
<a class='friend-card <% 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 || '/') %>"
<% if (theme.pages.friends.link_block_color.enable === true) { %>
style="<% if (item.color) { %>background-color: <%- item.color %>;<% } %>
<% if (theme.pages.friends.link_block_color.unified_font === true) { %>color: var(--link-color);<% } else { %>
<% if (item.color) { %>color: var(--link-color);<% } %>
<% } %>"
<% } %>
>
<div class='friend-left'>
<% if (item.avatar) { %>
<img class='avatar' src='<%- item.avatar || (theme.plugins.lazyload && theme.plugins.lazyload.loadingImg) %>'/>
Expand Down Expand Up @@ -47,7 +54,14 @@
<div class='simpleuser-group'>
<% getList(group.items).forEach(function(item){ %>
<% if (item.url && item.title) { %>
<a class="simpleuser" target="_blank" rel="external noopener noreferrer" href="<%- url_for(item.url || '/') %>">
<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 || '/') %>"
<% if (theme.pages.friends.link_block_color.enable === true) { %>
style="<% if (item.color) { %>background-color: <%- item.color %>;<% } %>
<% if (theme.pages.friends.link_block_color.unified_font === true) { %>color: var(--link-color);<% } else { %>
<% if (item.color) { %>color: var(--link-color);<% } %>
<% } %>"
<% } %>
>
<img src="<%- item.avatar || (theme.plugins.lazyload && theme.plugins.lazyload.loadingImg) %>"/>
<span><%- item.title %></span>
</a>
Expand Down
1 change: 1 addition & 0 deletions source/css/_first/base_first.styl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
--color-read-bkg: $color-read-bkg
--color-read-post: $color-read-post
--color-copyright-bkg: $color-copyright-bkg
--link-color: #00323c

*
box-sizing: border-box
Expand Down
4 changes: 4 additions & 0 deletions source/css/_first/dark_first.styl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ fitst_dark()
--color-meta: $color-dark-meta
--color-link: $color-dark-link
--color-copyright-bkg: $color-dark-copyright-bkg
--link-color:rgb(228, 228, 228)

img
filter: brightness(convert(hexo-config('color_scheme.dark.brightness'))) !important
Expand Down Expand Up @@ -75,3 +76,6 @@ if hexo-config('plugins.darkmode.enable')
fitst_dark()
[color-scheme='dark']
fitst_dark()
.friend-card.color-bk-dark {
filter: brightness(0.8);
}