Index: document/src/App.jsx =================================================================== diff -u -r9680c9eb7e7f593cafe96716c2dcb6877aa5c706 -rccb300fdb5164cab7100b83ce99df42b554b9d3b --- document/src/App.jsx (.../App.jsx) (revision 9680c9eb7e7f593cafe96716c2dcb6877aa5c706) +++ document/src/App.jsx (.../App.jsx) (revision ccb300fdb5164cab7100b83ce99df42b554b9d3b) @@ -31,8 +31,8 @@ Route path 를 만들고 contexts/contexts.jsx 파일로 가서 서브 메뉴 링크를 수정하면 연결 됩니다. To connect the path to the submenu, check 'contexts/contets.jsx' */} - }> - } /> + }> + } /> } /> } /> } /> Index: document/src/components/shadcn/ui/accordion.jsx =================================================================== diff -u -r3dbe1098df9b1ed1b18f66471db263644b63efb2 -rccb300fdb5164cab7100b83ce99df42b554b9d3b --- document/src/components/shadcn/ui/accordion.jsx (.../accordion.jsx) (revision 3dbe1098df9b1ed1b18f66471db263644b63efb2) +++ document/src/components/shadcn/ui/accordion.jsx (.../accordion.jsx) (revision ccb300fdb5164cab7100b83ce99df42b554b9d3b) @@ -9,7 +9,7 @@ const Accordion = AccordionPrimitive.Root const AccordionItem = React.forwardRef(({ className, ...props }, ref) => ( - + )) AccordionItem.displayName = "AccordionItem" Index: document/src/contexts/contexts.jsx =================================================================== diff -u -r3dbe1098df9b1ed1b18f66471db263644b63efb2 -rccb300fdb5164cab7100b83ce99df42b554b9d3b --- document/src/contexts/contexts.jsx (.../contexts.jsx) (revision 3dbe1098df9b1ed1b18f66471db263644b63efb2) +++ document/src/contexts/contexts.jsx (.../contexts.jsx) (revision ccb300fdb5164cab7100b83ce99df42b554b9d3b) @@ -29,7 +29,7 @@ export const SubMenuContext = createContext(); export const SubMenuContextProvider = ({children}) => { - const { activeLink, handleSetActiveLink } = useActiveLink(); + const { activeLink, handleSetActiveLink } = useActiveLink(); const value = [ { Index: document/src/layout/HeaderMenu.jsx =================================================================== diff -u -r3dbe1098df9b1ed1b18f66471db263644b63efb2 -rccb300fdb5164cab7100b83ce99df42b554b9d3b --- document/src/layout/HeaderMenu.jsx (.../HeaderMenu.jsx) (revision 3dbe1098df9b1ed1b18f66471db263644b63efb2) +++ document/src/layout/HeaderMenu.jsx (.../HeaderMenu.jsx) (revision ccb300fdb5164cab7100b83ce99df42b554b9d3b) @@ -1,40 +1,59 @@ -import React, { useContext } from 'react' -import { Link } from 'react-router-dom' +import { useContext, useEffect, useState } from 'react' +import { Link, useLocation } from 'react-router-dom' import { SubMenuContext } from '../contexts/contexts' -import { - Accordion, - AccordionContent, - AccordionItem, - AccordionTrigger, -} from "@/components/shadcn/ui/accordion" +import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "@/components/shadcn/ui/accordion" - export const AccordionMenu = ({ title, to, isActive }) => { return ( - {title} + {title} ) } export const SubMenu = () => { - const { menuItems, activeLink } = useContext(SubMenuContext); + const { menuItems, activeLink } = useContext(SubMenuContext) + const [openItems, setOpenItems] = useState([]) + const location = useLocation() + useEffect(() => { + const newOpenItems = menuItems + .map((item, index) => { + if (item.subMenus && (item.subMenus.some(subItem => subItem.to === location.pathname) || openItems.includes(`item-${index}`))) { + return `item-${index}`; + } + return null; + }) + .filter(Boolean); + setOpenItems(newOpenItems); + }, [location, menuItems]); + + const handleAccordionChange = (value) => { + setOpenItems(value); + }; + return ( <> {menuItems.map((item, index) => { - const isActive = activeLink === item.to; + const isActive = activeLink === item.to || (item.subMenus && item.subMenus.some(subItem => subItem.to === activeLink)) const combinedClassName = ` ${isActive ? `active !text-blue-400` : ''} ${item.className || ''} `.trim(); return ( - item.subMenus && item.subMenus.length > 0 ? ( // 메뉴 Data에 서브메뉴가 있을 시 아코디언 컴포넌트로 출력 - + // 메뉴 Data에 서브메뉴가 있을 시 아코디언 컴포넌트로 출력 + item.subMenus && item.subMenus.length > 0 ? ( + - {Array.isArray(item.title) ? ( Index: document/src/reducer/linkFetchReducer.jsx =================================================================== diff -u -r3dbe1098df9b1ed1b18f66471db263644b63efb2 -rccb300fdb5164cab7100b83ce99df42b554b9d3b --- document/src/reducer/linkFetchReducer.jsx (.../linkFetchReducer.jsx) (revision 3dbe1098df9b1ed1b18f66471db263644b63efb2) +++ document/src/reducer/linkFetchReducer.jsx (.../linkFetchReducer.jsx) (revision ccb300fdb5164cab7100b83ce99df42b554b9d3b) @@ -53,21 +53,18 @@ const savedSrc = domNode.attribs.src return ( { - // return e.target.src = import.meta.env.VITE_ASSET_URL + savedSrc; - // }} - /> - )} - if (domNode.name === "header") { + /> + )} + if (domNode.name === "header") { // Iterate over the children of the header + // 게시물 상단

문구 숨김 domNode.children.forEach((child) => { if (child.name === "h4") { // Modify the

element as needed child.attribs.class += ' hidden' } }) } - if (domNode.name === "section" && domNode.attribs.id === "bo_v_info") { return
} @@ -98,7 +95,6 @@ }); dispatch({ type: FETCH_SUCCESS, payload: parsedHtml }); } catch (error) { - console.log(error); dispatch({ type: FETCH_ERROR, payload: error.message }); }