mirror of
https://github.com/DefectingCat/DefectingCat.github.io
synced 2025-07-16 01:01:38 +00:00
update build gh-pages script
This commit is contained in:
@ -10,13 +10,32 @@ const __dirname = path.dirname(__filename);
|
|||||||
const contentPath = path.resolve(__dirname, '../../content/posts');
|
const contentPath = path.resolve(__dirname, '../../content/posts');
|
||||||
const buildPath = path.resolve(__dirname, '../../build');
|
const buildPath = path.resolve(__dirname, '../../build');
|
||||||
|
|
||||||
|
const PostPerPage = 10;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read post folder, list all posts
|
||||||
|
*/
|
||||||
async function allPosts() {
|
async function allPosts() {
|
||||||
const content = await fs.readdir(contentPath);
|
const content = await fs.readdir(contentPath);
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy all posts to build folder
|
||||||
|
*/
|
||||||
|
async function copyPosts(posts) {
|
||||||
|
const builds = posts.map((post) => {
|
||||||
|
log(`Copy file ${post}`);
|
||||||
|
return fs.copyFile(`${contentPath}/${post}`, `${buildPath}/${post}`);
|
||||||
|
});
|
||||||
|
await Promise.all(builds);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function buildJson(posts) {}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const posts = await allPosts();
|
const posts = await allPosts();
|
||||||
|
log(posts);
|
||||||
|
|
||||||
log('Clean build path');
|
log('Clean build path');
|
||||||
try {
|
try {
|
||||||
@ -27,11 +46,8 @@ async function main() {
|
|||||||
await fs.mkdir(buildPath);
|
await fs.mkdir(buildPath);
|
||||||
|
|
||||||
log('Start build');
|
log('Start build');
|
||||||
const builds = posts.map((post) => {
|
await copyPosts(posts);
|
||||||
log(`Copy file ${post}`);
|
|
||||||
return fs.copyFile(`${contentPath}/${post}`, `${buildPath}/${post}`);
|
|
||||||
});
|
|
||||||
await Promise.all(builds);
|
|
||||||
log('Build done');
|
log('Build done');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user