惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Blog — PlanetScale
Blog — PlanetScale
J
Java Code Geeks
月光博客
月光博客
Engineering at Meta
Engineering at Meta
WordPress大学
WordPress大学
Jina AI
Jina AI
小众软件
小众软件
U
Unit 42
云风的 BLOG
云风的 BLOG
Stack Overflow Blog
Stack Overflow Blog
雷峰网
雷峰网
博客园 - Franky
Microsoft Security Blog
Microsoft Security Blog
罗磊的独立博客
宝玉的分享
宝玉的分享
B
Blog
C
Check Point Blog
爱范儿
爱范儿
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
量子位
阮一峰的网络日志
阮一峰的网络日志
Vercel News
Vercel News
酷 壳 – CoolShell
酷 壳 – CoolShell

Donghai's Blog

使用DBeaver连接Dynamics 365 Dataverse | Donghai C# 技术备忘 - LINQ | Donghai 为Astro站点添加Google Analytics | Donghai C# 技术备忘 - LINQ - Donghai’s Blog 20260819 说些什么 | Donghai Dynamics 365 interview questions | Donghai C# 技术备忘 (1) | Donghai Dynamics 365 事件框架、事件执行管道 | Donghai 马拉松配速表 | Donghai 马拉松赛事分级 | Donghai 抖音创作日志(2026年) | Donghai 2026年跑步日志(5月开始) | Donghai 2FA | Donghai 初尝Github Actions | Donghai AstroPaper主题添加Waline评论 | Donghai Dynamics 365集中视图/聚焦视图/Focused View | Donghai AstroPaper主题添加GitHub风格的Markdown警告框 | Donghai 我日常收藏的优质网站资源导航(持续更新) | Donghai 如何从归档页批量获取URL并提交到Bing Webmaster Tools | Donghai PaperMod 使用 Zeoseven 自定义网页字体 | Donghai 我常用的Prompt | Donghai Hugo默认时区导致本地预览文章不显示 | Donghai 通过手动提交工单解决Bing不收录网站问题 | Donghai 如何访问 Power BI 管理门户(Power BI Admin Portal) | Donghai 还在手敲时间戳?Win11输入法一个技巧,秒输当前时间戳 | Donghai 工作术语备忘录(持续更新) | Donghai 使用XrmToolBox导出安全角色表级权限到Excel | Donghai 24年的年终总结 | Donghai World笔记 | Donghai Excel笔记 | Donghai
AstroPaper主题自定义记录 | Donghai
Donghai · 2026-02-28 · via Donghai's Blog

添加Waline评论功能

另起了一篇文章记录,详见:《AstroPaper主题添加Waline评论》

之前的博客RSS订阅链接是 /index.xml ,但 AstroPaper RSS订阅链接是 /rss.xml,为了不影响订阅源,需要做点修改

1.重命名文件

src\pages\rss.xml.ts 重命名为 src\pages\index.xml.ts

2.修改其他页面的路由配置

全局搜索 rss.xml ,检查有哪些页面使用了它,然后修改为 index.xml

设置 slug

因为有一些文章迁移过来,我不想影响原因的文章链接,所以需要设置 slus ,但是我发现虽然设置了,却没有效果,例如:

---
pubDatetime: 2022-09-23T15:22:00Z
modDatetime: 2025-06-13T16:52:45.934Z
title: 在AstroPaper主题中添加新帖子(译)
slug: doc/adding-new-posts-in-astropaper-theme
featured: true
draft: false
tags:
  - astro-paper
  - docs
description: 在使用 AstroPaper 主题创建或添加新帖子时的一些规则和建议
---

<!-- 文章的其余部分 -->

文章路径是 src\data\blog\astro-paper\adding-new-post.md,在浏览器预览这篇文章的链接却是 http://localhost:4321/posts/astro-paper/adding-new-posts-in-astropaper-theme,并不是预期的 http://localhost:4321/doc/adding-new-posts-in-astropaper-theme

看了 src\utils\getPath.ts 源码后,发现问题出在这里:id 被当作了文件名处理,而不是完整路径,所以需要再点逻辑:

export function getPath(
  id: string,
  filePath: string | undefined,
  includeBase = true
) {
  // 检查 id 是否包含自定义路径
  if (id.includes('/')) {
    // 如果 id 包含 '/',直接使用完整 id
    const basePath = includeBase ? "/posts" : "";
    return [basePath, id].join("/");
  }

  // 原有逻辑保持不变...
  const pathSegments = filePath
    ?.replace(BLOG_PATH, "")
    .split("/")
    .filter(path => path !== "")
    .filter(path => !path.startsWith("_"))
    .slice(0, -1)
    .map(segment => slugifyStr(segment));

  const basePath = includeBase ? "/posts" : "";
  const blogId = id.split("/");
  const slug = blogId.length > 0 ? blogId.slice(-1) : blogId;

  if (!pathSegments || pathSegments.length < 1) {
    return [basePath, slug].join("/");
  }

  return [basePath, ...pathSegments, slug].join("/");
}

修改日期格式

将日期格式从 “4 Jan, 2024” 修改为 “2024-01-04”

---


// ...此处代码省略...

const isModified = modDatetime && modDatetime > pubDatetime;

// ...此处代码省略...

const date = datetime.format("D MMM, YYYY"); 
const date = datetime.format("YYYY-MM-DD"); 
---

<div class:list={["flex items-center gap-x-2 opacity-80", className]}>
// ...此处代码省略...
</div>
src/components/Datetime.astro

(完)

如果这篇文章刚好帮到了你,欢迎请我喝杯咖啡