fix "View as Markdown" feature not working (#8160)
Signed-off-by: The-Best-Codes <106822363+The-Best-Codes@users.noreply.github.com>
This commit is contained in:
@@ -359,6 +359,7 @@ function CopyPageButton(): ReactNode {
|
|||||||
|
|
||||||
// New wrapper component that adds dropdown menu to copy button
|
// New wrapper component that adds dropdown menu to copy button
|
||||||
function PageActionsMenu(): ReactNode {
|
function PageActionsMenu(): ReactNode {
|
||||||
|
const {metadata} = useDoc();
|
||||||
const [dropdownOpen, setDropdownOpen] = useState(false);
|
const [dropdownOpen, setDropdownOpen] = useState(false);
|
||||||
const dropdownRef = useRef<HTMLDivElement>(null);
|
const dropdownRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
@@ -391,11 +392,8 @@ function PageActionsMenu(): ReactNode {
|
|||||||
}, [dropdownOpen]);
|
}, [dropdownOpen]);
|
||||||
|
|
||||||
const handleViewMarkdown = () => {
|
const handleViewMarkdown = () => {
|
||||||
const currentPath = window.location.pathname;
|
const source = metadata?.source?.replace('@site/', '') || '';
|
||||||
const mdPath = currentPath.endsWith('/')
|
window.open(`https://raw.githubusercontent.com/block/goose/refs/heads/main/documentation/${source}`, '_blank');
|
||||||
? `${currentPath.slice(0, -1)}.md`
|
|
||||||
: `${currentPath}.md`;
|
|
||||||
window.open(mdPath, '_blank');
|
|
||||||
setDropdownOpen(false);
|
setDropdownOpen(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user