docs: change report issue link (#10160)

This commit is contained in:
Shahed Nasser
2024-11-19 15:54:16 +02:00
committed by GitHub
parent 156494c646
commit a1738f823c
23 changed files with 40 additions and 190 deletions
@@ -4,7 +4,7 @@ import clsx from "clsx"
import React from "react"
import { Link, Tooltip } from "@/components"
import { ExclamationCircle, PlaySolid } from "@medusajs/icons"
import { GITHUB_ISSUES_PREFIX } from "@/constants"
import { GITHUB_ISSUES_LINK } from "@/constants"
import { CodeBlockCopyAction } from "./Copy"
export type CodeBlockActionsProps = {
@@ -109,9 +109,7 @@ export const CodeBlockActions = ({
)}
>
<Link
href={`${GITHUB_ISSUES_PREFIX}&title=${encodeURIComponent(
`Docs(Code Issue): `
)}`}
href={GITHUB_ISSUES_LINK}
target="_blank"
className={clsx(
"bg-transparent border-none cursor-pointer rounded",
@@ -1,6 +1,6 @@
"use client"
import React, { useRef, useState } from "react"
import React, { useMemo, useRef, useState } from "react"
// @ts-expect-error can't install the types package because it doesn't support React v19
import { CSSTransition, SwitchTransition } from "react-transition-group"
import { Solutions } from "./Solutions"
@@ -16,6 +16,7 @@ import {
} from "@/components"
import { ChatBubbleLeftRight, ThumbDown, ThumbUp } from "@medusajs/icons"
import Link from "next/link"
import { useSiteConfig } from "../../providers"
export type FeedbackProps = {
event: string
@@ -39,7 +40,7 @@ export type FeedbackProps = {
export const Feedback = ({
event,
pathName,
reportLink,
reportLink: initReportLink,
question = "Was this page helpful?",
positiveBtn = "It was helpful",
negativeBtn = "It wasn't helpful",
@@ -54,6 +55,12 @@ export const Feedback = ({
showLongForm = false,
showDottedSeparator = true,
}: FeedbackProps) => {
const {
config: { reportIssueLink },
} = useSiteConfig()
const reportLink = useMemo(() => {
return initReportLink || reportIssueLink
}, [initReportLink, reportIssueLink])
const [showForm, setShowForm] = useState(false)
const [submittedFeedback, setSubmittedFeedback] = useState(false)
const [loading, setLoading] = useState(false)
@@ -26,7 +26,7 @@ type MainNavProps = {
}
export const MainNav = ({ className, itemsClassName }: MainNavProps) => {
const { reportIssueLink, editDate } = useMainNav()
const { editDate } = useMainNav()
const { setMobileSidebarOpen, isSidebarShown } = useSidebar()
const { config } = useSiteConfig()
@@ -64,7 +64,7 @@ export const MainNav = ({ className, itemsClassName }: MainNavProps) => {
<MainNavVersion />
{editDate && <MainNavEditDate date={editDate} />}
<LinkButton
href={reportIssueLink}
href={config.reportIssueLink || ""}
variant="subtle"
target="_blank"
className="text-compact-small-plus"
+2 -2
View File
@@ -1,8 +1,8 @@
import { OptionType } from "@/hooks"
import { NavigationItem } from "types"
export const GITHUB_ISSUES_PREFIX = `https://github.com/medusajs/medusa/issues/new?assignees=&labels=type%3A+docs&template=docs.yml`
export const GITHUB_UI_ISSUES_PREFIX = `https://github.com/medusajs/ui/issues/new?labels=documentation`
export const GITHUB_ISSUES_LINK =
"https://github.com/medusajs/medusa/issues/new/choose"
export const navDropdownItems: NavigationItem[] = [
{
@@ -9,7 +9,6 @@ export type MainNavContext = {
navItems: NavigationItem[]
activeItemIndex?: number
activeItem?: NavigationItem
reportIssueLink: string
editDate?: string
}
@@ -17,14 +16,12 @@ const MainNavContext = createContext<MainNavContext | null>(null)
export type MainNavProviderProps = {
navItems: NavigationItem[]
reportIssueLink: string
editDate?: string
children?: React.ReactNode
}
export const MainNavProvider = ({
navItems,
reportIssueLink,
children,
editDate,
}: MainNavProviderProps) => {
@@ -90,7 +87,6 @@ export const MainNavProvider = ({
value={{
navItems,
activeItemIndex,
reportIssueLink,
editDate,
activeItem,
}}
@@ -3,6 +3,7 @@
import React, { createContext, useContext, useState } from "react"
import { DocsConfig } from "types"
import { globalConfig } from "../../global-config"
import { GITHUB_ISSUES_LINK } from "../.."
export type SiteConfigContextType = {
config: DocsConfig
@@ -21,21 +22,25 @@ export const SiteConfigProvider = ({
children,
}: SiteConfigProviderProps) => {
const [config, setConfig] = useState<DocsConfig>(
initConfig || {
baseUrl: "",
sidebar: {
default: [],
mobile: [],
Object.assign(
{
baseUrl: "",
sidebar: {
default: [],
mobile: [],
},
project: {
title: "",
key: "",
},
breadcrumbOptions: {
showCategories: true,
},
reportIssueLink: GITHUB_ISSUES_LINK,
},
project: {
title: "",
key: "",
},
breadcrumbOptions: {
showCategories: true,
},
...globalConfig,
}
globalConfig,
initConfig || {}
)
)
return (
@@ -1,17 +0,0 @@
import { GITHUB_ISSUES_PREFIX, GITHUB_UI_ISSUES_PREFIX } from "../constants"
export type ReportLinkType = "default" | "ui"
export function formatReportLink(
title: string,
sectionTitle: string,
type?: ReportLinkType
) {
let prefix = GITHUB_ISSUES_PREFIX
if (type === "ui") {
prefix = GITHUB_UI_ISSUES_PREFIX
}
return `${prefix}&title=${encodeURI(title)}%3A%20Issue%20in%20${encodeURI(
sectionTitle
)}`
}
-1
View File
@@ -3,7 +3,6 @@ export * from "./capitalize"
export * from "./check-sidebar-item-visibility"
export * from "./decode-str"
export * from "./dom-utils"
export * from "./format-report-link"
export * from "./get-link-with-base-path"
export * from "./get-navbar-items"
export * from "./get-os-shortcut"