From a4db54aa237cc1eb6e7c75b2d854e3087200d1e7 Mon Sep 17 00:00:00 2001 From: sastaachar Date: Sat, 10 Jun 2023 13:49:12 +0530 Subject: [PATCH] testing some stuff --- src/components/DevDocTemplate/index.tsx | 61 +++---------------------- src/components/LeftSidebar/helper.tsx | 2 +- src/components/LeftSidebar/index.tsx | 1 + 3 files changed, 8 insertions(+), 56 deletions(-) diff --git a/src/components/DevDocTemplate/index.tsx b/src/components/DevDocTemplate/index.tsx index 9badf5837..c36282e4c 100644 --- a/src/components/DevDocTemplate/index.tsx +++ b/src/components/DevDocTemplate/index.tsx @@ -41,11 +41,7 @@ import t from '../../utils/lang-utils'; const DevDocTemplate: FC = (props) => { const { data, location } = props; // console.log('awd', props); - const { - curPageNode, - navNode, - allAsciidoc: { edges }, - } = data; + const { curPageNode, navNode } = data; const { width, ref } = useResizeDetector(); const [params, setParams] = useState({ [TS_HOST_PARAM]: DEFAULT_HOST, @@ -81,10 +77,10 @@ const DevDocTemplate: FC = (props) => { setIsPublicSiteOpen(isPublicSite(location.search)); const paramObj = queryStringParser(location.search); - edges.map((e) => { - paramObj[e.node.parent.name] = - e.node.pageAttributes.pageid || NOT_FOUND_PAGE_ID; - }); + // edges.map((e) => { + // paramObj[e.node.parent.name] = + // e.node.pageAttributes.pageid || NOT_FOUND_PAGE_ID; + // }); setParams({ ...params, ...paramObj }); }, [location.search]); @@ -101,32 +97,6 @@ const DevDocTemplate: FC = (props) => { ); }, [location.search, location.hash]); - const setPageContent = (pageid: string = NOT_FOUND_PAGE_ID) => { - // check if url query param is having pageid or not - if (pageid) { - // fetch edge id for specified pageid in the url - const edgeIndex = edges.findIndex( - (i) => i.node.pageAttributes[TS_PAGE_ID_PARAM] === pageid, - ); - - // check if we have corresponding document to serve if not redirect to 404 - if (edgeIndex > -1) { - // get and set page title - setDocTitle( - edges[edgeIndex].node.document.title || - edges[edgeIndex].node.pageAttributes.title, - ); - - // get and set doc page content with dynamic data replaced - setDocContent( - passThroughHandler(edges[edgeIndex].node.html, params), - ); - } else { - // pageid not found redirect - setPageContent(NOT_FOUND_PAGE_ID); - } - } - }; const setPageContentFromSingleNode = (node: AsciiDocNode) => { setDocTitle(node.document.title || node.pageAttributes.title); @@ -254,6 +224,7 @@ const DevDocTemplate: FC = (props) => { isMaxMobileResolution={isMaxMobileResolution} setDarkMode={setDarkMode} isDarkMode={isDarkMode} + pageId={params[TS_PAGE_ID_PARAM]} />
{ const divElement = document.createElement('div'); divElement.innerHTML = navContent; - const allPageIds = []; + const allPageIds: string[] = []; divElement.querySelectorAll('a').forEach((link: HTMLAnchorElement) => { const splitArr = link.href.split('?'); if (splitArr.length > 1) { diff --git a/src/components/LeftSidebar/index.tsx b/src/components/LeftSidebar/index.tsx index cd0da31e1..325a83f86 100644 --- a/src/components/LeftSidebar/index.tsx +++ b/src/components/LeftSidebar/index.tsx @@ -39,6 +39,7 @@ const LeftSideBar = (props: { setLeftNavOpen: Function; isPublicSiteOpen: boolean; setDarkMode: Function; + pageId?: string; }) => { const params = queryStringParser(props.location.search); const [navContent, setNavContent] = useState('');