diff --git a/.github/workflows/opencatalogi-page-deploy.yml b/.github/workflows/opencatalogi-page-deploy.yml index 580c43aad..02df769f6 100644 --- a/.github/workflows/opencatalogi-page-deploy.yml +++ b/.github/workflows/opencatalogi-page-deploy.yml @@ -7,20 +7,25 @@ env: # Change these to your preferences any image url can also be a base encoded USE_GITHUB_REPOSITORY_NAME_AS_PATH_PREFIX: "true" GITHUB_REPOSITORY_NAME: ${{ github.event.repository.name }} - API_BASE_URL: "https://api.gateway.commonground.nu/api" - NL_DESIGN_THEME_CLASSNAME: "conduction-theme" - FAVICON_URL: "https://conduction.nl/wp-content/uploads/2021/07/cropped-favicon-32x32.png" - HEADER_LOGO_URL: "https://conduction.nl/wp-content/uploads/2021/07/cropped-conductionlogo-1.png" - ORGANISATION_NAME: "Conduction" - JUMBOTRON_IMAGE_URL: "https://www.conduction.nl/wp-content/uploads/2021/07/cropped-Conduction_HOME_0000_afb1-1.png" - FOOTER_LOGO_URL: "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/Pgo8IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDIwMDEwOTA0Ly9FTiIKICAgICJodHRwOi8vd3d3LnczLm9yZy9UUi8yMDAxL1JFQy1TVkctMjAwMTA5MDQvRFREL3N2ZzEwLmR0ZCI+CjxzdmcgdmVyc2lvbj0iMS4wIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgICAgd2lkdGg9IjcxLjAwMDAwMHB0IiBoZWlnaHQ9IjcwLjAwMDAwMHB0IiB2aWV3Qm94PSIwIDAgNzEuMDAwMDAwIDcwLjAwMDAwMCIKICAgICBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSJ4TWlkWU1pZCBtZWV0Ij4KCiAgICA8ZyB0cmFuc2Zvcm09InRyYW5zbGF0ZSgwLjAwMDAwMCw3MC4wMDAwMDApIHNjYWxlKDAuMTAwMDAwLC0wLjEwMDAwMCkiCiAgICAgICBmaWxsPSIjNDM3NkZDIiBzdHJva2U9Im5vbmUiPgogICAgICAgIDxwYXRoIGQ9Ik0yMTggNTkyIGwtMTM3IC03NyAwIC0xNjUgMCAtMTY1IDEzMSAtNzQgYzcyIC00MSAxMzcgLTc0IDE0MyAtNzQgNgowIDcwIDMzIDE0MyA3NCBsMTMxIDc0IDEgMTY1IDAgMTY1IC02OCAzNyBjLTM3IDIxIC05OSA1NiAtMTM3IDc3IGwtNzEgNDAKLTEzNiAtNzd6IG0yOTUgLTg1IGw1NyAtMzIgMCAtMTI1IDAgLTEyNSAtMTA2IC02MCBjLTU4IC0zMyAtMTA4IC02MCAtMTExCi01OSAtMyAwIC01MiAyNyAtMTA5IDYwIGwtMTAzIDU5IDAgMTI1IDAgMTI1IDEwNyA2MSAxMDcgNjIgNTAgLTI5IGMyNyAtMTYKNzYgLTQ0IDEwOCAtNjJ6Ii8+CiAgICAgICAgPHBhdGggZD0iTTI3OCA0NzIgbC02OCAtMzcgMCAtODUgMCAtODUgNzMgLTM5IDczIC0zOSA2MiAzNCBjMzQgMTggNjIgMzcgNjIKNDEgMCA0IC0xNCAxNSAtMzEgMjMgLTI4IDE1IC0zMyAxNSAtNTQgMSAtMzEgLTIwIC00NiAtMjAgLTg0IDIgLTI3IDE1IC0zMQoyMiAtMzEgNjIgMCA0MCA0IDQ3IDMxIDYzIDM4IDIxIDUzIDIxIDg0IDEgMjEgLTE0IDI2IC0xNCA1NCAxIDE3IDggMzEgMTkgMzEKMjMgMCA4IC0xMTMgNzIgLTEyNiA3MiAtNSAwIC0zOSAtMTcgLTc2IC0zOHoiLz4KICAgIDwvZz4KPC9zdmc+Cg==" - FOOTER_LOGO_HREF: "https://conduction.nl/" - # OIDN_NUMBER: " " + + ME_URL: "https://api.opencatalogi.nl/api/users/me" + API_URL: "https://api.opencatalogi.nl/api" + ADMIN_URL: "https://api.opencatalogi.nl/admin" + BASE_URL: "https://api.opencatalogi.nl" + FRONTEND_URL: "https://api.opencatalogi.nl" + LOGIN_REDIRECT: "vault" + ADMIN_DASHBOARD_URL: "https://admin.opencatalogi.nl" + + NL_DESIGN_THEME_CLASSNAME: rotterdam-theme + ARROW_BREADCRUMBS: "false" + + # GITHUB_ORGANIZATION_URL: "" on: push: branches: - - never + - main + - development jobs: build: @@ -37,17 +42,19 @@ jobs: - name: Make envfile uses: SpicyPizza/create-envfile@v2.0 with: - envkey_GITHUB_REPOSITORY_NAME: ${{ env.GITHUB_REPOSITORY_NAME }} - envkey_USE_GITHUB_REPOSITORY_NAME_AS_PATH_PREFIX: ${{ env.USE_GITHUB_REPOSITORY_NAME_AS_PATH_PREFIX }} - envkey_GATSBY_API_BASE_URL: ${{ env.API_BASE_URL }} + envkey_GATSBY_USE_GITHUB_REPOSITORY_NAME_AS_PATH_PREFIX: ${{ env.USE_GITHUB_REPOSITORY_NAME_AS_PATH_PREFIX }} + envkey_GATSBY_GITHUB_REPOSITORY_NAME: ${{ env.GITHUB_REPOSITORY_NAME }} + envkey_GATSBY_ME_URL: ${{ env.ME_URL }} + envkey_GATSBY_API_URL: ${{ env.API_URL }} + envkey_GATSBY_ADMIN_URL: ${{ env.ADMIN_URL }} + envkey_GATSBY_BASE_URL: ${{ env.BASE_URL }} + envkey_GATSBY_FRONTEND_URL: ${{ env.FRONTEND_URL }} + envkey_GATSBY_LOGIN_REDIRECT: ${{ env.LOGIN_REDIRECT }} + envkey_GATSBY_ADMIN_DASHBOARD_URL: ${{ env.ADMIN_DASHBOARD_URL }} envkey_GATSBY_NL_DESIGN_THEME_CLASSNAME: ${{ env.NL_DESIGN_THEME_CLASSNAME }} - envkey_GATSBY_FAVICON_URL: ${{ env.FAVICON_URL }} - envkey_GATSBY_HEADER_LOGO_URL: ${{ env.HEADER_LOGO_URL }} - envkey_GATSBY_ORGANISATION_NAME: ${{ env.ORGANISATION_NAME }} - envkey_GATSBY_JUMBOTRON_IMAGE_URL: ${{ env.JUMBOTRON_IMAGE_URL }} - envkey_GATSBY_FOOTER_LOGO_URL: ${{ env.FOOTER_LOGO_URL }} - envkey_GATSBY_FOOTER_LOGO_HREF: ${{ env.FOOTER_LOGO_HREF }} - # envkey_GATSBY_OIDN_NUMBER: ${{ env.OIDN_NUMBER }} + envkey_GATSBY_ARROW_BREADCRUMBS: ${{ env.ARROW_BREADCRUMBS }} + + # envkey_GATSBY_GITHUB_ORGANIZATION_URL: ${{ env.GITHUB_ORGANIZATION_URL }} directory: pwa/static file_name: .env.production fail_on_empty: true diff --git a/pwa/gatsby-config.js b/pwa/gatsby-config.js index 66dcd217d..a5c017cf7 100644 --- a/pwa/gatsby-config.js +++ b/pwa/gatsby-config.js @@ -5,6 +5,10 @@ require("dotenv").config({ }); module.exports = { + pathPrefix: + process.env.GATSBY_USE_GITHUB_REPOSITORY_NAME_AS_PATH_PREFIX === "true" + ? `/${process.env.GATSBY_GITHUB_REPOSITORY_NAME}` + : "", // we do NOT want to set the prefix if we're using an DNS plugins: [ { resolve: `gatsby-plugin-layout`, diff --git a/pwa/package.json b/pwa/package.json index d834e78d1..e97b0e4a5 100644 --- a/pwa/package.json +++ b/pwa/package.json @@ -4,13 +4,12 @@ "private": true, "description": "skeleton-pip", "author": "Conduction", - "keywords": [ - "gatsby" - ], + "keywords": ["gatsby"], "scripts": { "develop": "gatsby develop", "start": "gatsby develop", - "build": "gatsby build", + "build": "gatsby build --prefix-paths", + "deploy": "gatsby build --prefix-paths && gh-pages -d public", "serve": "gatsby serve", "clean": "gatsby clean", "lint": "npm-run-all lint:** ", diff --git a/pwa/src/apiService/resources/search.ts b/pwa/src/apiService/resources/search.ts index 1eff11941..a33437df5 100644 --- a/pwa/src/apiService/resources/search.ts +++ b/pwa/src/apiService/resources/search.ts @@ -11,13 +11,15 @@ export default class Search { } public getSearch = async (filters: IFilters): Promise => { - const { data } = await Send( - this._instance, - "GET", - `/search?page=${ - filters.currentPage - }&order[embedded.rating.rating]=desc&limit=10&extend[]=all${filtersToQueryParams(filters)}`, - ); + let endpoint = `/search?page=${ + filters.currentPage + }&order[embedded.rating.rating]=desc&limit=10&extend[]=all${filtersToQueryParams(filters)}`; + + if (process.env.GATSBY_GITHUB_ORGANIZATION_URL) { + endpoint += `&legal.repoOwner.github=${process.env.GATSBY_GITHUB_ORGANIZATION_URL}`; + } + + const { data } = await Send(this._instance, "GET", endpoint); return data; }; diff --git a/pwa/src/templates/templateParts/header/HeaderTemplate.tsx b/pwa/src/templates/templateParts/header/HeaderTemplate.tsx index bcfd53865..fb0ea1575 100644 --- a/pwa/src/templates/templateParts/header/HeaderTemplate.tsx +++ b/pwa/src/templates/templateParts/header/HeaderTemplate.tsx @@ -25,6 +25,7 @@ interface HeaderTemplateProps { export const HeaderTemplate: React.FC = ({ layoutClassName }) => { const { t } = useTranslation(); + const [isHomePage, setIsHomePage] = React.useState(false); const [filters, setFilters] = React.useContext(FiltersContext); const [topNavItems, setTopNavItems] = React.useState([]); @@ -44,6 +45,14 @@ export const HeaderTemplate: React.FC = ({ layoutClassName navigate(pathname); }; + React.useEffect(() => { + setIsHomePage( + pathname === "/" || + (process.env.GATSBY_USE_GITHUB_REPOSITORY_NAME_AS_PATH_PREFIX === "true" && + pathname === `/${process.env.GATSBY_GITHUB_REPOSITORY_NAME}/`), + ); + }, [pathname]); + const primaryTopNavItems = [ { label: "Home", @@ -182,7 +191,7 @@ export const HeaderTemplate: React.FC = ({ layoutClassName - {pathname === "/" && ( + {isHomePage && (
diff --git a/pwa/static/.env.development b/pwa/static/.env.development index 727cb6c64..b3fcb34cd 100644 --- a/pwa/static/.env.development +++ b/pwa/static/.env.development @@ -1,13 +1,17 @@ +GATSBY_GITHUB_REPOSITORY_NAME=web-app +# options: "true" | "false" +GATSBY_USE_GITHUB_REPOSITORY_NAME_AS_PATH_PREFIX=true + # Backend-config GATSBY_ME_URL=https://api.opencatalogi.nl/api/users/me GATSBY_API_URL=https://api.opencatalogi.nl/api GATSBY_ADMIN_URL=https://api.opencatalogi.nl/admin GATSBY_BASE_URL=https://api.opencatalogi.nl GATSBY_FRONTEND_URL=https://api.opencatalogi.nl -GATSBY_ORGANIZATION="" GATSBY_LOGIN_REDIRECT=vault GATSBY_ADMIN_DASHBOARD_URL=https://admin.opencatalogi.nl # Config GATSBY_NL_DESIGN_THEME_CLASSNAME=rotterdam-theme -GATSBY_ARROW_BREADCRUMBS="false" +GATSBY_ARROW_BREADCRUMBS=false +# GATSBY_GITHUB_ORGANIZATION_URL="" diff --git a/pwa/static/.env.production b/pwa/static/.env.production index b725dec8a..ec92f1c1d 100644 --- a/pwa/static/.env.production +++ b/pwa/static/.env.production @@ -1,13 +1,18 @@ +GATSBY_GITHUB_REPOSITORY_NAME= +# options: "true" | "false" +GATSBY_USE_GITHUB_REPOSITORY_NAME_AS_PATH_PREFIX= + + # Backend-config GATSBY_ME_URL= GATSBY_API_URL= GATSBY_ADMIN_URL= GATSBY_BASE_URL= GATSBY_FRONTEND_URL= -GATSBY_ORGANIZATION= GATSBY_LOGIN_REDIRECT= GATSBY_ADMIN_DASHBOARD_URL= # Config GATSBY_NL_DESIGN_THEME_CLASSNAME= -GATSBY_ARROW_BREADCRUMBS= \ No newline at end of file +GATSBY_ARROW_BREADCRUMBS= +# GATSBY_GITHUB_ORGANIZATION_URL= \ No newline at end of file