Skip to content

Commit

Permalink
removed /pages prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
remko48 committed Feb 1, 2024
1 parent 1348ee3 commit 9bdaaf4
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 37 deletions.
12 changes: 6 additions & 6 deletions pwa/src/components/breadcrumbs/Breadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)) };
});
Expand Down
6 changes: 3 additions & 3 deletions pwa/src/hooks/htmlParser/anchor/getAnchor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand All @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion pwa/src/hooks/useHeaderTopNavItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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}`);
}
}
};
Expand Down
Original file line number Diff line number Diff line change
@@ -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<PageProps> = (props: PageProps) => {
const pageSlug = props.params.pageSlug;
Expand Down
Original file line number Diff line number Diff line change
@@ -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<PageProps> = (props: PageProps) => {
const detailPageSlug = props.params.detailPageSlug;
Expand Down
File renamed without changes.
12 changes: 0 additions & 12 deletions pwa/src/pages/pages/index.tsx

This file was deleted.

6 changes: 3 additions & 3 deletions pwa/src/templates/templateParts/footer/FooterContent.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
{
"ariaLabel": "Roadmap",
"value": "Roadmap",
"link": "/pages/Roadmap",
"link": "/Roadmap",
"icon": { "prefix": "fas", "icon": "arrow-right", "placement": "left" }
}
]
Expand All @@ -28,7 +28,7 @@
{
"ariaLabel": "Features README",
"value": "README",
"link": "/pages/Features",
"link": "/Features",
"icon": { "prefix": "fas", "icon": "arrow-right", "placement": "left" }
},
{
Expand Down Expand Up @@ -75,7 +75,7 @@
{
"ariaLabel": "Usecases README",
"value": "README",
"link": "/pages/Usecases",
"link": "/Usecases",
"icon": { "prefix": "fas", "icon": "arrow-right", "placement": "left" }
},
{
Expand Down
2 changes: 1 addition & 1 deletion pwa/src/templates/templateParts/header/Defaults.json
Original file line number Diff line number Diff line change
@@ -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"
}
8 changes: 4 additions & 4 deletions pwa/src/templates/templateParts/header/HeaderContent.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
5 changes: 3 additions & 2 deletions pwa/src/templates/templateParts/header/HeaderTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -74,12 +75,12 @@ export const HeaderTemplate: React.FC<HeaderTemplateProps> = ({ layoutClassName
<div className={styles.headerMiddleBar}>
<Container layoutClassName={styles.primaryNavContainer}>
<div className={clsx(styles.logoContainer, styles.logoDesktop)}>
<Logo variant="navbar" />
<Logo onClick={() => navigate("/")} variant="navbar" />
</div>
<PrimaryTopNav
mobileLogo={
<div className={clsx(styles.logoContainer, styles.logoMobile)}>
<Logo variant="navbar" />
<Logo onClick={() => navigate("/")} variant="navbar" />
</div>
}
items={topNavItems}
Expand Down
6 changes: 3 additions & 3 deletions pwa/static/.env.development
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
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
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"
Expand Down

0 comments on commit 9bdaaf4

Please sign in to comment.