From 249dabd8319e38e29682a00dc27d9ae5254663f1 Mon Sep 17 00:00:00 2001 From: qianmoQ Date: Mon, 5 Jan 2026 12:06:50 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E6=94=AF=E6=8C=81=E9=BB=98=E8=AE=A4=20h=20?= =?UTF-8?q?=E6=A0=87=E7=AD=BE=E6=B8=B2=E6=9F=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- templates/components/header.js | 27 ++++----------------------- templates/components/span.js | 2 +- templates/layouts/base.ejs | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 25 deletions(-) diff --git a/package.json b/package.json index 2acb8cb..3bcba26 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pageforge", - "version": "2025.1.7", + "version": "2026.0.0", "description": "PageForge 是一款现代化的静态页面生成与部署平台,旨在帮助用户快速创建精美的静态网站,并一键部署到 GitHub Pages。 无论是个人博客、项目文档还是企业官网,PageForge 都能让你轻松实现高效构建、智能部署和即时上线。", "homepage": "https://pageforge.devlive.org", "repository": { diff --git a/templates/components/header.js b/templates/components/header.js index 6265d59..8932267 100644 --- a/templates/components/header.js +++ b/templates/components/header.js @@ -1,28 +1,9 @@ module.exports = function template(item) { - const divClass = () => { - const baseClasses = 'font-bold tracking-tight text-gray-900 dark:text-white my-3 [&_span]:!font-inherit [&_span]:!text-inherit [&_code]:!text-inherit'; - - switch (item.level) { - case 1: - return `text-3xl sm:text-4xl ${baseClasses} [&_span]:!text-3xl [&_span]:sm:!text-4xl`; - case 2: - return `text-2xl sm:text-3xl ${baseClasses} [&_span]:!text-2xl [&_span]:sm:!text-3xl`; - case 3: - return `text-xl sm:text-2xl ${baseClasses} [&_span]:!text-xl [&_span]:sm:!text-2xl`; - case 4: - return `text-lg sm:text-xl ${baseClasses} [&_span]:!text-lg [&_span]:sm:!text-xl`; - case 5: - return `text-md sm:text-lg ${baseClasses} [&_span]:!text-md [&_span]:sm:!text-lg`; - case 6: - return `text-sm sm:text-md ${baseClasses} [&_span]:!text-sm [&_span]:sm:!text-md`; - default: - return `text-base sm:text-lg ${baseClasses} [&_span]:!text-base [&_span]:sm:!text-lg`; - } - } + const tag = `h${item.level}`; return ` -
-
${item.text}
-
+ <${tag} id="${item.slug}"> + ${item.text} + `; }; \ No newline at end of file diff --git a/templates/components/span.js b/templates/components/span.js index 50b6805..6506183 100644 --- a/templates/components/span.js +++ b/templates/components/span.js @@ -1,5 +1,5 @@ module.exports = function template(item) { return ` - ${item.text} + ${item.text} `; }; \ No newline at end of file diff --git a/templates/layouts/base.ejs b/templates/layouts/base.ejs index 9cf115b..659b766 100644 --- a/templates/layouts/base.ejs +++ b/templates/layouts/base.ejs @@ -104,6 +104,39 @@ function buildPagePath(pagePath) { + From ca5e95c39ae87e0d3ba6f402a1db1777f08b3408 Mon Sep 17 00:00:00 2001 From: qianmoQ Date: Mon, 5 Jan 2026 13:25:09 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E9=80=9F=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/commands/build.js | 5 ++++- lib/dev-server.js | 8 ++++++-- lib/directory-processor.js | 17 +++++++++-------- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/lib/commands/build.js b/lib/commands/build.js index be2d1cb..e458f7a 100644 --- a/lib/commands/build.js +++ b/lib/commands/build.js @@ -9,6 +9,8 @@ class BuildCommand { } async execute(options = {}) { + const startTime = Date.now(); + try { let config = this.configManager.getConfig(); @@ -40,7 +42,8 @@ class BuildCommand { const generator = new SiteGenerator(config); await generator.generate(); - console.log('🎉 项目编译完成'); + const duration = ((Date.now() - startTime) / 1000).toFixed(2); + console.log(`🎉 项目编译完成,耗时: ${duration}s`); } catch (error) { throw new Error(`Build failed: ${error.message}`); diff --git a/lib/dev-server.js b/lib/dev-server.js index 5e9d516..258e2d7 100644 --- a/lib/dev-server.js +++ b/lib/dev-server.js @@ -13,8 +13,10 @@ class DevServer { async start() { // 首先构建一次 + const startTime = Date.now(); await this.generator.generate(); - console.log('🎉 项目编译完成'); + const duration = ((Date.now() - startTime) / 1000).toFixed(2); + console.log(`🎉 项目编译完成,耗时: ${duration}s`); const home = this.config?.version ? this.config.outputPath.replace(this.config.version, '') : this.config.outputPath; // 设置静态文件服务 @@ -73,8 +75,10 @@ class DevServer { console.log(`📄 文件 ${filepath} 已更新,正在重新编译...`); } + const startTime = Date.now(); await this.generator.generate(); - console.log('✓ 项目重新编译完成'); + const duration = ((Date.now() - startTime) / 1000).toFixed(2); + console.log(`✓ 项目重新编译完成,耗时: ${duration}s`); } catch (error) { console.error('🤯 项目文件重新编译失败 ', error); diff --git a/lib/directory-processor.js b/lib/directory-processor.js index cfe8ead..95803f1 100644 --- a/lib/directory-processor.js +++ b/lib/directory-processor.js @@ -183,7 +183,8 @@ class DirectoryProcessor { // 创建根目录重定向 this.createRootRedirect(); - for (const locale of this.getAvailableLocales()) { + // 并发处理多语言 + await Promise.all(this.getAvailableLocales().map(async (locale) => { console.log(`\n📂 处理语言: ${locale.key}`); // 创建语言目录 @@ -196,7 +197,7 @@ class DirectoryProcessor { const relativeToSource = path.relative(this.config.sourcePath, sourceDir); const initialBaseDir = path.join(locale.key, relativeToSource); await this.processDirectory(sourceDir, initialBaseDir, locale.key, this.config.sourcePath); - } + })); } else { await this.processDirectory(sourceDir, '', '', this.config.sourcePath); @@ -223,8 +224,8 @@ class DirectoryProcessor { console.log(`\n📂 处理目录: ${sourceDir}`); - // 处理子目录 - for (const file of files) { + // 并发处理子目录 + await Promise.all(files.map(async (file) => { const sourcePath = path.join(sourceDir, file); const stat = fs.statSync(sourcePath); @@ -233,11 +234,11 @@ class DirectoryProcessor { const nextBaseDir = locale ? path.join(locale, relativeToSource) : relativeToSource; await this.processDirectory(sourcePath, nextBaseDir, locale, rootSourceDir); } - } + })); - // 处理 Markdown 文件 + // 并发处理 Markdown 文件 const markdownFiles = files.filter(file => file.endsWith('.md')); - for (const file of markdownFiles) { + await Promise.all(markdownFiles.map(async (file) => { const relativeSourceDir = path.relative(rootSourceDir, sourceDir); const relativeBaseDir = locale ? path.join(locale, relativeSourceDir) : relativeSourceDir; @@ -248,7 +249,7 @@ class DirectoryProcessor { locale, rootSourceDir ); - } + })); // 处理其他文件 const otherFiles = files.filter(file => From 4aa1878aef45ab4d87c21f793b0ff37a21b20802 Mon Sep 17 00:00:00 2001 From: qianmoQ Date: Mon, 5 Jan 2026 14:09:03 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=94=B1=E4=BA=8E?= =?UTF-8?q?=E6=9C=AA=E8=8E=B7=E5=8F=96=20nav=20+=20banner=20=E9=AB=98?= =?UTF-8?q?=E5=BA=A6=E5=AF=BC=E8=87=B4=E9=A1=B5=E9=9D=A2=E6=8A=96=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/includes/header-banner.ejs | 4 ++-- templates/includes/repo.ejs | 4 ++-- templates/layouts/base.ejs | 10 ++++++++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/templates/includes/header-banner.ejs b/templates/includes/header-banner.ejs index 3808f98..ebd40be 100644 --- a/templates/includes/header-banner.ejs +++ b/templates/includes/header-banner.ejs @@ -1,6 +1,6 @@ <% if (locals.siteData?.banner?.content) { %> -
-
+
+
<% if (Array.isArray(locals.siteData.banner.content)) { %>