Skip to content

Commit d54380b

Browse files
committed
fix issue with homepage
1 parent c572eaf commit d54380b

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/components/CopyMarkdown.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ function CopyMarkdown() {
2121
const currentPath = window.location.pathname;
2222

2323
// Remove trailing slash if it exists
24-
const normalizedPath = currentPath.endsWith('/')
24+
const normalizedPath = currentPath.endsWith('/') && currentPath !== '/'
2525
? currentPath.slice(0, -1)
2626
: currentPath;
2727

28-
// Construct the markdown URL
29-
const markdownUrl = `${normalizedPath}.md`;
28+
// For the homepage/intro, use /intro.md specifically
29+
const markdownPath = normalizedPath === '/' ? '/intro.md' : `${normalizedPath}.md`;
3030

3131
// Fetch the markdown content
32-
const response = await fetch(markdownUrl);
32+
const response = await fetch(markdownPath);
3333

3434
if (!response.ok) {
3535
throw new Error(`Failed to fetch markdown: ${response.status}`);
@@ -60,15 +60,15 @@ function CopyMarkdown() {
6060
const currentPath = window.location.pathname;
6161

6262
// Remove trailing slash if it exists
63-
const normalizedPath = currentPath.endsWith('/')
63+
const normalizedPath = currentPath.endsWith('/') && currentPath !== '/'
6464
? currentPath.slice(0, -1)
6565
: currentPath;
6666

67-
// Construct the markdown URL
68-
const markdownUrl = `${normalizedPath}.md`;
67+
// For the homepage/intro, use /intro.md specifically
68+
const markdownPath = normalizedPath === '/' ? '/intro.md' : `${normalizedPath}.md`;
6969

7070
// Open in a new tab
71-
window.open(markdownUrl, '_blank');
71+
window.open(markdownPath, '_blank');
7272

7373
// Close dropdown
7474
setIsOpen(false);
@@ -84,12 +84,15 @@ function CopyMarkdown() {
8484
const currentPath = window.location.pathname;
8585

8686
// Remove trailing slash if it exists
87-
const normalizedPath = currentPath.endsWith('/')
87+
const normalizedPath = currentPath.endsWith('/') && currentPath !== '/'
8888
? currentPath.slice(0, -1)
8989
: currentPath;
9090

91+
// For the homepage/intro, use /intro specifically
92+
const docPath = normalizedPath === '/' ? '/intro' : normalizedPath;
93+
9194
// Construct the full markdown URL with domain
92-
const fullMarkdownUrl = `https://docs.replicated.com${normalizedPath}.md`;
95+
const fullMarkdownUrl = `https://docs.replicated.com${docPath}.md`;
9396

9497
// Create the prompt to send to ChatGPT
9598
const prompt = `Read ${fullMarkdownUrl} so I can ask questions about it`;

0 commit comments

Comments
 (0)