@onozaty/growi-uploader 1.7.0 → 1.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.ja.md CHANGED
@@ -274,6 +274,48 @@ Download the [documentation](/attachment/68f3a3fa794f665ad2c0d2b3).
274
274
 
275
275
  両方の検出方法で、複数のリンク形式(`./`あり・なし)がサポートされています。
276
276
 
277
+ ### クロスページ参照
278
+
279
+ 命名規則に従うファイル(`BBB_attachment_*`)を別のページ(`AAA.md`)から参照している場合:
280
+
281
+ - 添付ファイルは所有者ページ(`/BBB`)にのみアップロードされます
282
+ - 参照元ページ(`AAA.md`)のリンクは添付ファイルのURL(`/attachment/{id}`)に置換されます
283
+
284
+ **例:**
285
+ ```
286
+ ファイル構成:
287
+ AAA.md (内容: ![](BBB_attachment_image.png))
288
+ BBB.md
289
+ BBB_attachment_image.png
290
+
291
+ 結果:
292
+ - BBB_attachment_image.png は /BBB ページにのみアップロード
293
+ - AAA.md 内のリンクは /attachment/{id} に置換
294
+ ```
295
+
296
+ ## ページリンクの変換
297
+
298
+ 他のMarkdownファイル(`.md`拡張子)へのリンクは自動的にGROWI形式に変換されます。
299
+
300
+ ### 対応パターン
301
+
302
+ ```markdown
303
+ # アップロード前(ローカル)
304
+ [ユーザーガイド](./guide.md)
305
+ [API概要](../api/overview.md)
306
+ [認証セクション](./api/auth.md#setup)
307
+
308
+ # アップロード後(GROWI上)
309
+ [ユーザーガイド](./guide)
310
+ [API概要](../api/overview)
311
+ [認証セクション](./api/auth#setup)
312
+ ```
313
+
314
+ - `.md`拡張子が除去されます
315
+ - 相対パスのプレフィックス(`./`、`../`)は維持されます(GROWIは相対リンクをサポート)
316
+ - アンカーリンク(`#section`)は維持されます
317
+ - 外部URL(`http://`、`https://`)は変更されません
318
+
277
319
  ## 高度な使い方
278
320
 
279
321
  ### 既存ページの更新
package/README.md CHANGED
@@ -274,6 +274,48 @@ Download the [documentation](/attachment/68f3a3fa794f665ad2c0d2b3).
274
274
 
275
275
  Both detection methods support multiple link formats (with or without `./`).
276
276
 
277
+ ### Cross-Page References
278
+
279
+ When a file following the naming convention (`BBB_attachment_*`) is referenced from a different page (`AAA.md`):
280
+
281
+ - The attachment is uploaded only to its owner page (`/BBB`)
282
+ - Links in the referencing page (`AAA.md`) are replaced with the attachment URL (`/attachment/{id}`)
283
+
284
+ **Example:**
285
+ ```
286
+ File structure:
287
+ AAA.md (contains: ![](BBB_attachment_image.png))
288
+ BBB.md
289
+ BBB_attachment_image.png
290
+
291
+ Result:
292
+ - BBB_attachment_image.png is uploaded to /BBB page only
293
+ - The link in AAA.md is replaced with /attachment/{id}
294
+ ```
295
+
296
+ ## Page Link Conversion
297
+
298
+ Links to other Markdown files (`.md` extension) are automatically converted to GROWI format.
299
+
300
+ ### Supported Patterns
301
+
302
+ ```markdown
303
+ # Before upload (local)
304
+ [User Guide](./guide.md)
305
+ [API Overview](../api/overview.md)
306
+ [Auth Section](./api/auth.md#setup)
307
+
308
+ # After upload (on GROWI)
309
+ [User Guide](./guide)
310
+ [API Overview](../api/overview)
311
+ [Auth Section](./api/auth#setup)
312
+ ```
313
+
314
+ - The `.md` extension is removed
315
+ - Relative path prefixes (`./`, `../`) are preserved (GROWI supports relative links)
316
+ - Anchor links (`#section`) are preserved
317
+ - External URLs (`http://`, `https://`) are not modified
318
+
277
319
  ## Advanced Usage
278
320
 
279
321
  ### Update Existing Pages
package/dist/index.mjs CHANGED
@@ -8,7 +8,7 @@ import { lookup } from "mime-types";
8
8
  import { glob } from "glob";
9
9
 
10
10
  //#region package.json
11
- var version = "1.7.0";
11
+ var version = "1.7.2";
12
12
 
13
13
  //#endregion
14
14
  //#region src/config.ts
@@ -52,7 +52,7 @@ const postAttachment = (postAttachmentBody, options) => {
52
52
  return axios$1.default.post(`/attachment`, postAttachmentBody, options);
53
53
  };
54
54
  /**
55
- * get page by pagePath or pageId
55
+ * Get page by pagePath or pageId. Returns a single page or multiple pages based on parameters.
56
56
  * @summary Get page
57
57
  */
58
58
  const getPage = (params, options) => {
@@ -609,8 +609,7 @@ const uploadFiles = async (files, sourceDir, config) => {
609
609
  const attachmentMap = /* @__PURE__ */ new Map();
610
610
  const pageResults = [];
611
611
  for (const file of files) {
612
- const content = readFileSync(join(sourceDir, file.localPath), "utf-8");
613
- const result = await createOrUpdatePage(file, content, config.update);
612
+ const result = await createOrUpdatePage(file, readFileSync(join(sourceDir, file.localPath), "utf-8"), config.update);
614
613
  if (result.action === "created") {
615
614
  stats.pagesCreated++;
616
615
  console.log(`[SUCCESS] ${file.localPath} → ${file.growiPath} (created)`);
@@ -647,8 +646,7 @@ const uploadFiles = async (files, sourceDir, config) => {
647
646
  if (latestRevisionId) pageResults.push({
648
647
  file,
649
648
  pageId: result.pageId,
650
- revisionId: latestRevisionId,
651
- content
649
+ revisionId: latestRevisionId
652
650
  });
653
651
  } else if (file.attachments.length > 0) {
654
652
  for (const attachment of file.attachments) if (!attachment.isExternalReference) {
@@ -658,8 +656,8 @@ const uploadFiles = async (files, sourceDir, config) => {
658
656
  }
659
657
  }
660
658
  for (const pageResult of pageResults) {
661
- const { file, pageId, content } = pageResult;
662
- let currentContent = content;
659
+ const { file, pageId } = pageResult;
660
+ let currentContent = readFileSync(join(sourceDir, file.localPath), "utf-8");
663
661
  let currentRevisionId = pageResult.revisionId;
664
662
  const pageName = basename(file.localPath, ".md");
665
663
  const localAttachments = file.attachments.filter((att) => !att.isExternalReference && att.attachmentId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onozaty/growi-uploader",
3
- "version": "1.7.0",
3
+ "version": "1.7.2",
4
4
  "description": "A content uploader for GROWI",
5
5
  "type": "module",
6
6
  "bin": {