@@ -74,7 +74,7 @@
-# Client download
+# Client download :id=install
[install](../commont/install.md ':include')
@@ -82,7 +82,7 @@ Current version: v1.0.0 [✨ What's new?](https://github.com/wonder-light/glidea
______
-### Other
+### Other :id=other
[Source address](https://github.com/wonder-light/glidea)
diff --git a/docs/en-us/docs/_sidebar.md b/docs/en-us/docs/_sidebar.md
index 173319e..2afce90 100644
--- a/docs/en-us/docs/_sidebar.md
+++ b/docs/en-us/docs/_sidebar.md
@@ -9,6 +9,7 @@
* [Variable](en-us/docs/theme/var.md)
* [Custom](en-us/docs/theme/custom.md)
* [Share](en-us/docs/theme/shared.md)
+ * [Render](en-us/docs/theme/render.md)
* Guide
* [Install](en-us/docs/guide/install.md)
* [FAQ](en-us/docs/guide/faq.md)
diff --git a/docs/en-us/docs/changelog.md b/docs/en-us/docs/changelog.md
index 238e274..d60ff1f 100644
--- a/docs/en-us/docs/changelog.md
+++ b/docs/en-us/docs/changelog.md
@@ -1,4 +1,4 @@
-# Change Log
+# Change Log :id=changelog
[filename](https://raw.githubusercontent.com/wonder-light/glidea/refs/heads/main/CHANGELOG-en.md ':include')
\ No newline at end of file
diff --git a/docs/en-us/docs/guide/faq.md b/docs/en-us/docs/guide/faq.md
index b0730cc..227523e 100644
--- a/docs/en-us/docs/guide/faq.md
+++ b/docs/en-us/docs/guide/faq.md
@@ -1,3 +1,3 @@
-# FAQ
+# FAQ :id=faq
## 1
\ No newline at end of file
diff --git a/docs/en-us/docs/guide/install.md b/docs/en-us/docs/guide/install.md
index d8ad939..f8c5597 100644
--- a/docs/en-us/docs/guide/install.md
+++ b/docs/en-us/docs/guide/install.md
@@ -1,4 +1,4 @@
-# Installing the client
+# Installing the client :id=install
[install](../../../commont/install.md ':include')
diff --git a/docs/en-us/docs/theme/custom.md b/docs/en-us/docs/theme/custom.md
index 22f04b2..dd9bc9f 100644
--- a/docs/en-us/docs/theme/custom.md
+++ b/docs/en-us/docs/theme/custom.md
@@ -1,5 +1,5 @@
-# Theme customization
+# Theme customization :id=theme-custom
> Glidea provides powerful theme customization capabilities, you can design your own custom configuration to provide theme users
@@ -8,7 +8,7 @@ Each theme is optionally paired with a `config.json` configuration file and a `s
## Example :id=example
-### config.json
+### config.json :id=config
```json
{
@@ -102,7 +102,7 @@ Each theme is optionally paired with a `config.json` configuration file and a `s
}
```
-### style-override.dart
+### style-override.dart :id=style-override
```django
{# Dark skin #}
@@ -208,6 +208,7 @@ the format for each element is as follows:
}
```
+
## Array type configuration :id=array-config
```json
@@ -266,10 +267,11 @@ the format for each element is as follows:
In most cases, using the input type is sufficient
-These fields can be used either in the template (corresponding to: [`site.customconfig.customField`](#configjson)) or in the style overlay file (corresponding to: input)
+These fields can be used either in the template (corresponding to: [`site.customconfig.customField`](#config)) or in the style overlay file (corresponding to: input)
When used in the template, you can play your imagination, social, statistics, friend chain, external chain background map, background music...
+
## Style overlay configuration :id=style-override
Of course, it can also be used in style overlay files:
diff --git a/docs/en-us/docs/theme/dev.md b/docs/en-us/docs/theme/dev.md
index a030ba5..ec15073 100644
--- a/docs/en-us/docs/theme/dev.md
+++ b/docs/en-us/docs/theme/dev.md
@@ -115,4 +115,9 @@ Macros can then be called like functions:
``` django
{{ input('username') }}
{{ input('password', type='password') }}
Due to the use of commands to start the program, there are cases that some devices do not support\
+Please explain how to use good friends!
+
+## Set custom :id=custom
+
+Add the `process` field to `config.json` and use the node.js example
+
+```json
+//
/config.json
+{
+ "name": "fog",
+ "version": "1.0",
+ "author": "wonder-light",
+ "repository": "https://github.com/wonder-light/glidea-theme-fog",
+ "process": "node ./index.js",
+ "customConfig": {}
+}
+```
+
+### Argument :id=params
+
+The output path and the path to render data are injected \
+at the end of the command before starting the program, and also in 'env'
+
+```shell
+node ./index.js
+#=>
+node ./index.js C:/.../output C:/.../render/config.json
+# There is a path.json directory in the config.json sibling directory to refer to the path writing
+```
+
+### Environment :id=env
+
+```js
+console.log(process.argv[process.argv.length - 2]);
+// C:/.../output
+
+console.log(process.argv[process.argv.length - 1]);
+// C:/.../render/config.json
+
+console.log(process.env['buildDir']);
+// C:/.../output
+
+console.log(process.env['renderData']);
+// C:/.../render/config.json
+
+console.log(process.env['renderPath']);
+// C:/.../render/paths.json
+```
+
diff --git a/docs/en-us/docs/theme/shared.md b/docs/en-us/docs/theme/shared.md
index e9b1808..38c6290 100644
--- a/docs/en-us/docs/theme/shared.md
+++ b/docs/en-us/docs/theme/shared.md
@@ -1,4 +1,4 @@
-# Share Theme
+# Share Theme :id=share
> Share your theme with your friends on GitHub
diff --git a/docs/en-us/themes/README.md b/docs/en-us/themes/README.md
index 64851c3..cbdcdcb 100644
--- a/docs/en-us/themes/README.md
+++ b/docs/en-us/themes/README.md
@@ -1,4 +1,4 @@
-# Theme
+# Theme :id=theme
diff --git a/docs/zh-cn/docs/_sidebar.md b/docs/zh-cn/docs/_sidebar.md
index e69989e..9b62b1d 100644
--- a/docs/zh-cn/docs/_sidebar.md
+++ b/docs/zh-cn/docs/_sidebar.md
@@ -9,6 +9,7 @@
* [变量](zh-cn/docs/theme/var.md)
* [自定义](zh-cn/docs/theme/custom.md)
* [分享](zh-cn/docs/theme/shared.md)
+ * [渲染](zh-cn/docs/theme/render.md)
* 指南
* [安装](zh-cn/docs/guide/install.md)
* [常见问题](zh-cn/docs/guide/faq.md)
diff --git a/docs/zh-cn/docs/changelog.md b/docs/zh-cn/docs/changelog.md
index c4aa911..03a7af9 100644
--- a/docs/zh-cn/docs/changelog.md
+++ b/docs/zh-cn/docs/changelog.md
@@ -1,4 +1,4 @@
-# 更改日志
+# 更改日志 :id=changelog
[filename](https://raw.githubusercontent.com/wonder-light/glidea/refs/heads/main/CHANGELOG.md ':include')
\ No newline at end of file
diff --git a/docs/zh-cn/docs/guide/ability.md b/docs/zh-cn/docs/guide/ability.md
index af26007..c885b47 100644
--- a/docs/zh-cn/docs/guide/ability.md
+++ b/docs/zh-cn/docs/guide/ability.md
@@ -1,5 +1,5 @@
-# 功能
+# 功能 :id=ability
diff --git a/docs/zh-cn/docs/guide/faq.md b/docs/zh-cn/docs/guide/faq.md
index 9bf046a..571b1ff 100644
--- a/docs/zh-cn/docs/guide/faq.md
+++ b/docs/zh-cn/docs/guide/faq.md
@@ -1,3 +1,3 @@
-# 常见问题
+# 常见问题 :id=faq
## 1
\ No newline at end of file
diff --git a/docs/zh-cn/docs/theme/custom.md b/docs/zh-cn/docs/theme/custom.md
index fdc3d68..0c1ca38 100644
--- a/docs/zh-cn/docs/theme/custom.md
+++ b/docs/zh-cn/docs/theme/custom.md
@@ -1,5 +1,5 @@
-# 主题自定义
+# 主题自定义 :id=theme-custom
> Glidea 提供了强大的主题自定义能力,你可以自行设计自定义配置提供给主题使用者
@@ -8,7 +8,7 @@
## 示例 :id=example
-### config.json
+### config.json :id=config
```json
{
@@ -102,7 +102,7 @@
}
```
-### style-override.j2
+### style-override.j2 :id=style-override
```django
{# 暗黑皮肤 #}
@@ -208,6 +208,7 @@
}
```
+
## 数组类型配置 :id=array-config
```json
@@ -266,7 +267,7 @@
大部分情况下,使用 input 类型的就够用了
-这些字段都可以在模版中(对应: [`site.customConfig.自定义字段`](#configjson))或样式覆盖文件(对应:入参)中使用
+这些字段都可以在模版中(对应: [`site.customConfig.自定义字段`](#config))或样式覆盖文件(对应:入参)中使用
在模版中使用时,你可以尽情发挥你的想象,社交、统计、友链、外链背景图、背景音乐...
diff --git a/docs/zh-cn/docs/theme/dev.md b/docs/zh-cn/docs/theme/dev.md
index 48d2bba..19a9209 100644
--- a/docs/zh-cn/docs/theme/dev.md
+++ b/docs/zh-cn/docs/theme/dev.md
@@ -112,4 +112,8 @@
``` django
{{ input('username') }}
{{ input('password', type='password') }}
由于使用的是由命令来启动程序, 所以存在着部分设备不怎么支持的情况,\
+请各位小伙伴说明好使用办法哦!
+
+## 设置自定义 :id=custom
+
+在 `config.json` 中添加 `process` 字段即可, 接下来以 node.js 示例
+
+```json
+// <主题目录>/config.json
+{
+ "name": "fog",
+ "version": "1.0",
+ "author": "wonder-light",
+ "repository": "https://github.com/wonder-light/glidea-theme-fog",
+ "process": "node ./index.js",
+ "customConfig": {}
+}
+```
+
+### 参数 :id=params
+
+在启动程序前会在命令的后面注入输出路径和渲染数据所在路径, 也会在 `env` 中注入
+
+```shell
+node ./index.js
+#=>
+node ./index.js C:/.../output C:/.../render/config.json
+# 在 config.json 同级目录下有一个 paths.json 可以参考路径的写法
+```
+
+### 环境 :id=env
+
+```js
+console.log(process.argv[process.argv.length - 2]);
+// C:/.../output
+
+console.log(process.argv[process.argv.length - 1]);
+// C:/.../render/config.json
+
+console.log(process.env['buildDir']);
+// C:/.../output
+
+console.log(process.env['renderData']);
+// C:/.../render/config.json
+
+console.log(process.env['renderPath']);
+// C:/.../render/paths.json
+```
+
diff --git a/docs/zh-cn/docs/theme/shared.md b/docs/zh-cn/docs/theme/shared.md
index 041484e..d70915c 100644
--- a/docs/zh-cn/docs/theme/shared.md
+++ b/docs/zh-cn/docs/theme/shared.md
@@ -1,4 +1,4 @@
-# 分享主题
+# 分享主题 :id=share
> 将小伙伴你的主题分享到 Github 吧
diff --git a/docs/zh-cn/themes/README.md b/docs/zh-cn/themes/README.md
index 6fb6933..aa9b120 100644
--- a/docs/zh-cn/themes/README.md
+++ b/docs/zh-cn/themes/README.md
@@ -1,4 +1,4 @@
-# 主题
+# 主题 :id=theme
diff --git a/lib/helpers/render/render.dart b/lib/helpers/render/render.dart
index 59f3799..b541ce9 100644
--- a/lib/helpers/render/render.dart
+++ b/lib/helpers/render/render.dart
@@ -1,4 +1,4 @@
-import 'dart:io' show FileMode;
+import 'dart:io' show Directory, FileMode;
import 'dart:math' show min;
import 'package:glidea/helpers/constants.dart';
@@ -16,7 +16,8 @@ import 'package:glidea/models/post.dart';
import 'package:glidea/models/tag.dart';
import 'package:glidea/models/theme.dart';
import 'package:jinja/jinja.dart' show Environment;
-import 'package:jinja/loaders.dart';
+import 'package:jinja/loaders.dart' show FileSystemLoader;
+import 'package:process_runner/process_runner.dart' show ProcessRunner;
typedef _TChangeData = TChangeCallback;
@@ -30,16 +31,12 @@ final class RemoteRender {
/// 主题路径
late final String themePath = FS.join(site.appDir, 'themes', site.themeConfig.selectTheme);
+ /// 是否执行自定义模板解析
+ bool isCustom = false;
+
/// jinja 执行环境
late Environment env;
- /// 匹配 feature 本地图片路径的正则
- ///
- /// 'file://.*/post-images/' => '/post-images/'
- ///
- /// (?<=匹配开头).*(?=匹配结尾)
- late final RegExp featureReg = RegExp(featurePrefix + r'.*(?=/post-images)');
-
/// 渲染 post 的数据
final List postsData = [];
@@ -53,8 +50,18 @@ final class RemoteRender {
/// 菜单数据
List