diff --git a/docs/quick-start/customer/_category_.json b/docs/quick-start/customer/_category_.json index 93ec6006..69f0462a 100644 --- a/docs/quick-start/customer/_category_.json +++ b/docs/quick-start/customer/_category_.json @@ -1,8 +1,8 @@ { - "label": "Customer Refund", + "label": "Customer", "position": 3, "link": { "type": "generated-index", - "description": "Learn on Customer Refund in SQL Account" + "description": "Learn on Customer in SQL Account" } } diff --git a/docs/quick-start/customer/customer-aging/intro.md b/docs/quick-start/customer/customer-aging/intro.md index 382d4d2a..0d9baa16 100644 --- a/docs/quick-start/customer/customer-aging/intro.md +++ b/docs/quick-start/customer/customer-aging/intro.md @@ -3,6 +3,7 @@ sidebar_position: 1 title: Table of contents hide_title: true slug: /quick-start/customer/customer-aging +form_name: TrfmARAging --- import {TOC} from '@src/components/toc.js'; diff --git a/docs/quick-start/customer/customer-contra/intro.md b/docs/quick-start/customer/customer-contra/intro.md index 4066b163..9b964067 100644 --- a/docs/quick-start/customer/customer-contra/intro.md +++ b/docs/quick-start/customer/customer-contra/intro.md @@ -3,6 +3,7 @@ sidebar_position: 1 title: Table of contents hide_title: true slug: /quick-start/customer/customer-contra +form_name: TfmARCT --- import {TOC} from '@src/components/toc.js'; diff --git a/docs/quick-start/customer/customer-deposit/intro.md b/docs/quick-start/customer/customer-deposit/intro.md index db2a7c62..c975aeb5 100644 --- a/docs/quick-start/customer/customer-deposit/intro.md +++ b/docs/quick-start/customer/customer-deposit/intro.md @@ -3,6 +3,7 @@ sidebar_position: 1 title: Table of contents hide_title: true slug: /quick-start/customer/customer-deposit +form_name: TfmARDP --- import {TOC} from '@src/components/toc.js'; diff --git a/docs/quick-start/customer/customer-due-document/intro.md b/docs/quick-start/customer/customer-due-document/intro.md index 348a939e..23505094 100644 --- a/docs/quick-start/customer/customer-due-document/intro.md +++ b/docs/quick-start/customer/customer-due-document/intro.md @@ -3,6 +3,7 @@ sidebar_position: 1 title: Table of contents hide_title: true slug: /quick-start/customer/customer-due-document +form_name: TrfmARDueDocument --- import {TOC} from '@src/components/toc.js'; diff --git a/docs/quick-start/customer/customer-payment/intro.md b/docs/quick-start/customer/customer-payment/intro.md index a1579d78..7757cf2c 100644 --- a/docs/quick-start/customer/customer-payment/intro.md +++ b/docs/quick-start/customer/customer-payment/intro.md @@ -3,6 +3,7 @@ sidebar_position: 1 title: Table of contents hide_title: true slug: /quick-start/customer/customer-payment +form_name: TfmARPM --- import {TOC} from '@src/components/toc.js'; diff --git a/docs/quick-start/customer/customer-refund/intro.md b/docs/quick-start/customer/customer-refund/intro.md index 0c59a3f4..0fa8a3ac 100644 --- a/docs/quick-start/customer/customer-refund/intro.md +++ b/docs/quick-start/customer/customer-refund/intro.md @@ -3,6 +3,7 @@ sidebar_position: 1 title: Table of contents hide_title: true slug: /quick-start/customer/customer-refund +form_name: TfmARCF --- import {TOC} from '@src/components/toc.js'; diff --git a/docs/quick-start/customer/customer-statement/intro.md b/docs/quick-start/customer/customer-statement/intro.md index cf6353f1..09efc714 100644 --- a/docs/quick-start/customer/customer-statement/intro.md +++ b/docs/quick-start/customer/customer-statement/intro.md @@ -3,6 +3,7 @@ sidebar_position: 1 title: Table of contents hide_title: true slug: /quick-start/customer/customer-statement +form_name: TrfmARStatement --- import {TOC} from '@src/components/toc.js'; diff --git a/docs/quick-start/gl/cash-book-entry/intro.md b/docs/quick-start/gl/cash-book-entry/intro.md index ab54abe1..12ea9261 100644 --- a/docs/quick-start/gl/cash-book-entry/intro.md +++ b/docs/quick-start/gl/cash-book-entry/intro.md @@ -3,6 +3,7 @@ sidebar_position: 1 title: Table of contents hide_title: true slug: /quick-start/gl/cash-book-entry +form_name: TfmGLCB --- import {TOC} from '@src/components/toc.js'; diff --git a/docs/quick-start/gl/journal-entry/intro.md b/docs/quick-start/gl/journal-entry/intro.md index bfa5f830..d0019e21 100644 --- a/docs/quick-start/gl/journal-entry/intro.md +++ b/docs/quick-start/gl/journal-entry/intro.md @@ -3,6 +3,7 @@ sidebar_position: 1 title: Table of contents hide_title: true slug: /quick-start/gl/journal-entry +form_name: TfmGLJE --- import {TOC} from '@src/components/toc.js'; diff --git a/docs/quick-start/purchase/cash-purchase/intro.md b/docs/quick-start/purchase/cash-purchase/intro.md index 2fd483d2..a2ab118f 100644 --- a/docs/quick-start/purchase/cash-purchase/intro.md +++ b/docs/quick-start/purchase/cash-purchase/intro.md @@ -3,6 +3,7 @@ sidebar_position: 1 title: Table of contents hide_title: true slug: /quick-start/purchase/cash-purchase +form_name: TfmPHCP --- import {TOC} from '@src/components/toc.js'; diff --git a/docs/quick-start/purchase/goods-received/intro.md b/docs/quick-start/purchase/goods-received/intro.md index fd8d27f6..4bf91b77 100644 --- a/docs/quick-start/purchase/goods-received/intro.md +++ b/docs/quick-start/purchase/goods-received/intro.md @@ -3,6 +3,7 @@ sidebar_position: 1 title: Table of contents hide_title: true slug: /quick-start/purchase/goods-received +form_name: TfmPHGR --- import {TOC} from '@src/components/toc.js'; diff --git a/docs/quick-start/purchase/purchase-cancelled-note/intro.md b/docs/quick-start/purchase/purchase-cancelled-note/intro.md index 024f0b8c..d8d8fca0 100644 --- a/docs/quick-start/purchase/purchase-cancelled-note/intro.md +++ b/docs/quick-start/purchase/purchase-cancelled-note/intro.md @@ -3,6 +3,7 @@ sidebar_position: 1 title: Table of contents hide_title: true slug: /quick-start/purchase/purchase-cancelled-note +form_name: TfmPHPC --- import {TOC} from '@src/components/toc.js'; diff --git a/docs/quick-start/purchase/purchase-debit-note/intro.md b/docs/quick-start/purchase/purchase-debit-note/intro.md index 31b59e59..686a1f64 100644 --- a/docs/quick-start/purchase/purchase-debit-note/intro.md +++ b/docs/quick-start/purchase/purchase-debit-note/intro.md @@ -3,6 +3,7 @@ sidebar_position: 1 title: Table of contents hide_title: true slug: /quick-start/purchase/purchase-debit-note +form_name: TfmPHSD --- import {TOC} from '@src/components/toc.js'; diff --git a/docs/quick-start/purchase/purchase-invoice/intro.md b/docs/quick-start/purchase/purchase-invoice/intro.md index b4744f84..9c345d1f 100644 --- a/docs/quick-start/purchase/purchase-invoice/intro.md +++ b/docs/quick-start/purchase/purchase-invoice/intro.md @@ -3,6 +3,7 @@ sidebar_position: 1 title: Table of contents hide_title: true slug: /quick-start/purchase/purchase-invoice +form_name: TfmPHPI --- import {TOC} from '@src/components/toc.js'; diff --git a/docs/quick-start/purchase/purchase-order/intro.md b/docs/quick-start/purchase/purchase-order/intro.md index 72f87e6b..2237c37d 100644 --- a/docs/quick-start/purchase/purchase-order/intro.md +++ b/docs/quick-start/purchase/purchase-order/intro.md @@ -3,6 +3,7 @@ sidebar_position: 1 title: Table of contents hide_title: true slug: /quick-start/purchase/purchase-order +form_name: TfmPHPO --- import {TOC} from '@src/components/toc.js'; diff --git a/docs/quick-start/purchase/purchase-request/intro.md b/docs/quick-start/purchase/purchase-request/intro.md index 1f96d69c..ea65e517 100644 --- a/docs/quick-start/purchase/purchase-request/intro.md +++ b/docs/quick-start/purchase/purchase-request/intro.md @@ -3,6 +3,7 @@ sidebar_position: 1 title: Table of contents hide_title: true slug: /quick-start/purchase/purchase-request +form_name: TfmPHPQ --- import {TOC} from '@src/components/toc.js'; diff --git a/docs/quick-start/purchase/purchase-returned/intro.md b/docs/quick-start/purchase/purchase-returned/intro.md index adff545e..c5df200b 100644 --- a/docs/quick-start/purchase/purchase-returned/intro.md +++ b/docs/quick-start/purchase/purchase-returned/intro.md @@ -3,6 +3,7 @@ sidebar_position: 1 title: Table of contents hide_title: true slug: /quick-start/purchase/purchase-returned +form_name: TfmPHSC --- import {TOC} from '@src/components/toc.js'; diff --git a/docs/quick-start/sales/cash-sales/intro.md b/docs/quick-start/sales/cash-sales/intro.md index 08143ceb..edf55235 100644 --- a/docs/quick-start/sales/cash-sales/intro.md +++ b/docs/quick-start/sales/cash-sales/intro.md @@ -3,6 +3,7 @@ sidebar_position: 1 title: Table of contents hide_title: true slug: /quick-start/sales/cash-sales +form_name: TfmSLCS --- import {TOC} from '@src/components/toc.js'; diff --git a/docs/quick-start/sales/sales-cancelled-note/intro.md b/docs/quick-start/sales/sales-cancelled-note/intro.md index 734e5dfa..9d1636d5 100644 --- a/docs/quick-start/sales/sales-cancelled-note/intro.md +++ b/docs/quick-start/sales/sales-cancelled-note/intro.md @@ -3,6 +3,7 @@ sidebar_position: 1 title: Table of contents hide_title: true slug: /quick-start/sales/sales-cancelled-note +form_name: TfmSLCC --- import {TOC} from '@src/components/toc.js'; diff --git a/docs/quick-start/sales/sales-credit-note/intro.md b/docs/quick-start/sales/sales-credit-note/intro.md index aaeaedfa..e0a05ef4 100644 --- a/docs/quick-start/sales/sales-credit-note/intro.md +++ b/docs/quick-start/sales/sales-credit-note/intro.md @@ -3,6 +3,7 @@ sidebar_position: 1 title: Table of contents hide_title: true slug: /quick-start/sales/sales-credit-note +form_name: TfmSLCN --- import {TOC} from '@src/components/toc.js'; diff --git a/docs/quick-start/sales/sales-debit-note/intro.md b/docs/quick-start/sales/sales-debit-note/intro.md index aeb03cb5..90c15300 100644 --- a/docs/quick-start/sales/sales-debit-note/intro.md +++ b/docs/quick-start/sales/sales-debit-note/intro.md @@ -3,6 +3,7 @@ sidebar_position: 1 title: Table of contents hide_title: true slug: /quick-start/sales/sales-debit-note +form_name: TfmSLDN --- import {TOC} from '@src/components/toc.js'; diff --git a/docs/quick-start/sales/sales-delivery-order/intro.md b/docs/quick-start/sales/sales-delivery-order/intro.md index 0988e3d0..375a0fbe 100644 --- a/docs/quick-start/sales/sales-delivery-order/intro.md +++ b/docs/quick-start/sales/sales-delivery-order/intro.md @@ -3,6 +3,7 @@ sidebar_position: 1 title: Table of contents hide_title: true slug: /quick-start/sales/sales-delivery-order +form_name: TfmSLDO --- import {TOC} from '@src/components/toc.js'; diff --git a/docs/quick-start/sales/sales-invoice/intro.md b/docs/quick-start/sales/sales-invoice/intro.md index b66ebaa4..2311cf0a 100644 --- a/docs/quick-start/sales/sales-invoice/intro.md +++ b/docs/quick-start/sales/sales-invoice/intro.md @@ -3,6 +3,7 @@ sidebar_position: 1 title: Table of contents hide_title: true slug: /quick-start/sales/sales-invoice +form_name: TfmSLIV --- import {TOC} from '@src/components/toc.js'; diff --git a/docs/quick-start/sales/sales-order/intro.md b/docs/quick-start/sales/sales-order/intro.md index 450ab4fb..818dece3 100644 --- a/docs/quick-start/sales/sales-order/intro.md +++ b/docs/quick-start/sales/sales-order/intro.md @@ -3,6 +3,7 @@ sidebar_position: 1 title: Table of contents hide_title: true slug: /quick-start/sales/sales-order +form_name: TfmSLSO --- import {TOC} from '@src/components/toc.js'; diff --git a/docs/quick-start/sales/sales-quotation/intro.md b/docs/quick-start/sales/sales-quotation/intro.md index 9ac8067d..7afdb9f1 100644 --- a/docs/quick-start/sales/sales-quotation/intro.md +++ b/docs/quick-start/sales/sales-quotation/intro.md @@ -3,6 +3,7 @@ sidebar_position: 1 title: Table of contents hide_title: true slug: /quick-start/sales/sales-quotation +form_name: TfmSLQT --- import {TOC} from '@src/components/toc.js'; diff --git a/docusaurus.config.js b/docusaurus.config.js index 68071193..22436ff1 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -31,6 +31,13 @@ const config = { }, plugins: [ "plugin-image-zoom", + [ + path.resolve(__dirname, 'plugins/generate-help-json'), + { + docsPath: 'docs', + outputPath: '/' + }, + ], function aliasPlugin(context, options) { return { name: 'alias-plugin', diff --git a/package-lock.json b/package-lock.json index 38a911e2..06faa703 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "@easyops-cn/docusaurus-search-local": "^0.40.1", "@mdx-js/react": "^3.0.0", "clsx": "^2.0.0", + "gray-matter": "^4.0.3", "plugin-image-zoom": "github:flexanalytics/plugin-image-zoom", "prism-react-renderer": "^2.3.0", "qrcode.react": "^4.2.0", diff --git a/package.json b/package.json index 5e88eacc..cff11c8e 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "@easyops-cn/docusaurus-search-local": "^0.40.1", "@mdx-js/react": "^3.0.0", "clsx": "^2.0.0", + "gray-matter": "^4.0.3", "plugin-image-zoom": "github:flexanalytics/plugin-image-zoom", "prism-react-renderer": "^2.3.0", "qrcode.react": "^4.2.0", diff --git a/plugins/generate-help-json/index.js b/plugins/generate-help-json/index.js new file mode 100644 index 00000000..29bbcf7d --- /dev/null +++ b/plugins/generate-help-json/index.js @@ -0,0 +1,102 @@ +const fs = require('fs'); +const path = require('path'); +const matter = require('gray-matter'); + +function getAllMarkdownFiles(dir, fileList = []) { + const files = fs.readdirSync(dir); + + files.forEach(file => { + const filePath = path.join(dir, file); + if (fs.statSync(filePath).isDirectory()) { + getAllMarkdownFiles(filePath, fileList); + } else if (file.endsWith('.md') || file.endsWith('.mdx')) { + fileList.push(filePath); + } + }); + + return fileList; +} + +module.exports = function(context, options) { + return { + name: 'generate-help-json', + + async postBuild({ siteConfig, routesPaths, outDir }) { + let docsDir; + docsDir = path.join(context.siteDir, options.docsPath); + if (!fs.existsSync(docsDir)) { + console.warn(`Warning: Docs directory not found: ${docsDir}`); + return; + } + + const markdownFiles = getAllMarkdownFiles(docsDir); + const helpData = []; + const formNameMap = {}; + const duplicates = []; + + for (const fullPath of markdownFiles) { + const filePath = path.relative(docsDir, fullPath); + const fileContent = fs.readFileSync(fullPath, 'utf8'); + + try { + const { data: frontMatter } = matter(fileContent); + + if (frontMatter && frontMatter.form_name) { + let permalink = frontMatter.slug; + if (!permalink) { + console.warn(`WARNING: No slug found for ${filePath}`); + } + + if (formNameMap[frontMatter.form_name]) { + duplicates.push({ + form_name: frontMatter.form_name, + existingFile: formNameMap[frontMatter.form_name], + newFile: filePath + }); + + console.warn(`WARNING: Duplicate form_name "${frontMatter.form_name}" found in:`); + console.warn(` 1. ${formNameMap[frontMatter.form_name]}`); + console.warn(` 2. ${filePath}`); + console.warn(` Using the first occurrence for help.json`); + + continue; + } + + formNameMap[frontMatter.form_name] = filePath; + + helpData.push({ + Name: frontMatter.form_name, + Path: permalink + }); + } + } catch (err) { + console.warn(`Error processing ${filePath}:`, err); + } + } + + let targetDir = outDir; + const outputPath = path.join(outDir, options.outputPath); + + if (fs.existsSync(outputPath) && fs.statSync(outputPath).isDirectory()) { + targetDir = outputPath; + } + + const helpJsonPath = path.join(targetDir, 'help.json'); + fs.writeFileSync( + helpJsonPath, + JSON.stringify(helpData, null, 2) + ); + + if (duplicates.length > 0) { + const duplicatesPath = path.join(targetDir, 'help-duplicates.json'); + fs.writeFileSync( + duplicatesPath, + JSON.stringify(duplicates, null, 2) + ); + console.warn(`Found ${duplicates.length} duplicate form_name entries. See help-duplicates.json for details.`); + } + + console.log(`Generated HELP.json with ${helpData.length} entries in ${targetDir}`); + } + }; +}; \ No newline at end of file