From 11210336cd3ecf75cfcd3ae8f95a98a27ea960e8 Mon Sep 17 00:00:00 2001 From: Hare Date: Tue, 3 Sep 2024 21:34:56 +0900 Subject: [PATCH] feat: git clone if articles does not exist --- src/lib/server/database/init_db.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/lib/server/database/init_db.ts b/src/lib/server/database/init_db.ts index e014a70..a5d3185 100644 --- a/src/lib/server/database/init_db.ts +++ b/src/lib/server/database/init_db.ts @@ -9,6 +9,10 @@ export default async function init(db: Postgres) { console.log('Pulling articles from git..'); const stdout = execSync('git -c core.sshCommand="ssh -i ../key -F /dev/null" pull', { cwd: './articles/' }); console.log(stdout.toString()); + } else { + console.log('Cloning articles from git..'); + const stdout = execSync('git -c core.sshCommand="ssh -i ./key -F /dev/null" clone git@gitea.hareworks.net:Hare/blog-articles.git articles', { cwd: './' }); + console.log(stdout.toString()); } const schemas = [ @@ -113,7 +117,13 @@ export default async function init(db: Postgres) { for (const { path, id } of articleFiles) { const res = await db.query('select * from article where id = $1', [id]); - const compiled = await compile(fs.readFileSync(path, 'utf-8')); + const compiled = await compile(fs.readFileSync(path, 'utf-8'), { + highlight: { + highlighter: (code: string, lang: string) => { + return `${code}`; + } + } + }); const title = compiled.data.fm.title; const category = path.split('/')[3];