From 906d2d341e96da577aff5b527086c980fd3946fd Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Mon, 28 Oct 2024 11:08:26 +0800 Subject: [PATCH] Fix Artboard image URL replace. (#20) --- feishu-pages/package.json | 2 +- feishu-pages/src/feishu.ts | 3 --- feishu-pages/src/index.ts | 9 +++++++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/feishu-pages/package.json b/feishu-pages/package.json index c2c91da..a355070 100644 --- a/feishu-pages/package.json +++ b/feishu-pages/package.json @@ -1,6 +1,6 @@ { "name": "feishu-pages", - "version": "0.7.1", + "version": "0.7.2", "description": "Generate Feishu Wiki into a Markdown for work with Static Page Generators.", "repository": { "url": "https://github.com/longbridgeapp/feishu-pages" diff --git a/feishu-pages/src/feishu.ts b/feishu-pages/src/feishu.ts index 8ed2310..8ac5fdf 100644 --- a/feishu-pages/src/feishu.ts +++ b/feishu-pages/src/feishu.ts @@ -331,9 +331,6 @@ export const feishuDownload = async (fileToken: string, localPath: string, type: ); } - let suffix = type == 'board' ? '-board' : ''; - localPath = localPath + suffix; - if (extension) { localPath = localPath + "." + extension; } diff --git a/feishu-pages/src/index.ts b/feishu-pages/src/index.ts index c4ecdce..a94e091 100644 --- a/feishu-pages/src/index.ts +++ b/feishu-pages/src/index.ts @@ -154,9 +154,14 @@ const downloadFiles = async ( } for (const fileToken in fileTokens) { + let base_filename = fileToken; + if (fileTokens[fileToken].type == 'board') { + base_filename = base_filename + '-board'; + } + const filePath = await feishuDownload( fileToken, - path.join(path.join(DOCS_DIR, 'assets'), fileToken), + path.join(path.join(DOCS_DIR, 'assets'), base_filename), fileTokens[fileToken].type ); if (!filePath) { @@ -165,7 +170,7 @@ const downloadFiles = async ( const extension = path.extname(filePath); - let assetURL = `/assets/${fileToken}${extension}`; + let assetURL = `/assets/${base_filename}${extension}`; // Replase Markdown image content = replaceLinks(content, fileToken, assetURL);