Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions docs/content/release/2026.0.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
title: 2026.0.0
---

我们很高兴地宣布 PageForge 2026.0.0 正式发布。PageForge 是一款现代化的静态页面生成与部署平台,致力于为用户提供从创建到部署的一站式解决方案。此版本主要增强了阅读体验相关功能。

## 新增功能

- 支持默认 h 标签渲染
- 优化构建速度
- 修复由于未获取 nav + banner 高度导致页面抖动
- 优化修改文件重新编译效率

## 链接

- GitHub: https://github.com/devlive-community/pageforge
- 官网: https://pageforge.devlive.org

## 反馈与支持

如果您在使用过程中遇到任何问题,请通过 GitHub Issues 向我们反馈。您的建议对我们至关重要!

---

此版本重点优化了构建效率,建议所有用户升级到此版本。
1 change: 1 addition & 0 deletions docs/pageforge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ nav:
- Technology:
- /technology/extension
- ReleaseNotes:
- /release/2026.0.0
- /release/2025.1.7
- /release/2025.1.6
- /release/2025.1.5
Expand Down
5 changes: 4 additions & 1 deletion lib/commands/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class BuildCommand {
}

async execute(options = {}) {
const startTime = Date.now();

try {
let config = this.configManager.getConfig();

Expand Down Expand Up @@ -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}`);
Expand Down
80 changes: 72 additions & 8 deletions lib/dev-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
// 设置静态文件服务
Expand Down Expand Up @@ -65,19 +67,81 @@ class DevServer {

async handleFileChange(filepath) {
try {
if (filepath.endsWith('pageforge.yaml')) {
console.log('📝 配置文件已更新,重新加载配置并重新编译...');
await this.generator.reloadConfig();
const startTime = Date.now();

// 配置文件或模板文件变化 - 全量编译
if (filepath.endsWith('pageforge.yaml') ||
filepath.includes('/templates/') ||
filepath.includes('\\templates\\')) {
console.log('📝 配置/模板文件已更新,全量重新编译...');
if (filepath.endsWith('pageforge.yaml')) {
await this.generator.reloadConfig();
}
await this.generator.generate();
}
// Markdown 文件变化 - 增量编译
else if (filepath.endsWith('.md')) {
console.log(`📄 Markdown 文件已更新: ${filepath}`);
await this.compileSingleMarkdown(filepath);
}
// 资源文件变化 - 复制资源
else if (this.config.assetsPath && filepath.startsWith(this.config.assetsPath)) {
console.log(`📦 资源文件已更新: ${filepath}`);
await this.generator.copyAssets();
}
// 其他文件 - 全量编译
else {
console.log(`📄 文件 ${filepath} 已更新,正在重新编译...`);
console.log(`📄 文件已更新: ${filepath},全量重新编译...`);
await this.generator.generate();
}

await this.generator.generate();
console.log('✓ 项目重新编译完成');
const duration = ((Date.now() - startTime) / 1000).toFixed(2);
console.log(`✓ 编译完成,耗时: ${duration}s`);
}
catch (error) {
console.error('🤯 项目文件重新编译失败 ', error);
console.error('🤯 编译失败:', error);
}
}

async compileSingleMarkdown(filepath) {
const fs = require('fs');

// 检查文件是否在源目录中
if (!filepath.startsWith(this.config.sourcePath)) {
console.log('文件不在源目录中,跳过编译');
return;
}

// 计算相对路径
const relativePath = path.relative(this.config.sourcePath, filepath);
const sourceDir = path.dirname(filepath);
const filename = path.basename(filepath);

// 判断是否启用国际化
if (this.config.feature?.i18n?.enable) {
// 多语言模式 - 为每个语言编译
const locales = Object.keys(this.config.i18n || {}).filter(key => key !== 'default');
for (const locale of locales) {
const relativeDir = path.relative(this.config.sourcePath, sourceDir);
const baseDir = path.join(locale, relativeDir);
await this.generator.directoryProcessor.fileProcessor.processMarkdownFile(
sourceDir,
baseDir,
filename,
locale,
this.config.sourcePath
);
}
} else {
// 单语言模式
const relativeDir = path.relative(this.config.sourcePath, sourceDir);
await this.generator.directoryProcessor.fileProcessor.processMarkdownFile(
sourceDir,
relativeDir,
filename,
'',
this.config.sourcePath
);
}
}
}
Expand Down
17 changes: 9 additions & 8 deletions lib/directory-processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);

// 创建语言目录
Expand All @@ -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);
Expand All @@ -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);

Expand All @@ -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;

Expand All @@ -248,7 +249,7 @@ class DirectoryProcessor {
locale,
rootSourceDir
);
}
}));

// 处理其他文件
const otherFiles = files.filter(file =>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
27 changes: 4 additions & 23 deletions templates/components/header.js
Original file line number Diff line number Diff line change
@@ -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 `
<div class="${divClass()}">
<div id="${item.slug}" class="inline-flex items-center">${item.text}</div>
</div>
<${tag} id="${item.slug}">
${item.text}
</${tag}>
`;
};
2 changes: 1 addition & 1 deletion templates/components/span.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = function template(item) {
return `
<span class="text-base text-gray-700 leading-7 my-2">${item.text}</span>
<span class="leading-7">${item.text}</span>
`;
};
4 changes: 2 additions & 2 deletions templates/includes/header-banner.ejs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% if (locals.siteData?.banner?.content) { %>
<div class="w-full bg-blue-50 <%= darkClasses('dark:bg-blue-900/20') %>" data-banner>
<div class="max-w-screen-xl px-6 py-3 mx-auto flex items-center justify-between">
<div class="w-full bg-blue-50 <%= darkClasses('dark:bg-blue-900/20') %> h-12" data-banner>
<div class="max-w-screen-xl px-6 mx-auto flex items-center justify-between h-full">
<% if (Array.isArray(locals.siteData.banner.content)) { %>
<div class="text-blue-700 <%= darkClasses('dark:text-blue-300') %> banner-container">
<div class="swiper banner-swiper">
Expand Down
4 changes: 2 additions & 2 deletions templates/includes/repo.ejs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<% if (locals.siteData.repo) { %>
<div class="hidden lg:flex items-center space-x-4 text-sm" id="github-stats-desktop">
<div class="hidden lg:flex items-center space-x-4 text-sm min-w-[200px]" id="github-stats-desktop">
<a href="<%= siteData.repo.url %>"
target="_blank"
rel="noopener noreferrer"
class="inline-flex items-center gap-3 text-gray-600 hover:text-gray-500 transition-colors">
class="inline-flex items-center gap-3 text-gray-600 hover:text-gray-500 transition-colors min-w-full">
<div class="inline-flex items-center">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" class="w-6 h-6">
<path d="M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22"></path>
Expand Down
43 changes: 43 additions & 0 deletions templates/layouts/base.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,51 @@ function buildPagePath(pagePath) {
<% }); %>
<% } %>

<style>
:root {
<% if (locals.siteData?.banner?.content) { %>
--header-height: 112px; /* banner 48px + nav 64px */
<% } else { %>
--header-height: 64px; /* nav 64px */
<% } %>
}
</style>

<!-- Tailwind CSS -->
<script src="<%= locals.siteData.cdn?.style || 'https://cdn.tailwindcss.com' %>"></script>
<script>
tailwind.config = {
theme: {
extend: {
typography: {
DEFAULT: {
css: {
h1: { fontWeight: '700', fontSize: '1.875rem', marginTop: '0.75rem', marginBottom: '0.75rem', color: 'rgb(17, 24, 39)' },
h2: { fontWeight: '700', fontSize: '1.5rem', marginTop: '0.75rem', marginBottom: '0.75rem', color: 'rgb(17, 24, 39)' },
h3: { fontWeight: '700', fontSize: '1.25rem', marginTop: '0.75rem', marginBottom: '0.75rem', color: 'rgb(17, 24, 39)' },
h4: { fontWeight: '700', fontSize: '1.125rem', marginTop: '0.75rem', marginBottom: '0.75rem', color: 'rgb(17, 24, 39)' },
h5: { fontWeight: '700', fontSize: '1rem', marginTop: '0.75rem', marginBottom: '0.75rem', color: 'rgb(17, 24, 39)' },
h6: { fontWeight: '700', fontSize: '0.875rem', marginTop: '0.75rem', marginBottom: '0.75rem', color: 'rgb(17, 24, 39)' },
}
}
}
}
},
plugins: [
function({ addBase }) {
addBase({
'h1': { fontWeight: '700', fontSize: '1.875rem', marginTop: '0.75rem', marginBottom: '0.75rem', color: 'rgb(17, 24, 39)' },
'h2': { fontWeight: '700', fontSize: '1.5rem', marginTop: '0.75rem', marginBottom: '0.75rem', color: 'rgb(17, 24, 39)' },
'h3': { fontWeight: '700', fontSize: '1.25rem', marginTop: '0.75rem', marginBottom: '0.75rem', color: 'rgb(17, 24, 39)' },
'h4': { fontWeight: '700', fontSize: '1.125rem', marginTop: '0.75rem', marginBottom: '0.75rem', color: 'rgb(17, 24, 39)' },
'h5': { fontWeight: '700', fontSize: '1rem', marginTop: '0.75rem', marginBottom: '0.75rem', color: 'rgb(17, 24, 39)' },
'h6': { fontWeight: '700', fontSize: '0.875rem', marginTop: '0.75rem', marginBottom: '0.75rem', color: 'rgb(17, 24, 39)' },
'.dark h1, .dark h2, .dark h3, .dark h4, .dark h5, .dark h6': { color: 'rgb(255, 255, 255)' }
})
}
]
}
</script>

<!-- Prism.js 语法高亮样式 -->
<link href="<%= locals.siteData.cdn?.prismStyle || 'https://cdnjs.cloudflare.com/ajax/libs/prism-themes/1.9.0/prism-ghcolors.css' %>" rel="stylesheet"/>
Expand Down