Skip to content

Commit

Permalink
内容首行缩进功能
Browse files Browse the repository at this point in the history
  • Loading branch information
wenjing-xin committed Jun 16, 2024
1 parent dff1a51 commit 519b274
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 193 deletions.
11 changes: 11 additions & 0 deletions src/main/java/xin/wenjing/blogHao/entity/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public static class CopyAdd{
public static class MiniTool{
public final static String GROUP_NAME = "miniTools";
private ContentSpace contentSpace;
private ContentIndent contentIndent;
}

/**
Expand All @@ -43,4 +44,14 @@ public static class ContentSpace{
private String scanContent;
}

/**
* 小工具配置的子内容
* 文章内容首行缩进
*/
@Data
public static class ContentIndent{
private boolean enableContentIndent;
private String indentNodeName;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ private String finalScript(ITemplateContext context) {
injectCode.append(ScriptContentUtils.panguScript(miniTool));
}

// 段落内容首行缩进
if(miniTool.getContentIndent().isEnableContentIndent()){
injectCode.append("""
<style type="text/css"> %s p:not(li>p):not(blockquote>p){text-indent: 2em;} </style>
""".formatted(miniTool.getContentIndent().getIndentNodeName()));
}

return injectCode.toString();
}
}
27 changes: 26 additions & 1 deletion src/main/resources/extensions/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,29 @@ spec:
name: scanContent
value: "pangu.spacingElementByTagName('body');"
rows: 3
help: 写法参考 https://github.com/vinta/pangu.js
help: 写法参考 https://github.com/vinta/pangu.js
- $formkit: group
name: contentIndent
label: 文本内容首行缩进
help: 开启后则在段落的首行缩进两个空格
value:
enableContentIndent: false
indentNodeName:
children:
- $formkit: radio
name: enableContentIndent
key: enableContentIndent
id: enableContentIndent
help: 是否启用
value: false
options:
- label: 启用
value: true
- label: 禁用
value: false
- $formkit: text
if: $get(enableContentIndent).value
label: 内容缩进的节点类名或者ID名
name: indentNodeName
value: "#post"
help: 根据自己使用的主题选择要适配的内容节点
24 changes: 1 addition & 23 deletions ui/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,7 @@
import { definePlugin } from "@halo-dev/console-shared";
import HomeView from "./views/HomeView.vue";
import { IconPlug } from "@halo-dev/components";
import { markRaw } from "vue";

export default definePlugin({
components: {},
routes: [
{
parentName: "Root",
route: {
path: "/example",
name: "Example",
component: HomeView,
meta: {
title: "示例页面",
searchable: true,
menu: {
name: "示例页面",
group: "示例分组",
icon: markRaw(IconPlug),
priority: 0,
},
},
},
},
],
routes: [],
extensionPoints: {},
});
169 changes: 0 additions & 169 deletions ui/src/views/HomeView.vue

This file was deleted.

0 comments on commit 519b274

Please sign in to comment.