NotionNext icon indicating copy to clipboard operation
NotionNext copied to clipboard

feat(next): 支持通过标签置顶文章(NEXT主题)

Open 6uu1 opened this issue 4 months ago • 1 comments

已知问题

  1. NEXT 主题无法通过标签实现文章置顶,用户无法灵活调整置顶文章。

解决方案

  1. 新增 sortPostsByTopTag 工具方法,支持按指定标签(如 top)将文章置顶。
  2. 在首页、分类、标签、搜索等页面,若当前主题为 next 且设置了置顶标签,则自动将带有该标签的文章排在前面。
  3. themes/next/config.js 增加 NEXT_TOP_TAG 配置项,支持自定义置顶标签名。

改动收益

  1. 主题用户可通过标签灵活置顶任意文章,无需手动排序。
  2. 兼容原有排序逻辑,未设置置顶标签时不影响现有功能。
  3. 仅影响 next 主题,其他主题不受影响。

具体改动

  1. lib/utils/post.js
    • 新增 sortPostsByTopTag 方法。
  2. themes/next/config.js
    • 新增 NEXT_TOP_TAG 配置项,默认值为 'top'
  3. pages/index.jspages/page/[page].jspages/category/[category]/index.jspages/category/[category]/page/[page].jspages/tag/[tag]/index.jspages/tag/[tag]/page/[page].jspages/search/index.jspages/search/[keyword]/index.jspages/search/[keyword]/page/[page].js
    • 在获取文章列表后,按置顶标签重排。

测试确认

  • [x] 本地开发环境测试通过
  • [x] 生产环境构建测试通过
  • [x] 置顶标签配置后,文章正确置顶
  • [x] 未配置置顶标签时,排序不受影响

6uu1 avatar Aug 13 '25 06:08 6uu1

Someone is attempting to deploy a commit to the tangly1024's projects Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Aug 13 '25 06:08 vercel[bot]