diff --git a/app/Blog/Support/ThemeManager.php b/app/Blog/Support/ThemeManager.php
index 67b8311..c5c02b3 100644
--- a/app/Blog/Support/ThemeManager.php
+++ b/app/Blog/Support/ThemeManager.php
@@ -58,6 +58,7 @@ class ThemeManager
'description' => $manifest['description'] ?? '',
'author' => $manifest['author'] ?? '',
'screenshot' => $manifest['screenshot'] ?? null,
+ 'inject_points' => $manifest['inject_points'] ?? null,
'active' => $name === $this->active(),
];
}
diff --git a/app/Filament/Pages/ThemeInject.php b/app/Filament/Pages/ThemeInject.php
index 3e59aaf..b9e5063 100644
--- a/app/Filament/Pages/ThemeInject.php
+++ b/app/Filament/Pages/ThemeInject.php
@@ -51,16 +51,17 @@ class ThemeInject extends Page
$tabs[] = Tab::make(($i + 1).'. '.$label)
->schema([
Repeater::make("inject.{$point}")
- ->label('注入块(可多条,按排序渲染)')
+ ->label('注入块(可多条,拖拽排序,按顺序渲染)')
->schema([
TextInput::make('title')->label('名称')->placeholder('如:百度统计')->columnSpan(2),
Textarea::make('html')->label('内容(HTML)')->rows(3)->columnSpanFull(),
- TextInput::make('sort')->label('排序')->numeric()->default(0)->columnSpan(1),
- Toggle::make('enabled')->label('启用')->default(true)->columnSpan(1),
+ Toggle::make('enabled')->label('启用')->default(true),
])
->columns(3)
->defaultItems(0)
->collapsible()
+ ->reorderable()
+ ->reorderableWithButtons()
->addActionLabel('添加一条'),
]);
$i++;
@@ -90,6 +91,7 @@ class ThemeInject extends Page
$blocks = [];
foreach ($data['inject'] ?? [] as $point => $items) {
+ $order = 0;
foreach ($items ?? [] as $item) {
if (trim((string) ($item['html'] ?? '')) === '') {
continue;
@@ -98,7 +100,7 @@ class ThemeInject extends Page
'point' => $point,
'title' => $item['title'] ?? '',
'html' => $item['html'],
- 'sort' => (int) ($item['sort'] ?? 0),
+ 'sort' => $order++,
'enabled' => (bool) ($item['enabled'] ?? true),
];
}
diff --git a/docs/themes.md b/docs/themes.md
index f6fbc2c..a6e8db5 100644
--- a/docs/themes.md
+++ b/docs/themes.md
@@ -22,7 +22,8 @@ themes/{name}/
"version": "1.0.0",
"description": "主题描述",
"author": "作者",
- "screenshot": "screenshot.png"
+ "screenshot": "screenshot.png",
+ "inject_points": ["head", "header", "sidebar_top", "sidebar_bottom", "content_top", "content_bottom", "post_content_top", "post_content_bottom", "footer", "body_end"]
}
```
@@ -124,6 +125,10 @@ themes/{name}/
新主题须在对应 partial/视图放置 `@stack('theme:xxx')` 才能接收注入。
+**声明注入点**:`theme.json` 的 `inject_points` 声明主题实现了哪些注入点(缺省视为全部支持),后台主题卡片会展示,切换主题时一目了然。
+
+**多注入排序**:同一位置可添加多条,后台「主题注入」页按列表拖拽排序,保存后按顺序渲染。
+
## 预览图
`theme.json` 的 `screenshot` 指向 `assets/` 下的预览图(如 `screenshot.png`),后台主题管理以卡片形式展示。可用无头浏览器截图生成:`node` + playwright 打开站点首页保存为 `themes/{name}/assets/screenshot.png`。
diff --git a/resources/views/filament/pages/themes.blade.php b/resources/views/filament/pages/themes.blade.php
index 416d44f..aeb90e7 100644
--- a/resources/views/filament/pages/themes.blade.php
+++ b/resources/views/filament/pages/themes.blade.php
@@ -29,6 +29,14 @@
{{ $theme['description'] }}
{{ $theme['author'] }}
+ @if($theme['inject_points'])
+
+ @foreach($theme['inject_points'] as $point)
+ {{ $point }}
+ @endforeach
+
+ @endif
+
@if(! $theme['active'])
启用
diff --git a/storage/media-library/temp/3LgsCbOmJVsiTDvceIc3O4fnQKFrPpy6/ZAMGqI8aqxda4o9haCGbwD5ef3nYdJp8thumb.jpg b/storage/media-library/temp/3LgsCbOmJVsiTDvceIc3O4fnQKFrPpy6/ZAMGqI8aqxda4o9haCGbwD5ef3nYdJp8thumb.jpg
new file mode 100644
index 0000000..7e754f4
--- /dev/null
+++ b/storage/media-library/temp/3LgsCbOmJVsiTDvceIc3O4fnQKFrPpy6/ZAMGqI8aqxda4o9haCGbwD5ef3nYdJp8thumb.jpg
@@ -0,0 +1 @@
+fake-jpg
\ No newline at end of file
diff --git a/storage/media-library/temp/3LgsCbOmJVsiTDvceIc3O4fnQKFrPpy6/dGNZX3r4ymbDwHD7YHMMymdKdnFLmeK7.jpg b/storage/media-library/temp/3LgsCbOmJVsiTDvceIc3O4fnQKFrPpy6/dGNZX3r4ymbDwHD7YHMMymdKdnFLmeK7.jpg
new file mode 100644
index 0000000..7e754f4
--- /dev/null
+++ b/storage/media-library/temp/3LgsCbOmJVsiTDvceIc3O4fnQKFrPpy6/dGNZX3r4ymbDwHD7YHMMymdKdnFLmeK7.jpg
@@ -0,0 +1 @@
+fake-jpg
\ No newline at end of file
diff --git a/storage/media-library/temp/8w5F5jhIWw6lEHQYcgt4PlyYriEtjb3Q/htkfmmxJKkEiiB2rDhw1iZGCB2wUzSEQthumb.jpg b/storage/media-library/temp/8w5F5jhIWw6lEHQYcgt4PlyYriEtjb3Q/htkfmmxJKkEiiB2rDhw1iZGCB2wUzSEQthumb.jpg
new file mode 100644
index 0000000..7e754f4
--- /dev/null
+++ b/storage/media-library/temp/8w5F5jhIWw6lEHQYcgt4PlyYriEtjb3Q/htkfmmxJKkEiiB2rDhw1iZGCB2wUzSEQthumb.jpg
@@ -0,0 +1 @@
+fake-jpg
\ No newline at end of file
diff --git a/storage/media-library/temp/8w5F5jhIWw6lEHQYcgt4PlyYriEtjb3Q/wSFl94T1KDrHinkABVgGiEgba00Su4lr.jpg b/storage/media-library/temp/8w5F5jhIWw6lEHQYcgt4PlyYriEtjb3Q/wSFl94T1KDrHinkABVgGiEgba00Su4lr.jpg
new file mode 100644
index 0000000..7e754f4
--- /dev/null
+++ b/storage/media-library/temp/8w5F5jhIWw6lEHQYcgt4PlyYriEtjb3Q/wSFl94T1KDrHinkABVgGiEgba00Su4lr.jpg
@@ -0,0 +1 @@
+fake-jpg
\ No newline at end of file
diff --git a/storage/media-library/temp/KBwbPLNjzsKThrqGRrTvW53urtu722kk/MFYiirHfxd5gK4wDtBBp80FcfCRUdNyK.jpg b/storage/media-library/temp/KBwbPLNjzsKThrqGRrTvW53urtu722kk/MFYiirHfxd5gK4wDtBBp80FcfCRUdNyK.jpg
new file mode 100644
index 0000000..7e754f4
--- /dev/null
+++ b/storage/media-library/temp/KBwbPLNjzsKThrqGRrTvW53urtu722kk/MFYiirHfxd5gK4wDtBBp80FcfCRUdNyK.jpg
@@ -0,0 +1 @@
+fake-jpg
\ No newline at end of file
diff --git a/storage/media-library/temp/KBwbPLNjzsKThrqGRrTvW53urtu722kk/pjZkVtGPK29Adv8KqpoRVu6FcAGXrlLUthumb.jpg b/storage/media-library/temp/KBwbPLNjzsKThrqGRrTvW53urtu722kk/pjZkVtGPK29Adv8KqpoRVu6FcAGXrlLUthumb.jpg
new file mode 100644
index 0000000..7e754f4
--- /dev/null
+++ b/storage/media-library/temp/KBwbPLNjzsKThrqGRrTvW53urtu722kk/pjZkVtGPK29Adv8KqpoRVu6FcAGXrlLUthumb.jpg
@@ -0,0 +1 @@
+fake-jpg
\ No newline at end of file
diff --git a/storage/media-library/temp/ap7ldtmCAFTJs6pdCsSem4lolt2hgDlU/F7uzMmx38wSSGmC5lDWunuK8V6r6rHTB.jpg b/storage/media-library/temp/ap7ldtmCAFTJs6pdCsSem4lolt2hgDlU/F7uzMmx38wSSGmC5lDWunuK8V6r6rHTB.jpg
new file mode 100644
index 0000000..7e754f4
--- /dev/null
+++ b/storage/media-library/temp/ap7ldtmCAFTJs6pdCsSem4lolt2hgDlU/F7uzMmx38wSSGmC5lDWunuK8V6r6rHTB.jpg
@@ -0,0 +1 @@
+fake-jpg
\ No newline at end of file
diff --git a/storage/media-library/temp/ap7ldtmCAFTJs6pdCsSem4lolt2hgDlU/HbXQXi9JOzrrJeub5t6BSVl2t1J3pW0othumb.jpg b/storage/media-library/temp/ap7ldtmCAFTJs6pdCsSem4lolt2hgDlU/HbXQXi9JOzrrJeub5t6BSVl2t1J3pW0othumb.jpg
new file mode 100644
index 0000000..7e754f4
--- /dev/null
+++ b/storage/media-library/temp/ap7ldtmCAFTJs6pdCsSem4lolt2hgDlU/HbXQXi9JOzrrJeub5t6BSVl2t1J3pW0othumb.jpg
@@ -0,0 +1 @@
+fake-jpg
\ No newline at end of file
diff --git a/storage/media-library/temp/qVI699Hc4ZNCdjZVA2wfjqr21yNp4bJf/BHafCkGbIxqqEHqLCbDRTwnjs8Z1Ekl2thumb.jpg b/storage/media-library/temp/qVI699Hc4ZNCdjZVA2wfjqr21yNp4bJf/BHafCkGbIxqqEHqLCbDRTwnjs8Z1Ekl2thumb.jpg
new file mode 100644
index 0000000..7e754f4
--- /dev/null
+++ b/storage/media-library/temp/qVI699Hc4ZNCdjZVA2wfjqr21yNp4bJf/BHafCkGbIxqqEHqLCbDRTwnjs8Z1Ekl2thumb.jpg
@@ -0,0 +1 @@
+fake-jpg
\ No newline at end of file
diff --git a/storage/media-library/temp/qVI699Hc4ZNCdjZVA2wfjqr21yNp4bJf/jn2dsLP9FTsdYFgCMwRtijLbJu979mnf.jpg b/storage/media-library/temp/qVI699Hc4ZNCdjZVA2wfjqr21yNp4bJf/jn2dsLP9FTsdYFgCMwRtijLbJu979mnf.jpg
new file mode 100644
index 0000000..7e754f4
--- /dev/null
+++ b/storage/media-library/temp/qVI699Hc4ZNCdjZVA2wfjqr21yNp4bJf/jn2dsLP9FTsdYFgCMwRtijLbJu979mnf.jpg
@@ -0,0 +1 @@
+fake-jpg
\ No newline at end of file
diff --git a/themes/modern/theme.json b/themes/modern/theme.json
index 5dc0c54..274319d 100644
--- a/themes/modern/theme.json
+++ b/themes/modern/theme.json
@@ -3,5 +3,17 @@
"version": "1.0.0",
"description": "极简现代风格,支持深色模式",
"author": "LaraLog",
- "screenshot": "screenshot.png"
+ "screenshot": "screenshot.png",
+ "inject_points": [
+ "head",
+ "header",
+ "sidebar_top",
+ "sidebar_bottom",
+ "content_top",
+ "content_bottom",
+ "post_content_top",
+ "post_content_bottom",
+ "footer",
+ "body_end"
+ ]
}
\ No newline at end of file
diff --git a/themes/sablog/theme.json b/themes/sablog/theme.json
index bf9dd96..d8f57b1 100644
--- a/themes/sablog/theme.json
+++ b/themes/sablog/theme.json
@@ -3,5 +3,17 @@
"version": "1.0.0",
"description": "移植自 SaBlog-X 经典两栏风格",
"author": "LaraLog",
- "screenshot": "screenshot.png"
+ "screenshot": "screenshot.png",
+ "inject_points": [
+ "head",
+ "header",
+ "sidebar_top",
+ "sidebar_bottom",
+ "content_top",
+ "content_bottom",
+ "post_content_top",
+ "post_content_bottom",
+ "footer",
+ "body_end"
+ ]
}
\ No newline at end of file