The Edit the page on GitHub link for view-components doesn't link to the right place
When viewing the docs at https://primer.style/view-components/ I noticed that Edit the page on GitHub link is taking the form of
https://github.com/primer/view_components/edit/content/<file> instead of https://github.com/primer/view_components/edit/main/docs/content/<file>
which means that none of the "Edit" links work
I found the link generation for the doctocat theme and this looks right to me, but I do see it is under data.allMdx.nodes. I'm not sure of .md files go through a different rendering path than .mdx files, but if they do I couldn't find it, so I wasn't able to quickly find where the issue lies.
Thanks!
Thanks for the report. I think it used to work initially when the docs were .md files, but later the documentation for components was moved to be part of the source. For example this page: https://primer.style/view-components/components/alpha/tooltip
| Description | URL |
|---|---|
href in markup |
https://github.com/primer/view_components/edit/main/../content/components/alpha/tooltip.md |
| Resolves to URL | https://github.com/primer/view_components/edit/content/components/alpha/tooltip.md |
| Expected | https://github.com/primer/view_components/edit/main/app/components/primer/alpha/tooltip.rb |
And here how Doctocat composes the links:
function getEditUrl(repo, filePath, defaultBranch) {
return `https://github.com/${repo.user}/${repo.project}/edit/${defaultBranch}/${filePath}`
}
Not sure if there is a way to configure the ${defaultBranch}/${filePath} to make it the same as the source? But some parts of the docs are still under /docs/content which makes it more complicated. 🤔
A simpler fix would be to just hide the "Edit on GitHub" link, by removing repository from package.json, see docs. But then I assume the links to the repo won't work anymore.
Or add support to hide the link in Doctocat. I made an issue here: https://github.com/primer/doctocat/issues/494.
@tallys
I'm closing this, as it'll be addressed in a new docs system we're working on.