refactor: перенос docusaurus в корень, так как больше ничего не планируется в этой репе держать

This commit is contained in:
2026-06-16 14:03:23 +03:00
parent 8250d61f56
commit 6d68cd5d23
19 changed files with 26 additions and 25 deletions
+31
View File
@@ -0,0 +1,31 @@
import fs from 'fs';
import path from 'path';
const docsDir = path.resolve(import.meta.dirname, '..', process.argv[2] || 'docs');
pinIndexToTop();
/**
* Гарантирует наличие 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');
}