Compare commits
4 Commits
master
...
feat-highl
Author | SHA1 | Date | |
---|---|---|---|
91501cd4d3 | |||
10b4cef4c1 | |||
4fd464fd34 | |||
d9c17720dc |
|
@ -7,8 +7,7 @@ using YaeBlog.Models;
|
||||||
|
|
||||||
namespace YaeBlog.Processors;
|
namespace YaeBlog.Processors;
|
||||||
|
|
||||||
public class ImagePostRenderProcessor(
|
public class ImagePostRenderProcessor(ILogger<ImagePostRenderProcessor> logger,
|
||||||
ILogger<ImagePostRenderProcessor> logger,
|
|
||||||
IOptions<BlogOptions> options)
|
IOptions<BlogOptions> options)
|
||||||
: IPostRenderProcessor
|
: IPostRenderProcessor
|
||||||
{
|
{
|
||||||
|
@ -30,27 +29,22 @@ public class ImagePostRenderProcessor(
|
||||||
if (attr is not null)
|
if (attr is not null)
|
||||||
{
|
{
|
||||||
logger.LogDebug("Found image link: '{}'", attr.Value);
|
logger.LogDebug("Found image link: '{}'", attr.Value);
|
||||||
attr.Value = GenerateImageLink(attr.Value, essay.FileName, essay.IsDraft);
|
attr.Value = GenerateImageLink(attr.Value, essay.FileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return essay.WithNewHtmlContent(html.DocumentElement.OuterHtml);
|
return essay.WithNewHtmlContent(html.DocumentElement.OuterHtml);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Name => nameof(ImagePostRenderProcessor);
|
public string Name => nameof(ImagePostRenderProcessor);
|
||||||
|
|
||||||
private string GenerateImageLink(string filename, string essayFilename, bool isDraft)
|
private string GenerateImageLink(string filename, string essayFilename)
|
||||||
{
|
{
|
||||||
// 如果图片路径中没有包含文件名
|
|
||||||
// 则添加文件名
|
|
||||||
if (!filename.Contains(essayFilename))
|
if (!filename.Contains(essayFilename))
|
||||||
{
|
{
|
||||||
filename = Path.Combine(essayFilename, filename);
|
filename = Path.Combine(essayFilename, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
filename = isDraft
|
filename = Path.Combine(_options.Root, "posts", filename);
|
||||||
? Path.Combine(_options.Root, "drafts", filename)
|
|
||||||
: Path.Combine(_options.Root, "posts", filename);
|
|
||||||
|
|
||||||
if (!Path.Exists(filename))
|
if (!Path.Exists(filename))
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,8 +2,7 @@
|
||||||
title: 2021年终总结
|
title: 2021年终总结
|
||||||
date: 2022-01-12 16:27:19
|
date: 2022-01-12 16:27:19
|
||||||
tags:
|
tags:
|
||||||
- 杂谈
|
- 随笔
|
||||||
- 年终总结
|
|
||||||
---
|
---
|
||||||
|
|
||||||
2021年已经过去,2022年已经来临。每每一年开始的时候,我都会展开一张纸或者新建一个文档,思量着又是一年时光,也该同诸大杂志一般,写几句意味深长的话语,怀念过去的时光,也祝福未来的自己。可往往脑海中已是三万字的长篇,落在笔头却又是一个字都没有了。
|
2021年已经过去,2022年已经来临。每每一年开始的时候,我都会展开一张纸或者新建一个文档,思量着又是一年时光,也该同诸大杂志一般,写几句意味深长的话语,怀念过去的时光,也祝福未来的自己。可往往脑海中已是三万字的长篇,落在笔头却又是一个字都没有了。
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
---
|
---
|
||||||
title: 2022年终总结
|
title: 2022年终总结
|
||||||
tags:
|
tags:
|
||||||
- 杂谈
|
- 随笔
|
||||||
- 年终总结
|
|
||||||
date: 2022-12-30 14:58:12
|
date: 2022-12-30 14:58:12
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
title: 2022年暑假碎碎念
|
title: 2022年暑假碎碎念
|
||||||
tags:
|
tags:
|
||||||
- 杂谈
|
- 随笔
|
||||||
typora-root-url: 2022-summer-vacation
|
typora-root-url: 2022-summer-vacation
|
||||||
date: 2022-08-22 15:39:13
|
date: 2022-08-22 15:39:13
|
||||||
---
|
---
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
---
|
---
|
||||||
title: 2023年年终总结
|
title: 2023年年终总结
|
||||||
tags:
|
tags:
|
||||||
- 杂谈
|
- 随笔
|
||||||
- 年终总结
|
|
||||||
date: 2024-2-29 20:18:19
|
date: 2024-2-29 20:18:19
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
title: 人生代码大作业初体验
|
title: 人生代码大作业初体验
|
||||||
tags:
|
tags:
|
||||||
- 杂谈
|
- 随笔
|
||||||
typora-root-url: big-homework
|
typora-root-url: big-homework
|
||||||
date: 2022-07-27 11:34:49
|
date: 2022-07-27 11:34:49
|
||||||
---
|
---
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
title: 日用Linux挑战 第0篇 初见Arch Linux
|
title: 日用Linux挑战 第0篇 初见Arch Linux
|
||||||
tags:
|
tags:
|
||||||
- Linux
|
- Linux
|
||||||
- 杂谈
|
- 随笔
|
||||||
date: 2023-01-15 22:23:08
|
date: 2023-01-15 22:23:08
|
||||||
typora-root-url: daily-linux-0
|
typora-root-url: daily-linux-0
|
||||||
---
|
---
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
title: 日用Linux挑战 第1篇 问题与挑战
|
title: 日用Linux挑战 第1篇 问题与挑战
|
||||||
tags:
|
tags:
|
||||||
- Linux
|
- Linux
|
||||||
- 杂谈
|
- 随笔
|
||||||
date: 2023-03-08 22:37:29
|
date: 2023-03-08 22:37:29
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
title: 日用Linux挑战 第2篇 Wayland
|
title: 日用Linux挑战 第2篇 Wayland
|
||||||
tags:
|
tags:
|
||||||
- 杂谈
|
- 随笔
|
||||||
- Linux
|
- Linux
|
||||||
date: 2023-07-23 11:44:34
|
date: 2023-07-23 11:44:34
|
||||||
typora-root-url: daily-linux-2
|
typora-root-url: daily-linux-2
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
title: 日用Linux挑战 第3篇 放弃Wayland
|
title: 日用Linux挑战 第3篇 放弃Wayland
|
||||||
tags:
|
tags:
|
||||||
- 杂谈
|
- 随笔
|
||||||
- Linux
|
- Linux
|
||||||
typora-root-url: daily-linux-3
|
typora-root-url: daily-linux-3
|
||||||
date: 2023-09-04 14:47:46
|
date: 2023-09-04 14:47:46
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
title: 日用Linux挑战 第4篇 新的开始
|
title: 日用Linux挑战 第4篇 新的开始
|
||||||
tags:
|
tags:
|
||||||
- Linux
|
- Linux
|
||||||
- 杂谈
|
- 随笔
|
||||||
date: 2024/03/09 14:00:00
|
date: 2024/03/09 14:00:00
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
title: 大学生用啥配置——计算机专业
|
title: 大学生用啥配置——计算机专业
|
||||||
tags:
|
tags:
|
||||||
- 杂谈
|
- 随笔
|
||||||
typora-root-url: laptop-for-computer
|
typora-root-url: laptop-for-computer
|
||||||
date: 2022-06-13 16:17:27
|
date: 2022-06-13 16:17:27
|
||||||
---
|
---
|
||||||
|
|
Loading…
Reference in New Issue
Block a user