hexo-fliud主题友链分类

需求在友链部分进行分类处理

_config.fluid.yml中的items部分可以多填一个title作为分类标题,然后再在下面添加友链

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
- title: "YR"
links:
- {
title: "xiaoy",
intro: "(reverse)",
link: "https://blog.csdn.net/xy_hzz",
avatar: "https://profile-avatar.csdnimg.cn/1223b08551c049fd870cbe357ad5b0d0_xy_hzz.jpg!1"
}

- title: "CTFer"
links:
- {
title: "LilRan",
intro: "今日启程 无畏向前",
link: "https://blog.xinshi.fun/",
avatar: "https://blog.xinshi.fun/assets/avatar.png"
}

修改node_modules\hexo-theme-fluid\layout\links.ejs

将row links部分修改为如下(感谢ChatGPT的代码贡献),就可以了

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
<div class="links">
<% for (const group of theme.links.items || []) { %>
<% if (group.title) { %>
<h2 class="links-category-title"><%- group.title %></h2>
<% } %>
<div class="row links-group">
<% for (const each of group.links || []) { %>
<% if (!each.title || !each.link) continue; %>
<div class="card col-lg-4 col-md-6 col-sm-12">
<a href="<%= url_for(each.link) %>" class="card-body hover-with-bg" target="_blank" rel="noopener">
<div class="card-content">
<% if (each.avatar || each.image) { %>
<div class="link-avatar my-auto">
<img src="<%= url_for(each.avatar || each.image) %>" alt="<%= each.title %>"
onerror="this.onerror=null; this.src='<%= url_for(theme.links.onerror_avatar) %>'" />
</div>
<% } %>
<div class="link-text">
<div class="link-title"><%- each.title %></div>
<div class="link-intro"><%- each.intro || '' %></div>
</div>
</div>
</a>
</div>
<% } %>
</div>
<% } %>
</div>

遇到问题:重新部署博客的时候说links中的page未定义,但我明明什么都没动

最后给最上面每一行加个分号就不报错了

1
2
3
4
5
6
7
8
9
<%
page.layout = "links";
page.title = theme.links.title || __('links.title');
page.subtitle = theme.links.subtitle || __('links.subtitle');
page.banner_img = theme.links.banner_img;
page.banner_img_height = theme.links.banner_img_height;
page.banner_mask_alpha = theme.links.banner_mask_alpha;
page.comment = theme.links.comments.type;
%>

hexo-fliud主题友链分类
http://example.com/2025/02/11/fluidlinks/
作者
Naby
发布于
2025年2月11日
许可协议