diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md new file mode 100644 index 0000000..c355b96 --- /dev/null +++ b/.github/copilot-instructions.md @@ -0,0 +1,6 @@ +Это сайт на vitepress для экосистемы Autumn. Он содержит как описание продуктов, так и описание их API. +Локально уже установлен node.js, зависимости. +Документация подчинённых проектов (repositories.json) синхронизирована в каталог sync. +Структура сайта собирается динамически, с активным использованием rewrite rules. + +Проверяй свои действия, собирая сайт и проверяя результирующие html-файлы. Используй curl на локальный адрес сайта только при необходимости. diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml new file mode 100644 index 0000000..1df7e8f --- /dev/null +++ b/.github/workflows/copilot-setup-steps.yml @@ -0,0 +1,34 @@ +name: "Coding Agent Environment Setup" + +# Allow testing of the setup steps from your repository's "Actions" tab. +on: workflow_dispatch + +jobs: + # The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot. + copilot-setup-steps: + runs-on: ubuntu-latest + + # Set the permissions to the lowest permissions possible needed for your steps. + # Copilot will be given its own token for its operations. + permissions: + # Clone the repository to install dependencies + contents: read + + steps: + + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '23' # Use the Node.js version compatible with VitePress + + - name: Install dependencies + run: npm install + + - name: Fetch documentation contents + run: npm run sync + + - name: Build the site + run: npm run docs:build diff --git a/.vitepress/config.mts b/.vitepress/config.mts index a699f7d..2d299a5 100644 --- a/.vitepress/config.mts +++ b/.vitepress/config.mts @@ -19,12 +19,29 @@ export default defineConfig({ const repositories = JSON.parse(fs.readFileSync('repositories.json', 'utf-8')); const repositoriesMap: Map = new Map(repositories.map((repoData: RepoData) => [repoData.repository, repoData])); - const repoName = pageData.relativePath.split('/')[1]?.replace(/\d+-/g, ''); + let repoName: string = ''; + + // Use filePath for all variants to extract repository name + if (pageData.filePath) { + if (pageData.filePath.startsWith('api/')) { + // For API paths: api/000-autumn/... or api/003-extends/... + const pathSegments = pageData.filePath.split('/'); + const repoSegment = pathSegments[1] || ''; + repoName = repoSegment.replace(/^\d+-/, ''); // Remove number prefix + } else if (pageData.filePath.startsWith('products/')) { + // For product paths: products/000-autumn/... or products/003-extends/... + const pathSegments = pageData.filePath.split('/'); + const repoSegment = pathSegments[1] || ''; + repoName = repoSegment.replace(/^\d+-/, ''); // Remove number prefix + } + } + const repoData = repositoriesMap.get(repoName); return { params: { organization: repoData?.organization, + repository: repoData?.repository, } } @@ -156,19 +173,28 @@ export default defineConfig({ const relativePath = pageData.relativePath const organization = pageData.params?.organization; + const repository = pageData.params?.repository; + + // If we have repository info from params, use it directly + if (organization && repository) { + if (relativePath.startsWith('api/')) { + // For API paths, remove 'api/' and repository name from path + const [_, repoSegment, ...rest] = relativePath.split('/') + const restPath = rest.join('/') + return `https://github.com/${organization}/${repository}/edit/master/docs/api/${restPath}`; + } - // Common calculation for repo extraction from relativePath - const [_, repoName, ...rest] = relativePath.split('/') - const repoNamePath = repoName?.replace(/\d+-/g, '') || '' - const restPath = rest.join('/') - const orgName = organization || 'autumn-library'; - - if (relativePath.startsWith('api/')) { - return `https://github.com/${orgName}/${repoNamePath}/edit/master/docs/api/${restPath}` - } - - if (relativePath.startsWith('products/')) { - return `https://github.com/${orgName}/${repoNamePath}/edit/master/docs/product/${restPath}` + // For product pages - determine path based on repository type + if (repository === 'autumn') { + // This is autumn documentation at root level - use entire relativePath + const restPath = relativePath + return `https://github.com/${organization}/${repository}/edit/master/docs/product/${restPath}`; + } else { + // This is other repository documentation - path after first segment (repository name) + const [_, ...rest] = relativePath.split('/') + const restPath = rest.join('/') + return `https://github.com/${organization}/${repository}/edit/master/docs/product/${restPath}`; + } } return ''