Skip to content

fix(docs): Edit links point to 404 for generated .md files #217

@polaz

Description

@polaz

Problem

VitePress "Edit this page on GitHub" links lead to 404 errors for pages generated from .md.in templates.

Current config (docs/.vitepress/config.mts:273-276):

editLink: {
  pattern: "https://github.com/structured-world/gitlab-mcp/edit/main/docs/:path",
  text: "Edit this page on GitHub",
}

This generates links like:

  • https://github.com/.../edit/main/docs/guide/index.md404 (file doesn't exist in repo)

Affected Pages

6 pages are generated from .md.in templates (listed in .gitignore):

VitePress Page Source Template Edit Link Status
/ docs/index.md.in ❌ 404
/guide/ docs/guide/index.md.in ❌ 404
/guide/authentication docs/guide/authentication.md.in ❌ 404
/guide/installation/claude-desktop docs/guide/installation/claude-desktop.md.in ❌ 404
/tools/ docs/tools/index.md.in ❌ 404
/clients/claude-desktop docs/clients/claude-desktop.md.in ❌ 404

All other pages (~50+) work correctly as their .md files are tracked in git.

Additional Issue

docs/clients/claude-desktop.md is missing from .gitignore despite being generated from .md.in template. Should be added to keep consistency.

Solution

VitePress supports editLink.pattern as a function. We can detect templated files and redirect to .md.in:

editLink: {
  pattern: ({ filePath }) => {
    // Files generated from .in templates
    const templatedFiles = [
      'index.md',
      'guide/index.md',
      'guide/authentication.md',
      'guide/installation/claude-desktop.md',
      'tools/index.md',
      'clients/claude-desktop.md',
    ];
    
    const relativePath = filePath.replace(/^docs\//, '');
    const isTemplated = templatedFiles.includes(relativePath);
    const targetPath = isTemplated ? `${filePath}.in` : filePath;
    
    return `https://github.com/structured-world/gitlab-mcp/edit/main/${targetPath}`;
  },
  text: "Edit this page on GitHub",
}

Alternative Solutions

  1. Disable edit links for generated pages — set editLink: false in frontmatter of .md.in templates
  2. Build-time injection — have inject-tool-refs.ts add frontmatter to generated files disabling edit link
  3. Custom component — replace default edit link with component that checks for .md.in

Tasks

  • Add docs/clients/claude-desktop.md to .gitignore
  • Implement editLink.pattern function to redirect templated files to .md.in
  • Test all 6 affected pages have correct edit links

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions