Compare commits

...

2 Commits

Author SHA1 Message Date
e1c5362cf5 blog: adjust tags for some essays
All checks were successful
Build blog docker image / Build-Blog-Image (push) Successful in 1m12s
2025-01-25 14:36:12 +08:00
bdcfed5506 fix: failed to handle images in draft. 2025-01-25 14:27:20 +08:00
12 changed files with 24 additions and 15 deletions

View File

@ -7,7 +7,8 @@ using YaeBlog.Models;
namespace YaeBlog.Processors;
public class ImagePostRenderProcessor(ILogger<ImagePostRenderProcessor> logger,
public class ImagePostRenderProcessor(
ILogger<ImagePostRenderProcessor> logger,
IOptions<BlogOptions> options)
: IPostRenderProcessor
{
@ -29,22 +30,27 @@ public class ImagePostRenderProcessor(ILogger<ImagePostRenderProcessor> logger,
if (attr is not null)
{
logger.LogDebug("Found image link: '{}'", attr.Value);
attr.Value = GenerateImageLink(attr.Value, essay.FileName);
attr.Value = GenerateImageLink(attr.Value, essay.FileName, essay.IsDraft);
}
}
return essay.WithNewHtmlContent(html.DocumentElement.OuterHtml);
}
public string Name => nameof(ImagePostRenderProcessor);
private string GenerateImageLink(string filename, string essayFilename)
private string GenerateImageLink(string filename, string essayFilename, bool isDraft)
{
// 如果图片路径中没有包含文件名
// 则添加文件名
if (!filename.Contains(essayFilename))
{
filename = Path.Combine(essayFilename, filename);
}
filename = Path.Combine(_options.Root, "posts", filename);
filename = isDraft
? Path.Combine(_options.Root, "drafts", filename)
: Path.Combine(_options.Root, "posts", filename);
if (!Path.Exists(filename))
{

View File

@ -2,7 +2,8 @@
title: 2021年终总结
date: 2022-01-12 16:27:19
tags:
- 随笔
- 杂谈
- 年终总结
---
2021年已经过去2022年已经来临。每每一年开始的时候我都会展开一张纸或者新建一个文档思量着又是一年时光也该同诸大杂志一般写几句意味深长的话语怀念过去的时光也祝福未来的自己。可往往脑海中已是三万字的长篇落在笔头却又是一个字都没有了。

View File

@ -1,7 +1,8 @@
---
title: 2022年终总结
tags:
- 随笔
- 杂谈
- 年终总结
date: 2022-12-30 14:58:12
---

View File

@ -1,7 +1,7 @@
---
title: 2022年暑假碎碎念
tags:
- 随笔
- 杂谈
typora-root-url: 2022-summer-vacation
date: 2022-08-22 15:39:13
---

View File

@ -1,7 +1,8 @@
---
title: 2023年年终总结
tags:
- 随笔
- 杂谈
- 年终总结
date: 2024-2-29 20:18:19
---

View File

@ -1,7 +1,7 @@
---
title: 人生代码大作业初体验
tags:
- 随笔
- 杂谈
typora-root-url: big-homework
date: 2022-07-27 11:34:49
---

View File

@ -2,7 +2,7 @@
title: 日用Linux挑战 第0篇 初见Arch Linux
tags:
- Linux
- 随笔
- 杂谈
date: 2023-01-15 22:23:08
typora-root-url: daily-linux-0
---

View File

@ -2,7 +2,7 @@
title: 日用Linux挑战 第1篇 问题与挑战
tags:
- Linux
- 随笔
- 杂谈
date: 2023-03-08 22:37:29
---

View File

@ -1,7 +1,7 @@
---
title: 日用Linux挑战 第2篇 Wayland
tags:
- 随笔
- 杂谈
- Linux
date: 2023-07-23 11:44:34
typora-root-url: daily-linux-2

View File

@ -1,7 +1,7 @@
---
title: 日用Linux挑战 第3篇 放弃Wayland
tags:
- 随笔
- 杂谈
- Linux
typora-root-url: daily-linux-3
date: 2023-09-04 14:47:46

View File

@ -2,7 +2,7 @@
title: 日用Linux挑战 第4篇 新的开始
tags:
- Linux
- 随笔
- 杂谈
date: 2024/03/09 14:00:00
---

View File

@ -1,7 +1,7 @@
---
title: 大学生用啥配置——计算机专业
tags:
- 随笔
- 杂谈
typora-root-url: laptop-for-computer
date: 2022-06-13 16:17:27
---