Skip to content

Commit 5058ba3

Browse files
committed
Add GitHub issue link and template
1 parent b053e70 commit 5058ba3

File tree

1 file changed

+65
-6
lines changed

1 file changed

+65
-6
lines changed

src/components/Support/SupportDropdownMenu.tsx

Lines changed: 65 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
import React, { useState, useEffect, useRef } from 'react';
2-
import styles from '@site/src/css/SupportDropdownMenu.module.css';
32
import AssistantModal from './AssistantModal'; // Import the AssistantModal component for the chatbot.
43
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; // Import the FontAwesomeIcon component.
54
import { faChevronDown } from '@fortawesome/free-solid-svg-icons'; // Import the icon.
65
import ContactSupportLink from "./ContactSupportLink"; // Import the Enterprise support link.
6+
import { useDoc } from '@docusaurus/plugin-content-docs/client';
77

88
const DropdownMenu: React.FC = () => {
99
const [isOpen, setIsOpen] = useState(false); // For dropdown visibility
1010
const [isModalOpen, setIsModalOpen] = useState(false); // For modal visibility
1111
const dropdownRef = useRef<HTMLDivElement>(null);
1212

13+
// Get document metadata from Docusaurus.
14+
const { metadata } = useDoc();
15+
const docTitle = metadata?.title || "Issue with documentation page"; // Use document title or fallback.
16+
1317
// Detect the language based on the URL path.
14-
const isJapanese = window.location.pathname.startsWith("/ja-jp");
18+
const isJapanese = typeof window !== "undefined" && window.location.pathname.startsWith("/ja-jp");
1519

1620
const toggleDropdown = () => {
1721
setIsOpen((prev) => !prev);
@@ -27,6 +31,58 @@ const DropdownMenu: React.FC = () => {
2731
setIsModalOpen(false);
2832
};
2933

34+
// Generate GitHub issue URL dynamically.
35+
const repoUrl = "https://github.com/scalar-labs/docs-scalardb/issues/new";
36+
37+
// Define issue title dynamically based on language.
38+
const issueTitle = encodeURIComponent(
39+
isJapanese ? `フィードバック: \`${docTitle}\` ページ` : `Feedback: \`${docTitle}\` page`
40+
);
41+
42+
// Define issue body dynamically based on language.
43+
const issueBody = encodeURIComponent(
44+
isJapanese
45+
? `**ドキュメントページの URL:** ${window.location.href.replace(/#.*$/, '')}
46+
47+
## 期待される動作
48+
49+
どのような動作を期待しましたか?
50+
51+
## 問題の説明
52+
53+
問題の内容をわかりやすく説明してください。
54+
55+
### 再現手順 (該当する場合)
56+
57+
問題を再現できる場合、手順を記載してください。
58+
59+
### スクリーンショット (該当する場合)
60+
61+
該当する場合は、スクリーンショットを添付してください。
62+
`
63+
: `**Documentation page URL:** ${window.location.href.replace(/#.*$/, '')}
64+
65+
## Expected behavior
66+
67+
What did you expect to happen?
68+
69+
## Describe the problem
70+
71+
Please provide a clear and concise description of what the issue is.
72+
73+
### Steps to reproduce (if applicable)
74+
75+
If the issue is reproducible, please list the steps to reproduce it.
76+
77+
### Screenshots (if applicable)
78+
79+
If applicable, add screenshots to help explain your problem.
80+
`
81+
);
82+
83+
// Construct the GitHub issue URL.
84+
const githubIssueUrl = `${repoUrl}?title=${issueTitle}&body=${issueBody}&labels=documentation`;
85+
3086
// Close the dropdown when clicking outside of the content container.
3187
useEffect(() => {
3288
function handleClickOutside(event: MouseEvent) {
@@ -45,21 +101,24 @@ const DropdownMenu: React.FC = () => {
45101
}, [isOpen]);
46102

47103
return (
48-
<div className={styles.supportDropdown} ref={dropdownRef}>
49104
<button className={styles.supportDropBtn} onClick={toggleDropdown}>
50105
{isJapanese ? "サポート" : "Support"} <FontAwesomeIcon icon={faChevronDown} fontSize={12} />
51106
</button>
52107

53108
{isOpen && (
54-
<div className={styles.supportDropdownContent}>
55109
<ContactSupportLink />
110+
<hr />
56111
<a href="https://stackoverflow.com/questions/tagged/scalardb" target="_blank">
57-
<b>Stack Overflow</b><br />{isJapanese ? "コミュニティ向けの質問" : "For questions to the community"}
58112
</a>
113+
<hr />
59114
<a href="#" onClick={openModal}>
60-
<b>{isJapanese ? "AI アシスタント(実験的)" : "AI assistant (experimental)"}</b><br />
61115
{isJapanese ? "Scalar メンバーシッププログラム向け" : "For Scalar Membership Program members"}
62116
</a>
117+
<hr />
118+
<a href={githubIssueUrl} target="_blank" rel="noopener noreferrer">
119+
<b>{isJapanese ? "ドキュメントの問題を報告" : "Report doc issue"}</b><br />
120+
{isJapanese ? "このページに関する問題を報告" : "For reporting an issue on this page"}
121+
</a>
63122
</div>
64123
)}
65124

0 commit comments

Comments
 (0)