Skip to content

Commit 22ded33

Browse files
authored
Fix "Edit this page" link on production docs build (#4796)
* fix github link on production build * fix logic * one more fix * remove extra leading slash * fix replace logic
1 parent 2474041 commit 22ded33

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/dev/docs/src/Layout.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@ function Page({children, currentPage, publicUrl, styles, scripts, pathToPage}) {
123123
let title = currentPage.title + (!INDEX_RE.test(currentPage.name) || isBlog ? ` – ${pageSection}` : '');
124124
let hero = (parts.length > 1 ? HERO[parts[0]] : '') || heroImageHome;
125125
let heroUrl = `https://${TLD}/${currentPage.image || path.basename(hero)}`;
126+
let githubLink = pathToPage;
127+
if (githubLink.startsWith('/tmp/')) {
128+
githubLink = githubLink.slice(5);
129+
githubLink = githubLink.substring(githubLink.indexOf('/') + 1);
130+
githubLink = githubLink.replace(/docs/, 'packages');
131+
}
126132

127133
return (
128134
<html
@@ -198,7 +204,7 @@ function Page({children, currentPage, publicUrl, styles, scripts, pathToPage}) {
198204
<meta property="og:image" content={heroUrl} />
199205
<meta property="og:description" content={description} />
200206
<meta property="og:locale" content="en_US" />
201-
<meta data-github-src={pathToPage} />
207+
<meta data-github-src={githubLink} />
202208
<script
203209
type="application/ld+json"
204210
dangerouslySetInnerHTML={{__html: JSON.stringify(

0 commit comments

Comments
 (0)