Skip to content

Commit

Permalink
支持渲染内容目录下静态文件
Browse files Browse the repository at this point in the history
  • Loading branch information
qianmoQ committed Dec 29, 2024
1 parent c3baf3c commit 2704993
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/content/docs/create-site/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ PageForge 包括一个实时预览服务器,因此您可以在编写文档时
pageforge serve
```

将浏览器指向 [localhost:3000](http://localhost:3000),您应该会看到:
将浏览器指向 [localhost:3000](http://localhost:3000 "localhost:3000" "_blank"),您应该会看到:

![img.png](img.png)
4 changes: 2 additions & 2 deletions docs/pageforge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ nav:
sidebar:
default:
- text: 快速上手
link: '/docs/get-started'
link: /docs/get-started
- text: 创建你的网站
link: '/docs/create-site/index'
link: /docs/create-site/index
10 changes: 10 additions & 0 deletions lib/site-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,16 @@ class SiteGenerator {
console.error(`✗ 编译 ${relativePath} 失败 ${error.message}`);
}
}
else {
// 复制非 Markdown 文件到对应输出目录
const outputDir = path.join(this.config.outputPath, baseDir);
if (!fs.existsSync(outputDir)) {
fs.mkdirSync(outputDir, {recursive: true});
}
const outputPath = path.join(outputDir, file);
fs.copyFileSync(sourcePath, outputPath);
console.log(`✓ 复制 ${relativePath} 文件完成`);
}
}
}

Expand Down

0 comments on commit 2704993

Please sign in to comment.