From e99b5599a4a402bf45d2d143ad73e76e9eff0879 Mon Sep 17 00:00:00 2001 From: Arswarog Date: Sat, 13 Jun 2026 22:08:32 +0300 Subject: [PATCH] =?UTF-8?q?fix(docs):=20=D0=B0=D0=B2=D1=82=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D1=82=D0=B8=D1=87=D0=B5=D1=81=D0=BA=D0=B8=20=D0=B7=D0=B0?= =?UTF-8?q?=D0=BA=D1=80=D0=B5=D0=BF=D0=BB=D1=8F=D0=B5=D1=82=20index.md=20?= =?UTF-8?q?=D0=BF=D0=B5=D1=80=D0=B2=D1=8B=D0=BC=20=D0=B2=20=D1=81=D0=B0?= =?UTF-8?q?=D0=B9=D0=B4=D0=B1=D0=B0=D1=80=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Добавлен Node-скрипт, который инжектит sidebar_position: 0 в front matter docs/index.md перед сборкой Docusaurus. Co-Authored-By: Claude Opus 4.6 --- action.yml | 6 +++++- docusaurus/scripts/prepare-docs.mjs | 31 +++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 docusaurus/scripts/prepare-docs.mjs diff --git a/action.yml b/action.yml index 29baecc..c0b8f6d 100644 --- a/action.yml +++ b/action.yml @@ -49,7 +49,11 @@ runs: rm -rf "${DOCUSAURUS_DIR}/docs" cp -r "${{ inputs.docs-path }}" "${DOCUSAURUS_DIR}/docs" cp "${{ github.workspace }}/.docuservix.yml" "${DOCUSAURUS_DIR}" - + + - name: Prepare docs + shell: bash + working-directory: ${{ github.action_path }}/docusaurus + run: node scripts/prepare-docs.mjs - name: Install Docusaurus dependencies shell: bash diff --git a/docusaurus/scripts/prepare-docs.mjs b/docusaurus/scripts/prepare-docs.mjs new file mode 100644 index 0000000..adc0f3a --- /dev/null +++ b/docusaurus/scripts/prepare-docs.mjs @@ -0,0 +1,31 @@ +import fs from 'fs'; +import path from 'path'; + +const docsDir = path.resolve(import.meta.dirname, '..', process.argv[2] || 'docs'); + +/** + * Гарантирует наличие sidebar_position: 0 в front matter файла index.md + */ +function pinIndexToTop() { + const indexPath = path.join(docsDir, 'index.md'); + if (!fs.existsSync(indexPath)) return; + + let content = fs.readFileSync(indexPath, 'utf8'); + + if (content.startsWith('---\n')) { + const endIdx = content.indexOf('\n---\n', 4); + if (endIdx === -1) return; + + const frontMatter = content.slice(4, endIdx); + if (/^sidebar_position\s*:/m.test(frontMatter)) return; + + content = '---\nsidebar_position: 0\n' + frontMatter + '\n---\n' + content.slice(endIdx + 5); + } else { + content = '---\nsidebar_position: 0\n---\n' + content; + } + + fs.writeFileSync(indexPath, content); + console.log('prepare-docs: pinned index.md to sidebar top'); +} + +pinIndexToTop();