From 9bdaaf49f5b8e08f8d572b3ea1494d0267118a20 Mon Sep 17 00:00:00 2001 From: Remko Date: Thu, 1 Feb 2024 12:45:44 +0100 Subject: [PATCH 1/2] removed /pages prefix --- pwa/src/components/breadcrumbs/Breadcrumbs.tsx | 12 ++++++------ pwa/src/hooks/htmlParser/anchor/getAnchor.tsx | 6 +++--- pwa/src/hooks/useHeaderTopNavItems.ts | 3 ++- pwa/src/pages/{pages => }/[pageSlug]/PagePage.tsx | 2 +- .../[pageSlug]/[detailPageSlug]/DetailPagePage.tsx | 2 +- .../[pageSlug]/[detailPageSlug]/index.tsx | 0 pwa/src/pages/{pages => }/[pageSlug]/index.tsx | 0 pwa/src/pages/pages/index.tsx | 12 ------------ .../templateParts/footer/FooterContent.json | 6 +++--- pwa/src/templates/templateParts/header/Defaults.json | 2 +- .../templateParts/header/HeaderContent.json | 8 ++++---- .../templateParts/header/HeaderTemplate.tsx | 5 +++-- pwa/static/.env.development | 6 +++--- 13 files changed, 27 insertions(+), 37 deletions(-) rename pwa/src/pages/{pages => }/[pageSlug]/PagePage.tsx (76%) rename pwa/src/pages/{pages => }/[pageSlug]/[detailPageSlug]/DetailPagePage.tsx (77%) rename pwa/src/pages/{pages => }/[pageSlug]/[detailPageSlug]/index.tsx (100%) rename pwa/src/pages/{pages => }/[pageSlug]/index.tsx (100%) delete mode 100644 pwa/src/pages/pages/index.tsx diff --git a/pwa/src/components/breadcrumbs/Breadcrumbs.tsx b/pwa/src/components/breadcrumbs/Breadcrumbs.tsx index 5ec8fbf..c033dbd 100644 --- a/pwa/src/components/breadcrumbs/Breadcrumbs.tsx +++ b/pwa/src/components/breadcrumbs/Breadcrumbs.tsx @@ -16,28 +16,28 @@ export const Breadcrumbs: React.FC = () => { const { gatsbyContext } = useGatsbyContext(); const pageSlugLabel = () => { - const splitNumber = process.env.GATSBY_USE_GITHUB_REPOSITORY_NAME_AS_PATH_PREFIX === "true" ? 3 : 2; + const splitNumber = process.env.GATSBY_USE_GITHUB_REPOSITORY_NAME_AS_PATH_PREFIX === "true" ? 3 : 1; const stringLabel = location.pathname.split("/")[splitNumber]; return stringLabel?.replaceAll("_", " "); }; const detailPageSlugLabel = () => { - const splitNumber = process.env.GATSBY_USE_GITHUB_REPOSITORY_NAME_AS_PATH_PREFIX === "true" ? 4 : 3; + const splitNumber = process.env.GATSBY_USE_GITHUB_REPOSITORY_NAME_AS_PATH_PREFIX === "true" ? 3 : 2; const stringLabel = location.pathname.split("/")[splitNumber]; return stringLabel?.replaceAll("_", " "); }; const translatedCrumbs = gatsbyContext.pageContext.breadcrumb.crumbs.map((crumb: any) => { - if (crumb.pathname === "/pages/[pageSlug]") { - return { ...crumb, crumbLabel: t(pageSlugLabel()), pathname: `/pages/${t(pageSlugLabel())}` }; + if (crumb.pathname === "/[pageSlug]") { + return { ...crumb, crumbLabel: t(pageSlugLabel()), pathname: `/${t(pageSlugLabel())}` }; } - if (crumb.pathname === "/pages/[pageSlug]/[detailPageSlug]") { + if (crumb.pathname === "/[pageSlug]/[detailPageSlug]") { return { ...crumb, crumbLabel: t(detailPageSlugLabel()), - pathname: `/pages/${t(pageSlugLabel())}/${t(detailPageSlugLabel())}`, + pathname: `/${t(pageSlugLabel())}/${t(detailPageSlugLabel())}`, }; } else return { ...crumb, crumbLabel: t(_.upperFirst(crumb.crumbLabel)) }; }); diff --git a/pwa/src/hooks/htmlParser/anchor/getAnchor.tsx b/pwa/src/hooks/htmlParser/anchor/getAnchor.tsx index ab9c6a3..d8578b7 100644 --- a/pwa/src/hooks/htmlParser/anchor/getAnchor.tsx +++ b/pwa/src/hooks/htmlParser/anchor/getAnchor.tsx @@ -57,7 +57,7 @@ const handleInternalLinks = (props: any, targetFile: string, location: string, d // Internal Links: same directory if (!props.href.includes("/")) { const targetDirectory = _.upperFirst(location.split("/").reverse()[1]); - navigate(`/pages/${targetDirectory}/${targetFile}`); + navigate(`/${targetDirectory}/${targetFile}`); return; // ensure no other flow is triggered } @@ -66,7 +66,7 @@ const handleInternalLinks = (props: any, targetFile: string, location: string, d if (props.href.includes("/") && location === "/") { const directoryFound = directories.some((directory) => directory.location === props.href); - if (directoryFound) navigate(`/pages/${targetFile}`); + if (directoryFound) navigate(`/${targetFile}`); return; // ensure no other flow is triggered } @@ -80,7 +80,7 @@ const handleInternalLinks = (props: any, targetFile: string, location: string, d // Internal Link exists: redirect to page if (directoryFound) { - navigate(`/pages/${_.upperFirst(targetDirectory)}/${targetFile}`); + navigate(`/${_.upperFirst(targetDirectory)}/${targetFile}`); } // Internal Link does not exist: redirect to online GitHub environment (TODO) diff --git a/pwa/src/hooks/useHeaderTopNavItems.ts b/pwa/src/hooks/useHeaderTopNavItems.ts index b5d699e..b2c56a3 100644 --- a/pwa/src/hooks/useHeaderTopNavItems.ts +++ b/pwa/src/hooks/useHeaderTopNavItems.ts @@ -32,6 +32,7 @@ export const useHeaderTopNavItems = (optionalData?: THeaderTopNavItem[]) => { getHeaderContent.isSuccess && getHeaderContent.data.concat(optionalData); // For development + // optionalData may not be visible during initialization while developing // const getHeaderContent = { data: require("../data/DevHeaderContent.json") }; // getHeaderContent.data.concat(optionalData); @@ -83,7 +84,7 @@ export const useHeaderTopNavItems = (optionalData?: THeaderTopNavItem[]) => { if (!onClick.link && onClick.internalMarkdown) { if (type === "internalMarkdown") { - navigate(`/pages/${onClick.internalMarkdown.directoryName}/${onClick.internalMarkdown.fileName}`); + navigate(`/${onClick.internalMarkdown.directoryName}/${onClick.internalMarkdown.fileName}`); } } }; diff --git a/pwa/src/pages/pages/[pageSlug]/PagePage.tsx b/pwa/src/pages/[pageSlug]/PagePage.tsx similarity index 76% rename from pwa/src/pages/pages/[pageSlug]/PagePage.tsx rename to pwa/src/pages/[pageSlug]/PagePage.tsx index 5f51f44..0304245 100644 --- a/pwa/src/pages/pages/[pageSlug]/PagePage.tsx +++ b/pwa/src/pages/[pageSlug]/PagePage.tsx @@ -1,6 +1,6 @@ import * as React from "react"; import { PageProps } from "gatsby"; -import { PageTemplate } from "../../../templates/pageTemplate/PageTemplate"; +import { PageTemplate } from "../../templates/pageTemplate/PageTemplate"; const PagePage: React.FC = (props: PageProps) => { const pageSlug = props.params.pageSlug; diff --git a/pwa/src/pages/pages/[pageSlug]/[detailPageSlug]/DetailPagePage.tsx b/pwa/src/pages/[pageSlug]/[detailPageSlug]/DetailPagePage.tsx similarity index 77% rename from pwa/src/pages/pages/[pageSlug]/[detailPageSlug]/DetailPagePage.tsx rename to pwa/src/pages/[pageSlug]/[detailPageSlug]/DetailPagePage.tsx index 82647ac..57aef0d 100644 --- a/pwa/src/pages/pages/[pageSlug]/[detailPageSlug]/DetailPagePage.tsx +++ b/pwa/src/pages/[pageSlug]/[detailPageSlug]/DetailPagePage.tsx @@ -1,6 +1,6 @@ import * as React from "react"; import { PageProps } from "gatsby"; -import { DetailPageTemplate } from "../../../../templates/detailPageTemplate/DetailPageTemplate"; +import { DetailPageTemplate } from "../../../templates/detailPageTemplate/DetailPageTemplate"; const DetailPagePage: React.FC = (props: PageProps) => { const detailPageSlug = props.params.detailPageSlug; diff --git a/pwa/src/pages/pages/[pageSlug]/[detailPageSlug]/index.tsx b/pwa/src/pages/[pageSlug]/[detailPageSlug]/index.tsx similarity index 100% rename from pwa/src/pages/pages/[pageSlug]/[detailPageSlug]/index.tsx rename to pwa/src/pages/[pageSlug]/[detailPageSlug]/index.tsx diff --git a/pwa/src/pages/pages/[pageSlug]/index.tsx b/pwa/src/pages/[pageSlug]/index.tsx similarity index 100% rename from pwa/src/pages/pages/[pageSlug]/index.tsx rename to pwa/src/pages/[pageSlug]/index.tsx diff --git a/pwa/src/pages/pages/index.tsx b/pwa/src/pages/pages/index.tsx deleted file mode 100644 index 3375216..0000000 --- a/pwa/src/pages/pages/index.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import * as React from "react"; -import { navigate } from "gatsby"; - -const IndexPage: React.FC = () => { - React.useEffect(() => { - navigate("/"); - }); - - return <>; -}; - -export default IndexPage; diff --git a/pwa/src/templates/templateParts/footer/FooterContent.json b/pwa/src/templates/templateParts/footer/FooterContent.json index 3352c80..4731add 100644 --- a/pwa/src/templates/templateParts/footer/FooterContent.json +++ b/pwa/src/templates/templateParts/footer/FooterContent.json @@ -17,7 +17,7 @@ { "ariaLabel": "Roadmap", "value": "Roadmap", - "link": "/pages/Roadmap", + "link": "/Roadmap", "icon": { "prefix": "fas", "icon": "arrow-right", "placement": "left" } } ] @@ -28,7 +28,7 @@ { "ariaLabel": "Features README", "value": "README", - "link": "/pages/Features", + "link": "/Features", "icon": { "prefix": "fas", "icon": "arrow-right", "placement": "left" } }, { @@ -75,7 +75,7 @@ { "ariaLabel": "Usecases README", "value": "README", - "link": "/pages/Usecases", + "link": "/Usecases", "icon": { "prefix": "fas", "icon": "arrow-right", "placement": "left" } }, { diff --git a/pwa/src/templates/templateParts/header/Defaults.json b/pwa/src/templates/templateParts/header/Defaults.json index d1df328..05417f8 100644 --- a/pwa/src/templates/templateParts/header/Defaults.json +++ b/pwa/src/templates/templateParts/header/Defaults.json @@ -1,3 +1,3 @@ { - "NAVBAR_CONTENT_URL": "https://raw.githubusercontent.com/ConductionNL/product-website-template/f62359452725aa45c94a348b13d041af63646503/pwa/src/templates/templateParts/header/HeaderContent.json" + "NAVBAR_CONTENT_URL": "https://raw.githubusercontent.com/ConductionNL/product-website-template/main/pwa/src/templates/templateParts/header/HeaderContent.json" } diff --git a/pwa/src/templates/templateParts/header/HeaderContent.json b/pwa/src/templates/templateParts/header/HeaderContent.json index 61404e2..6ff1b00 100644 --- a/pwa/src/templates/templateParts/header/HeaderContent.json +++ b/pwa/src/templates/templateParts/header/HeaderContent.json @@ -13,23 +13,23 @@ "label": "Roadmap", "type": "internal", "current": { - "pathname": "/pages/Roadmap" + "pathname": "/Roadmap" }, "handleClick": { - "link": "/pages/Roadmap" + "link": "/Roadmap" } }, { "label": "Features", "current": { - "pathname": "/pages/Features" + "pathname": "/Features" }, "subItems": [ { "label": "README", "type": "internalMarkdown", "current": { - "pathname": "/pages/Features/README" + "pathname": "/Features/README" }, "handleClick": { "internalMarkdown": { diff --git a/pwa/src/templates/templateParts/header/HeaderTemplate.tsx b/pwa/src/templates/templateParts/header/HeaderTemplate.tsx index 3ec090b..6cb5f7d 100644 --- a/pwa/src/templates/templateParts/header/HeaderTemplate.tsx +++ b/pwa/src/templates/templateParts/header/HeaderTemplate.tsx @@ -2,6 +2,7 @@ import * as React from "react"; import * as styles from "./HeaderTemplate.module.css"; import clsx from "clsx"; import _ from "lodash"; +import { navigate } from "gatsby"; import { useTranslation } from "react-i18next"; import { Container, Logo, PrimaryTopNav } from "@conduction/components"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; @@ -74,12 +75,12 @@ export const HeaderTemplate: React.FC = ({ layoutClassName
- + navigate("/")} variant="navbar" />
- + navigate("/")} variant="navbar" />
} items={topNavItems} diff --git a/pwa/static/.env.development b/pwa/static/.env.development index d51e5cb..47e27e3 100644 --- a/pwa/static/.env.development +++ b/pwa/static/.env.development @@ -2,8 +2,8 @@ GATSBY_GITHUB_REPOSITORY_NAME=product-website-template # options: "true" | "false" GATSBY_USE_GITHUB_REPOSITORY_NAME_AS_PATH_PREFIX=false -GATSBY_GITHUB_REPOSITORY_URL=https://github.com/CommonGateway/CoreBundle -GATSBY_GITHUB_API_BASE_URL=https://api.github.com/repos/CommonGateway/CoreBundle/contents +GATSBY_GITHUB_REPOSITORY_URL=https://github.com/ConductionNL/product-website-template +GATSBY_GITHUB_API_BASE_URL=https://api.github.com/repos/ConductionNL/product-website-template/contents GATSBY_GITHUB_DOCS_DIRECTORY_PATHS=[{"name": "Features", "location": "/docs/features"}, {"name": "Roadmap", "location": "/docs/roadmap"}, {"name": "Usecases", "location": "/docs/usecases"}] # Links @@ -11,7 +11,7 @@ GATSBY_SLACK_URL="false" GATSBY_READ_THE_DOCS_URL="https://commongateway.readthedocs.io/en/latest/" # Navbar -GATSBY_NAVBAR_CONTENT="https://raw.githubusercontent.com/ConductionNL/product-website-template/f62359452725aa45c94a348b13d041af63646503/pwa/src/templates/templateParts/header/HeaderContent.json" +GATSBY_NAVBAR_CONTENT="https://raw.githubusercontent.com/ConductionNL/product-website-template/main/pwa/src/templates/templateParts/header/HeaderContent.json" # Footer GATSBY_FOOTER_CONTENT="https://raw.githubusercontent.com/ConductionNL/product-website-template/main/pwa/src/templates/templateParts/footer/FooterContent.json" From 4d6487c2405688702e74569478dedfcedad7a351 Mon Sep 17 00:00:00 2001 From: Remko Date: Thu, 1 Feb 2024 12:46:40 +0100 Subject: [PATCH 2/2] cleanup --- .github/workflows/product-page-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/product-page-deploy.yml b/.github/workflows/product-page-deploy.yml index 8b95db7..b1b041d 100644 --- a/.github/workflows/product-page-deploy.yml +++ b/.github/workflows/product-page-deploy.yml @@ -18,7 +18,7 @@ jobs: with: github_repository_name_as_prefix: true github_repository_url: https://github.com/ConductionNL/product-website-template - github_api_base_url: https://api.github.com/repos/${{ github.repository }}/contents + github_api_base_url: https://api.github.com/repos/ConductionNL/product-website-template/contents github_docs_directory_paths: '[{"name": "Features", "location": "/docs/features"}, {"name": "Roadmap", "location": "/docs/roadmap"}, {"name": "Usecases", "location": "/docs/usecases"}]' slack_url: "false" read_the_docs_url: "false"