Skip to content

Fix editLink для продуктов не учитывает orgName из repositories.json #75

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jun 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Это сайт на vitepress для экосистемы Autumn. Он содержит как описание продуктов, так и описание их API.
Локально уже установлен node.js, зависимости.
Документация подчинённых проектов (repositories.json) синхронизирована в каталог sync.
Структура сайта собирается динамически, с активным использованием rewrite rules.

Проверяй свои действия, собирая сайт и проверяя результирующие html-файлы. Используй curl на локальный адрес сайта только при необходимости.
34 changes: 34 additions & 0 deletions .github/workflows/copilot-setup-steps.yml
Original file line number Diff line number Diff line change
@@ -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
52 changes: 39 additions & 13 deletions .vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,29 @@ export default defineConfig({
const repositories = JSON.parse(fs.readFileSync('repositories.json', 'utf-8'));
const repositoriesMap: Map<string, RepoData> = 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,
}
}

Expand Down Expand Up @@ -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 ''
Expand Down