Skip to content

fix(website): 'Edit on GitHub' link on docs pages 404s — missing .mdx extension #142

Description

@NicolaasGrobler

Symptom

Clicking Edit on GitHub on any docs page opens a GitHub URL that 404s. URL looks like:

`https://github.com/openidle-dev/queryden/edit/main/website/src/content/docs/getting-started/install\`

That path doesn't exist on GitHub — the actual file is `install.mdx`.

Root cause

`website/src/pages/docs/[...slug].astro:23` passes `sourcePath={entry.id}` to `DocsLayout`. In Astro 6's content collections, `entry.id` no longer includes the file extension (it did in earlier Astro versions, hence the now-no-op `.replace(/.(md|mdx)$/, '')` in `getStaticPaths`). So `sourcePath` ends up as the bare slug like `getting-started/install` instead of `getting-started/install.mdx`.

`DocsLayout.astro:21-23`:

```astro
const editUrl = sourcePath
? `${SITE.repo}/edit/main/website/src/content/docs/${sourcePath}`
: `${SITE.repo}/edit/main/website/src/content/docs/${currentSlug}.mdx`;
```

The fallback (no sourcePath) correctly appends `.mdx`. The sourcePath branch doesn't.

Fix

Two equivalent options:

  1. In `[...slug].astro`, normalize: `sourcePath={`${entry.id.replace(/.(md|mdx)$/, '')}.mdx`}`
  2. In `DocsLayout.astro`, change the sourcePath branch to always end in `.mdx` regardless of input.

Either works. (1) is slightly cleaner since the layout doesn't need to know about extensions.

All docs in `website/src/content/docs/` are `.mdx` (verified). No `.md` files exist.

Acceptance

  • Click Edit on GitHub on any docs page → opens the corresponding `.mdx` file in GitHub's web editor.
  • No 404.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions