diff --git a/src/routes/admin/+layout.server.ts b/src/routes/admin/+layout.server.ts
index ec238fd..8782bf2 100644
--- a/src/routes/admin/+layout.server.ts
+++ b/src/routes/admin/+layout.server.ts
@@ -1,7 +1,49 @@
import type { LayoutServerLoad } from './$types';
-export const load: LayoutServerLoad = async ({ locals }) => {
+export const load: LayoutServerLoad = async ({ locals, platform }) => {
+ const db = platform?.env?.DB;
+
+ let aliases = {
+ post: '文章',
+ page: '页面',
+ category: '分类',
+ tag: '标签'
+ };
+
+ let site = {
+ title: 'BlogFlare',
+ description: 'A high-performance blog powered by Cloudflare D1, R2, and KV.'
+ };
+
+ if (db) {
+ try {
+ const { results } = await db.prepare(
+ "SELECT key, value FROM settings WHERE key LIKE 'alias.%' OR key LIKE 'site.%'"
+ ).all();
+
+ if (results && results.length > 0) {
+ results.forEach((row: any) => {
+ if (row.key.startsWith('alias.')) {
+ const type = row.key.split('.')[1];
+ if (type && type in aliases) {
+ (aliases as any)[type] = row.value;
+ }
+ } else if (row.key.startsWith('site.')) {
+ const type = row.key.split('.')[1];
+ if (type && type in site) {
+ (site as any)[type] = row.value;
+ }
+ }
+ });
+ }
+ } catch (e) {
+ console.error('Failed to load settings', e);
+ }
+ }
+
return {
- user: locals.user
+ user: locals.user,
+ aliases,
+ site
};
};
diff --git a/src/routes/admin/+layout.svelte b/src/routes/admin/+layout.svelte
index 13e7abc..5635c92 100644
--- a/src/routes/admin/+layout.svelte
+++ b/src/routes/admin/+layout.svelte
@@ -17,24 +17,34 @@
- 后台管理 - BlogFlare
+ 后台管理 - {$page.data.site?.title || 'BlogFlare'}