invertase / invertase/docs.page

Bug: Local Preview "file not found" with anchor links on refresh

Open
#412 2 comments 0 reactions 1 assignee Claimed by @Ehesp View on GitHub
status: investigating
Dominant language
TypeScript
Stars
673
Forks
101
Avg merge
4d 5h
Merged PRs (30d)
10

Description

When using local preview mode, if you click on an anchor link, change your content and reload the page, it will throw a page not found error. To resolve, if you remove the anchor link from the URL and refresh, the page loads

**To Replicate**

1. Create a page, with a H2 header

```mdx
---
title: Test
---

Test Page

## Anchor Link

Test Anchor
```

2. Load the page using docs.page/preview
3. Click on the anchor link, which sets the browser URL to `https://docs.page/preview/testpage#anchor-link`
4 Hit Ctrl+R

![Image](https://github.com/user-attachments/assets/8174b08c-5f3a-4cb8-ab61-48b009b592a2)

5. To resolve - remove the anchor link, ie ` https://docs.page/preview/testpage`

The cause of the issue appears to be here: https://github.com/invertase/docs.page/blob/main/website/src/layouts/preview/utils.ts#L265-L267

Its looking for `page#anchor.mdx`. To confirm this, you can create another page called `page#anchor.mdx` in your directory. When you go through the steps above, it will load the `page#anchor.mdx` file rather than `page.mdx`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.