From 436e4251195d28737cfedad7587299ffcb3ea48d Mon Sep 17 00:00:00 2001 From: Arswarog Date: Wed, 17 Jun 2026 16:16:56 +0300 Subject: [PATCH] =?UTF-8?q?format:=20=D0=90=D0=B2=D1=82=D0=BE=D1=84=D0=BE?= =?UTF-8?q?=D1=80=D0=BC=D0=B0=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BF=D1=80=D0=BE=D0=B5=D0=BA=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .docuservix.yml | 6 +- README.md | 6 +- action.yml | 208 +++++++++++++++++++-------------------- docs/index.md | 2 +- docusaurus.config.ts | 35 +++---- package.json | 39 ++++---- scripts/prepare-docs.mjs | 29 +++--- src/pages/index.tsx | 59 ++++++----- tsconfig.json | 17 ++-- 9 files changed, 205 insertions(+), 196 deletions(-) diff --git a/.docuservix.yml b/.docuservix.yml index 686e6e2..05f4d29 100644 --- a/.docuservix.yml +++ b/.docuservix.yml @@ -1,4 +1,4 @@ -title: "Title example" +title: 'Title example' project: - org: "example" - repo: "example" + org: 'example' + repo: 'example' diff --git a/README.md b/README.md index 7a4b716..270c434 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,8 @@ yarn yarn start ``` -This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server. +This command starts a local development server and opens up a browser window. Most changes are +reflected live without having to restart the server. ## Build @@ -22,4 +23,5 @@ This command starts a local development server and opens up a browser window. Mo yarn build ``` -This command generates static content into the `build` directory and can be served using any static contents hosting service. +This command generates static content into the `build` directory and can be served using any static +contents hosting service. diff --git a/action.yml b/action.yml index 754c25f..ca06e23 100644 --- a/action.yml +++ b/action.yml @@ -2,120 +2,120 @@ name: 'Docusaurus Deploy' description: 'Builds Docusaurus docs from repo and deploys to S3' inputs: - docs-path: - description: 'Path to docs directory in calling repo' - default: 'docs' - on-broken-links: - description: 'Behavior on broken links: throw, warn, or ignore' - default: 'throw' - prefix: - description: 'Prefix for S3 path' - default: '' + docs-path: + description: 'Path to docs directory in calling repo' + default: 'docs' + on-broken-links: + description: 'Behavior on broken links: throw, warn, or ignore' + default: 'throw' + prefix: + description: 'Prefix for S3 path' + default: '' runs: - using: 'composite' - steps: - - name: Compute target URL - shell: bash - run: | - REF="${{ github.head_ref || github.ref_name }}" - REPO="${{ github.event.repository.name }}" - ORG="${{ github.repository_owner }}" + using: 'composite' + steps: + - name: Compute target URL + shell: bash + run: | + REF="${{ github.head_ref || github.ref_name }}" + REPO="${{ github.event.repository.name }}" + ORG="${{ github.repository_owner }}" - if [[ "$REF" == "main" || "$REF" == "master" ]]; then - URL="http://${REPO}.${ORG}.jt4d-wiki.ru.net" - S3_PATH="${ORG}.${REPO}" - else - URL="http://${REF}.${REPO}.${ORG}.jt4d-wiki.ru.net" - S3_PATH="${ORG}.${REPO}.${REF}" - fi + if [[ "$REF" == "main" || "$REF" == "master" ]]; then + URL="http://${REPO}.${ORG}.jt4d-wiki.ru.net" + S3_PATH="${ORG}.${REPO}" + else + URL="http://${REF}.${REPO}.${ORG}.jt4d-wiki.ru.net" + S3_PATH="${ORG}.${REPO}.${REF}" + fi - PREFIX="${{ inputs.prefix }}" - if [[ -n "$PREFIX" ]]; then - S3_PATH="${PREFIX}/${S3_PATH}" - fi + PREFIX="${{ inputs.prefix }}" + if [[ -n "$PREFIX" ]]; then + S3_PATH="${PREFIX}/${S3_PATH}" + fi - echo "TARGET_URL=$URL" >> $GITHUB_ENV - echo "S3_PATH=$S3_PATH" >> $GITHUB_ENV + echo "TARGET_URL=$URL" >> $GITHUB_ENV + echo "S3_PATH=$S3_PATH" >> $GITHUB_ENV - - name: Set docs status pending - shell: bash - run: | - curl -s -X POST \ - -H "Authorization: token ${{ github.token }}" \ - -H "Content-Type: application/json" \ - -d '{ - "state": "pending", - "context": "Docs", - "description": "building", - "target_url": "${{ env.TARGET_URL }}" - }' \ - "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/statuses/${{ github.sha }}" + - name: Set docs status pending + shell: bash + run: | + curl -s -X POST \ + -H "Authorization: token ${{ github.token }}" \ + -H "Content-Type: application/json" \ + -d '{ + "state": "pending", + "context": "Docs", + "description": "building", + "target_url": "${{ env.TARGET_URL }}" + }' \ + "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/statuses/${{ github.sha }}" - - name: Copy docs into Docusaurus - shell: bash - run: | - DOCUSAURUS_DIR="${{ github.action_path }}" - rm -rf "${DOCUSAURUS_DIR}/docs" - cp -r "${{ inputs.docs-path }}" "${DOCUSAURUS_DIR}/docs" - cp "${{ github.workspace }}/.docuservix.yml" "${DOCUSAURUS_DIR}" + - name: Copy docs into Docusaurus + shell: bash + run: | + DOCUSAURUS_DIR="${{ github.action_path }}" + 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 }} - run: node scripts/prepare-docs.mjs + - name: Prepare docs + shell: bash + working-directory: ${{ github.action_path }} + run: node scripts/prepare-docs.mjs - - name: Install Docusaurus dependencies - shell: bash - working-directory: ${{ github.action_path }} - run: yarn install --frozen-lockfile + - name: Install Docusaurus dependencies + shell: bash + working-directory: ${{ github.action_path }} + run: yarn install --frozen-lockfile - - name: Build docs - shell: bash - working-directory: ${{ github.action_path }} - env: - DOCUSERVIX_ON_BROKEN_LINKS: ${{ inputs.on-broken-links }} - DOCUSERVIX_URL: ${{ env.TARGET_URL }} - run: yarn docusaurus build --out-dir ${{ github.workspace }}/generated-docs + - name: Build docs + shell: bash + working-directory: ${{ github.action_path }} + env: + DOCUSERVIX_ON_BROKEN_LINKS: ${{ inputs.on-broken-links }} + DOCUSERVIX_URL: ${{ env.TARGET_URL }} + run: yarn docusaurus build --out-dir ${{ github.workspace }}/generated-docs - - name: Upload to S3 - shell: bash - env: - AWS_ACCESS_KEY_ID: ${{ vars.DOCUSERVIX_S3_ACCESS }} - AWS_SECRET_ACCESS_KEY: ${{ vars.DOCUSERVIX_S3_SECRET }} - run: | - aws s3 sync generated-docs/ \ - s3://${{ vars.DOCUSERVIX_S3_BUCKET }}/${{ env.S3_PATH }}\ - --endpoint-url ${{ vars.DOCUSERVIX_S3_URL }} \ - --acl public-read \ - --delete + - name: Upload to S3 + shell: bash + env: + AWS_ACCESS_KEY_ID: ${{ vars.DOCUSERVIX_S3_ACCESS }} + AWS_SECRET_ACCESS_KEY: ${{ vars.DOCUSERVIX_S3_SECRET }} + run: | + aws s3 sync generated-docs/ \ + s3://${{ vars.DOCUSERVIX_S3_BUCKET }}/${{ env.S3_PATH }}\ + --endpoint-url ${{ vars.DOCUSERVIX_S3_URL }} \ + --acl public-read \ + --delete - - name: Set docs status success - if: success() - shell: bash - run: | - curl -s -X POST \ - -H "Authorization: token ${{ github.token }}" \ - -H "Content-Type: application/json" \ - -d '{ - "state": "success", - "context": "Docs", - "description": "deployed", - "target_url": "${{ env.TARGET_URL }}" - }' \ - "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/statuses/${{ github.sha }}" + - name: Set docs status success + if: success() + shell: bash + run: | + curl -s -X POST \ + -H "Authorization: token ${{ github.token }}" \ + -H "Content-Type: application/json" \ + -d '{ + "state": "success", + "context": "Docs", + "description": "deployed", + "target_url": "${{ env.TARGET_URL }}" + }' \ + "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/statuses/${{ github.sha }}" - - name: Set docs status failure - if: failure() - shell: bash - run: | - curl -s -X POST \ - -H "Authorization: token ${{ github.token }}" \ - -H "Content-Type: application/json" \ - -d '{ - "state": "failure", - "context": "Docs", - "description": "build failed", - "target_url": "${{ env.TARGET_URL }}" - }' \ - "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/statuses/${{ github.sha }}" \ No newline at end of file + - name: Set docs status failure + if: failure() + shell: bash + run: | + curl -s -X POST \ + -H "Authorization: token ${{ github.token }}" \ + -H "Content-Type: application/json" \ + -d '{ + "state": "failure", + "context": "Docs", + "description": "build failed", + "target_url": "${{ env.TARGET_URL }}" + }' \ + "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/statuses/${{ github.sha }}" diff --git a/docs/index.md b/docs/index.md index de2d532..7701e79 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,3 +1,3 @@ # Добро пожаловать в Docuservix! -Вам надо настроить публикацию документации по инструкции в https://git.jt4d.ru/jt4d/docuservix \ No newline at end of file +Вам надо настроить публикацию документации по инструкции в https://git.jt4d.ru/jt4d/docuservix diff --git a/docusaurus.config.ts b/docusaurus.config.ts index d8a76c9..89414d5 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -1,9 +1,9 @@ import fs from 'fs'; import yaml from 'js-yaml'; -import {themes as prismThemes} from 'prism-react-renderer'; -import type {Config} from '@docusaurus/types'; +import { themes as prismThemes } from 'prism-react-renderer'; +import type { Config } from '@docusaurus/types'; import type * as Preset from '@docusaurus/preset-classic'; -import type {NavbarItem} from '@docusaurus/theme-common' +import type { NavbarItem } from '@docusaurus/theme-common'; interface DocsConfig { title: string; @@ -13,24 +13,17 @@ interface DocsConfig { const docsConfig = yaml.load(fs.readFileSync('./.docuservix.yml', 'utf8')) as DocsConfig; -const { - title, -} = docsConfig +const { title } = docsConfig; const url = process.env.DOCUSERVIX_URL; -const { - org, - repo -} = docsConfig.project +const { org, repo } = docsConfig.project; -const { - docs: docsDir = 'docs', - blog: blogDir -} = docsConfig.dirs || {} +const { docs: docsDir = 'docs', blog: blogDir } = docsConfig.dirs || {}; const giteaUrl = 'https://git.jt4d.ru'; -const onBrokenLinks = (process.env.DOCUSERVIX_ON_BROKEN_LINKS as Config['onBrokenLinks']) || 'throw'; +const onBrokenLinks = + (process.env.DOCUSERVIX_ON_BROKEN_LINKS as Config['onBrokenLinks']) || 'throw'; const config: Config = { title, @@ -107,11 +100,13 @@ const config: Config = { label: 'Документация', position: 'left', }, - blogDir ? { - to: '/blog', - label: 'Блог', - position: 'left' - } : undefined, + blogDir + ? { + to: '/blog', + label: 'Блог', + position: 'left', + } + : undefined, { href: `${giteaUrl}/${org}/${repo}`, label: 'Gitea', diff --git a/package.json b/package.json index 73d6955..7ec9275 100644 --- a/package.json +++ b/package.json @@ -3,20 +3,35 @@ "version": "0.0.0", "private": true, "scripts": { - "docusaurus": "docusaurus", - "start": "docusaurus start", "build": "docusaurus build", - "swizzle": "docusaurus swizzle", - "deploy": "docusaurus deploy", "clear": "docusaurus clear", + "deploy": "docusaurus deploy", + "docusaurus": "docusaurus", + "prepare": "husky", + "prettier:check": "prettier --check \"**/*.{ts,tsx,js,mjs,json,yml,yaml,md,mdx}\"", + "prettier:fix": "prettier --write \"**/*.{ts,tsx,js,mjs,json,yml,yaml,md,mdx}\"", "serve": "docusaurus serve", - "write-translations": "docusaurus write-translations", + "start": "docusaurus start", + "swizzle": "docusaurus swizzle", + "typecheck": "tsc", "write-heading-ids": "docusaurus write-heading-ids", - "typecheck": "tsc" + "write-translations": "docusaurus write-translations" }, "lint-staged": { "*.{json,ts,tsx,js,jsx,js,mjs,md,mdx,yaml,yml}": "prettier --write" }, + "browserslist": { + "production": [ + ">0.5%", + "not dead", + "not op_mini all" + ], + "development": [ + "last 3 chrome version", + "last 3 firefox version", + "last 5 safari version" + ] + }, "dependencies": { "@docusaurus/core": "3.10.1", "@docusaurus/faster": "3.10.1", @@ -40,18 +55,6 @@ "prettier": "^3.8.4", "typescript": "~6.0.2" }, - "browserslist": { - "production": [ - ">0.5%", - "not dead", - "not op_mini all" - ], - "development": [ - "last 3 chrome version", - "last 3 firefox version", - "last 5 safari version" - ] - }, "engines": { "node": ">=20.0" } diff --git a/scripts/prepare-docs.mjs b/scripts/prepare-docs.mjs index f4408f3..a7b59e0 100644 --- a/scripts/prepare-docs.mjs +++ b/scripts/prepare-docs.mjs @@ -9,23 +9,24 @@ pinIndexToTop(); * Гарантирует наличие sidebar_position: 0 в front matter файла index.md */ function pinIndexToTop() { - const indexPath = path.join(docsDir, 'index.md'); - if (!fs.existsSync(indexPath)) return; + const indexPath = path.join(docsDir, 'index.md'); + if (!fs.existsSync(indexPath)) return; - let content = fs.readFileSync(indexPath, 'utf8'); + let content = fs.readFileSync(indexPath, 'utf8'); - if (content.startsWith('---\n')) { - const endIdx = content.indexOf('\n---\n', 4); - if (endIdx === -1) return; + 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; + 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; - } + 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'); + fs.writeFileSync(indexPath, content); + console.log('prepare-docs: pinned index.md to sidebar top'); } diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 01a91ac..6d20b10 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -1,4 +1,4 @@ -import type {ReactNode} from 'react'; +import type { ReactNode } from 'react'; import clsx from 'clsx'; import Link from '@docusaurus/Link'; import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; @@ -8,33 +8,38 @@ import Heading from '@theme/Heading'; import styles from './index.module.css'; function HomepageHeader() { - const {siteConfig} = useDocusaurusContext(); - return ( -
-
- - {siteConfig.title} - -

{siteConfig.tagline}

-
- - Документация - -
-
-
- ); + const { siteConfig } = useDocusaurusContext(); + return ( +
+
+ + {siteConfig.title} + +

{siteConfig.tagline}

+
+ + Документация + +
+
+
+ ); } export default function Home(): ReactNode { - const {siteConfig} = useDocusaurusContext(); - return ( - - - - ); + const { siteConfig } = useDocusaurusContext(); + return ( + + + + ); } diff --git a/tsconfig.json b/tsconfig.json index 405d777..3035635 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,11 +2,14 @@ // It is here to improve your IDE experience (type-checking, autocompletion...), // and can also run the package.json "typecheck" script manually. { - "extends": "@docusaurus/tsconfig", - "compilerOptions": { - "baseUrl": ".", - "ignoreDeprecations": "6.0", - "strict": true - }, - "exclude": [".docusaurus", "build"] + "extends": "@docusaurus/tsconfig", + "compilerOptions": { + "baseUrl": ".", + "ignoreDeprecations": "6.0", + "strict": true + }, + "exclude": [ + ".docusaurus", + "build" + ] }