From 2102f7ef162554799e70a0c929e90ec602a57e47 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Tue, 10 Oct 2023 11:55:17 -0400 Subject: [PATCH 01/17] chore: remove outdated readme content --- README.md | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/README.md b/README.md index a6ec10415..3ec1707de 100644 --- a/README.md +++ b/README.md @@ -67,31 +67,6 @@ Updated components in [📁`gatsby-theme-project-portal`](./packages/gatsby-theme-project-portal) will be shown in the Storybook. -### Build Site in Separate Directory (Locally) - -Load the shell scripts: -```zsh -source test-packaging.sh -``` - -Run the packaging, build the example site, and serve it locally: -```zsh -package-and-install -t "packages/example/" -w @thepolicylab-projectportals/gatsby-theme-project-portal -``` - -Please note `yarn` version should be `v3.4.1`. Check it using: - -``` -yarn -v -``` - -### Testing - -#### Local - -Run the "all local build and packaging checks (with npm)" run configuration in WebStorm. - - ### Release Process The release process is automated using GitHub Actions. From d248e7578d592d0a92b776ab7318ec0a03f78272 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Tue, 10 Oct 2023 11:56:08 -0400 Subject: [PATCH 02/17] chore: make thank-you-page work without intermediate file --- .../gatsby-node.js | 9 +++++--- .../src/layouts/ThankYouPageLayout.tsx | 22 ++++++++++++++++++- .../src/templates/thank-you-page.js | 21 ------------------ 3 files changed, 27 insertions(+), 25 deletions(-) delete mode 100644 packages/gatsby-theme-project-portal/src/templates/thank-you-page.js diff --git a/packages/gatsby-theme-project-portal/gatsby-node.js b/packages/gatsby-theme-project-portal/gatsby-node.js index 4261995bb..e630374bc 100644 --- a/packages/gatsby-theme-project-portal/gatsby-node.js +++ b/packages/gatsby-theme-project-portal/gatsby-node.js @@ -1,4 +1,6 @@ const { withDefaults } = require(`./utils/default-options`) +const fs = require("fs") +const path = require("path") const { projectTypeDefs, @@ -9,8 +11,9 @@ const { const CardPageTemplate = require.resolve(`./src/templates/card-page`) const AboutPageTemplate = require.resolve(`./src/templates/about-page`) const ContactPageTemplate = require.resolve(`./src/templates/contact-page`) -const ThankYouPageTemplate = require.resolve(`./src/templates/thank-you-page`) -const fs = require("fs") +const ThankYouPageLayout = require.resolve( + "./src/layouts/ThankYouPageLayout.tsx" +) exports.onPreBootstrap = ({ reporter }, themeOptions) => { const { themeImageDirectory } = withDefaults(themeOptions) @@ -153,7 +156,7 @@ exports.createPages = async ({ graphql, actions, reporter }) => { }) createPage({ path: thankYouPagePath, - component: ThankYouPageTemplate, + component: ThankYouPageLayout, context: { slug: slug, }, diff --git a/packages/gatsby-theme-project-portal/src/layouts/ThankYouPageLayout.tsx b/packages/gatsby-theme-project-portal/src/layouts/ThankYouPageLayout.tsx index 95d2ff79d..038b8d406 100644 --- a/packages/gatsby-theme-project-portal/src/layouts/ThankYouPageLayout.tsx +++ b/packages/gatsby-theme-project-portal/src/layouts/ThankYouPageLayout.tsx @@ -1,8 +1,10 @@ import React, { FunctionComponent } from "react" -import { Link } from "gatsby" +import { graphql, Link } from "gatsby" import { HeaderWithImage } from "../components" import { ImageDataLike } from "gatsby-plugin-image" +export { Head } from "../hooks" + interface ThankYouProps { data: { generalPage: { @@ -40,3 +42,21 @@ export const ThankYouPageLayout: FunctionComponent = ({ ) } + +export default ThankYouPageLayout + +export const query = graphql` + query ThankYouQuery($slug: String!) { + ...HeadData + ...LayoutData + page: generalPage(slug: { eq: $slug }) { + title + description: lede + } + generalPage(slug: { eq: $slug }) { + image { + ...HeaderWithImageBackground + } + } + } +` diff --git a/packages/gatsby-theme-project-portal/src/templates/thank-you-page.js b/packages/gatsby-theme-project-portal/src/templates/thank-you-page.js deleted file mode 100644 index c053e4ead..000000000 --- a/packages/gatsby-theme-project-portal/src/templates/thank-you-page.js +++ /dev/null @@ -1,21 +0,0 @@ -import { graphql } from "gatsby" -import { ThankYouPageLayout } from "../layouts" - -export default ThankYouPageLayout -export { Head } from "../hooks" - -export const query = graphql` - query ThankYouQuery($slug: String!) { - ...HeadData - ...LayoutData - page: generalPage(slug: { eq: $slug }) { - title - description: lede - } - generalPage(slug: { eq: $slug }) { - image { - ...HeaderWithImageBackground - } - } - } -` From aecccf5499e7f6599f3676e617ee5476cffc53de Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Tue, 10 Oct 2023 13:14:48 -0400 Subject: [PATCH 03/17] chore: update typescript config (maximum) --- tsconfig.json | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index dd50d1388..c254470f0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,11 +1,27 @@ { + "compileOnSave": true, "compilerOptions": { "resolveJsonModule": true, - "module": "commonjs", - "target": "es2017", - "noImplicitAny": false, + "module": "es6", + "target": "es5", + "noImplicitAny": true, "esModuleInterop": true, "jsx": "react", - "isolatedModules": true - } + "types": ["node"], + "moduleResolution": "node", + "lib": ["dom", "es2015", "es2017"], + "sourceMap": true, + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "allowSyntheticDefaultImports": true, + "downlevelIteration": true, + "baseUrl": "./", + "paths": { + "~/*": ["src/*"] + } + }, + "include": ["./src/**/*"], + "exclude": ["node_modules", "plugins"] } From 432ceebfc1334804d6bab7a4f50a81434f02b158 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Tue, 10 Oct 2023 13:27:19 -0400 Subject: [PATCH 04/17] chore: update config for about page --- .../gatsby-node.js | 2 +- .../src/layouts/AboutPageLayout.tsx | 33 +++++++++++++++++++ .../src/templates/about-page.js | 33 ------------------- 3 files changed, 34 insertions(+), 34 deletions(-) delete mode 100644 packages/gatsby-theme-project-portal/src/templates/about-page.js diff --git a/packages/gatsby-theme-project-portal/gatsby-node.js b/packages/gatsby-theme-project-portal/gatsby-node.js index e630374bc..c3de94111 100644 --- a/packages/gatsby-theme-project-portal/gatsby-node.js +++ b/packages/gatsby-theme-project-portal/gatsby-node.js @@ -9,7 +9,7 @@ const { pageTypeDefs, } = require(`./utils/types`) const CardPageTemplate = require.resolve(`./src/templates/card-page`) -const AboutPageTemplate = require.resolve(`./src/templates/about-page`) +const AboutPageTemplate = require.resolve(`./src/layouts/AboutPageLayout.tsx`) const ContactPageTemplate = require.resolve(`./src/templates/contact-page`) const ThankYouPageLayout = require.resolve( "./src/layouts/ThankYouPageLayout.tsx" diff --git a/packages/gatsby-theme-project-portal/src/layouts/AboutPageLayout.tsx b/packages/gatsby-theme-project-portal/src/layouts/AboutPageLayout.tsx index 57fff3879..3e27ca846 100644 --- a/packages/gatsby-theme-project-portal/src/layouts/AboutPageLayout.tsx +++ b/packages/gatsby-theme-project-portal/src/layouts/AboutPageLayout.tsx @@ -1,4 +1,5 @@ import React, { FunctionComponent } from "react" +import { graphql } from "gatsby" import { Accordion } from "../components/Accordion" import { HeaderWithImage, @@ -7,6 +8,8 @@ import { import { isNA } from "../utils" import { ImageDataLike } from "gatsby-plugin-image" +export { Head } from "../hooks" + interface AboutProps { data: { generalPage: { @@ -95,3 +98,33 @@ export const AboutPageLayout: FunctionComponent = ({ ) } + +export default AboutPageLayout + +export const query = graphql` + query AboutQuery($slug: String!) { + ...HeadData + ...LayoutData + page: generalPage(slug: { eq: $slug }) { + title + description: lede + } + generalPage(slug: { eq: $slug }) { + pageName + title + header + aims { + title + text + } + faq { + title + text + } + accessibility + image { + ...HeaderWithImageBackground + } + } + } +` diff --git a/packages/gatsby-theme-project-portal/src/templates/about-page.js b/packages/gatsby-theme-project-portal/src/templates/about-page.js deleted file mode 100644 index 633340512..000000000 --- a/packages/gatsby-theme-project-portal/src/templates/about-page.js +++ /dev/null @@ -1,33 +0,0 @@ -import { graphql } from "gatsby" -import { AboutPageLayout } from "../layouts" - -export default AboutPageLayout -export { Head } from "../hooks" - -export const query = graphql` - query AboutQuery($slug: String!) { - ...HeadData - ...LayoutData - page: generalPage(slug: { eq: $slug }) { - title - description: lede - } - generalPage(slug: { eq: $slug }) { - pageName - title - header - aims { - title - text - } - faq { - title - text - } - accessibility - image { - ...HeaderWithImageBackground - } - } - } -` From b2b1223f09d5cb0734f7f220bc954c861d30a447 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Tue, 10 Oct 2023 13:27:34 -0400 Subject: [PATCH 05/17] chore: undo renaming of thankyoupagetemplate --- packages/gatsby-theme-project-portal/gatsby-node.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/gatsby-theme-project-portal/gatsby-node.js b/packages/gatsby-theme-project-portal/gatsby-node.js index c3de94111..9e66cb713 100644 --- a/packages/gatsby-theme-project-portal/gatsby-node.js +++ b/packages/gatsby-theme-project-portal/gatsby-node.js @@ -11,7 +11,7 @@ const { const CardPageTemplate = require.resolve(`./src/templates/card-page`) const AboutPageTemplate = require.resolve(`./src/layouts/AboutPageLayout.tsx`) const ContactPageTemplate = require.resolve(`./src/templates/contact-page`) -const ThankYouPageLayout = require.resolve( +const ThankYouPageTemplate = require.resolve( "./src/layouts/ThankYouPageLayout.tsx" ) @@ -156,7 +156,7 @@ exports.createPages = async ({ graphql, actions, reporter }) => { }) createPage({ path: thankYouPagePath, - component: ThankYouPageLayout, + component: ThankYouPageTemplate, context: { slug: slug, }, From 475e5c9c5353bd04b7142278179803d8dbe4b202 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Tue, 10 Oct 2023 13:27:44 -0400 Subject: [PATCH 06/17] chore: reformat graphql --- .../gatsby-node.js | 50 +++++++++---------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/packages/gatsby-theme-project-portal/gatsby-node.js b/packages/gatsby-theme-project-portal/gatsby-node.js index 9e66cb713..e61b0a95d 100644 --- a/packages/gatsby-theme-project-portal/gatsby-node.js +++ b/packages/gatsby-theme-project-portal/gatsby-node.js @@ -61,39 +61,35 @@ const ProjectDetailPageTemplate = require.resolve( exports.createPages = async ({ graphql, actions, reporter }) => { const { createPage } = actions - const result = await graphql( - ` - query { - allProject { - nodes { - slug - } + const result = await graphql(` + query { + allProject { + nodes { + slug } - allCardPage { - nodes { - slug - filterOn { - status - } + } + allCardPage { + nodes { + slug + filterOn { + status } } - aboutPages: allGeneralPage( - filter: { templateKey: { eq: "AboutPage" } } - ) { - nodes { - slug - } + } + aboutPages: allGeneralPage(filter: { templateKey: { eq: "AboutPage" } }) { + nodes { + slug } - contactPages: allGeneralPage( - filter: { templateKey: { eq: "ContactPage" } } - ) { - nodes { - slug - } + } + contactPages: allGeneralPage( + filter: { templateKey: { eq: "ContactPage" } } + ) { + nodes { + slug } } - ` - ) + } + `) if (result.errors) { reporter.panicOnBuild(result.errors) From c2c2bf505564275054d3af3e264e5df6a64ed470 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Tue, 10 Oct 2023 13:28:02 -0400 Subject: [PATCH 07/17] docs: update readme for running test packaging script --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3ec1707de..94d53666a 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ theme and other plugins from the registry instead of the local directory: ```zsh source test-packaging.sh -package-and-install -t "packages/example-site/" -r react@^18,react-dom@^18,gatsby@^5,@thepolicylab-projectportals/gatsby-theme-project-portal,@thepolicylab-projectportals/project-portal-content-netlify +package-and-install -t "packages/example-site/" -w @thepolicylab-projectportals/gatsby-theme-project-portal,@thepolicylab-projectportals/project-portal-content-netlify ``` ### Use Prettier Code Formatter in WebStorm From b717d202de8ba621eaaa7e045f09302dcc03c3ef Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Tue, 10 Oct 2023 13:28:13 -0400 Subject: [PATCH 08/17] docs: update test packaging script docs --- test-packaging.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-packaging.sh b/test-packaging.sh index de34c03c4..9f34c8bdc 100644 --- a/test-packaging.sh +++ b/test-packaging.sh @@ -80,7 +80,7 @@ EXAMPLES % package-and-install -t "packages/example/" -w @thepolicylab-projectportals/gatsby-theme-project-portal Create a new duplicate of the "example-content" site: - % package-and-install -t "packages/example-content/" -w @thepolicylab-projectportals/gatsby-theme-project-portal,@thepolicylab-projectportals/project-portal-content-netlify + % package-and-install -t "packages/example-site/" -w @thepolicylab-projectportals/gatsby-theme-project-portal,@thepolicylab-projectportals/project-portal-content-netlify EOM From eab9bd9c3a31287c68220560b5a1659b8e41e7ca Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Tue, 10 Oct 2023 13:28:22 -0400 Subject: [PATCH 09/17] revert: changes to tsconfig --- tsconfig.json | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index c254470f0..dd50d1388 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,27 +1,11 @@ { - "compileOnSave": true, "compilerOptions": { "resolveJsonModule": true, - "module": "es6", - "target": "es5", - "noImplicitAny": true, + "module": "commonjs", + "target": "es2017", + "noImplicitAny": false, "esModuleInterop": true, "jsx": "react", - "types": ["node"], - "moduleResolution": "node", - "lib": ["dom", "es2015", "es2017"], - "sourceMap": true, - "strict": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noFallthroughCasesInSwitch": true, - "allowSyntheticDefaultImports": true, - "downlevelIteration": true, - "baseUrl": "./", - "paths": { - "~/*": ["src/*"] - } - }, - "include": ["./src/**/*"], - "exclude": ["node_modules", "plugins"] + "isolatedModules": true + } } From 9b897161e634c5d3a3cb75fa67ec3f1ea27cde60 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Tue, 10 Oct 2023 13:31:09 -0400 Subject: [PATCH 10/17] chore: remove extra CardPageLayout file --- .../gatsby-node.js | 2 +- .../src/layouts/CardPageLayout.tsx | 30 +++++++++++++++++++ .../src/templates/card-page.js | 30 ------------------- 3 files changed, 31 insertions(+), 31 deletions(-) delete mode 100644 packages/gatsby-theme-project-portal/src/templates/card-page.js diff --git a/packages/gatsby-theme-project-portal/gatsby-node.js b/packages/gatsby-theme-project-portal/gatsby-node.js index e61b0a95d..a77f94d28 100644 --- a/packages/gatsby-theme-project-portal/gatsby-node.js +++ b/packages/gatsby-theme-project-portal/gatsby-node.js @@ -8,7 +8,7 @@ const { contactTypeDefs, pageTypeDefs, } = require(`./utils/types`) -const CardPageTemplate = require.resolve(`./src/templates/card-page`) +const CardPageTemplate = require.resolve(`./src/layouts/CardPageLayout.tsx`) const AboutPageTemplate = require.resolve(`./src/layouts/AboutPageLayout.tsx`) const ContactPageTemplate = require.resolve(`./src/templates/contact-page`) const ThankYouPageTemplate = require.resolve( diff --git a/packages/gatsby-theme-project-portal/src/layouts/CardPageLayout.tsx b/packages/gatsby-theme-project-portal/src/layouts/CardPageLayout.tsx index 612886d01..2e732a15b 100644 --- a/packages/gatsby-theme-project-portal/src/layouts/CardPageLayout.tsx +++ b/packages/gatsby-theme-project-portal/src/layouts/CardPageLayout.tsx @@ -1,6 +1,9 @@ import { ProjectPage, CardProps } from "../components" import React, { FunctionComponent } from "react" import { ImageDataLike } from "gatsby-plugin-image" +import { graphql } from "gatsby" + +export { Head } from "../hooks" export interface CardPageLayoutProps { data: { @@ -39,3 +42,30 @@ export const CardPageLayout: FunctionComponent = ({ ) } + +export default CardPageLayout + +export const query = graphql` + query CardPageQuery($slug: String!, $statusFilter: [String]) { + ...HeadData + ...LayoutData + page: cardPage(slug: { eq: $slug }) { + title + description: lede + } + cardPage(slug: { eq: $slug }) { + pageName + title + lede + sortOptions + image { + ...HeaderWithImageBackground + } + } + allProject(filter: { status: { in: $statusFilter } }) { + nodes { + ...CardDetails + } + } + } +` diff --git a/packages/gatsby-theme-project-portal/src/templates/card-page.js b/packages/gatsby-theme-project-portal/src/templates/card-page.js deleted file mode 100644 index 5465e1b39..000000000 --- a/packages/gatsby-theme-project-portal/src/templates/card-page.js +++ /dev/null @@ -1,30 +0,0 @@ -import { graphql } from "gatsby" -import { CardPageLayout } from "../layouts" - -export default CardPageLayout -export { Head } from "../hooks" - -export const query = graphql` - query CardPageQuery($slug: String!, $statusFilter: [String]) { - ...HeadData - ...LayoutData - page: cardPage(slug: { eq: $slug }) { - title - description: lede - } - cardPage(slug: { eq: $slug }) { - pageName - title - lede - sortOptions - image { - ...HeaderWithImageBackground - } - } - allProject(filter: { status: { in: $statusFilter } }) { - nodes { - ...CardDetails - } - } - } -` From d569193f89ffdaca68f74cd4b84a163c086f0a0a Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Tue, 10 Oct 2023 13:31:23 -0400 Subject: [PATCH 11/17] chore: remove unused path import --- packages/gatsby-theme-project-portal/gatsby-node.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/gatsby-theme-project-portal/gatsby-node.js b/packages/gatsby-theme-project-portal/gatsby-node.js index a77f94d28..8f822c39b 100644 --- a/packages/gatsby-theme-project-portal/gatsby-node.js +++ b/packages/gatsby-theme-project-portal/gatsby-node.js @@ -1,6 +1,5 @@ const { withDefaults } = require(`./utils/default-options`) const fs = require("fs") -const path = require("path") const { projectTypeDefs, From a2864376dae2d9c612fb253f1722ec119cfd6a37 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Tue, 10 Oct 2023 13:33:01 -0400 Subject: [PATCH 12/17] chore: remove extra contact-page js file --- .../gatsby-node.js | 4 ++- .../src/layouts/ContactPageLayout.tsx | 27 ++++++++++++++++++- .../src/templates/contact-page.js | 26 ------------------ 3 files changed, 29 insertions(+), 28 deletions(-) delete mode 100644 packages/gatsby-theme-project-portal/src/templates/contact-page.js diff --git a/packages/gatsby-theme-project-portal/gatsby-node.js b/packages/gatsby-theme-project-portal/gatsby-node.js index 8f822c39b..edc244691 100644 --- a/packages/gatsby-theme-project-portal/gatsby-node.js +++ b/packages/gatsby-theme-project-portal/gatsby-node.js @@ -9,7 +9,9 @@ const { } = require(`./utils/types`) const CardPageTemplate = require.resolve(`./src/layouts/CardPageLayout.tsx`) const AboutPageTemplate = require.resolve(`./src/layouts/AboutPageLayout.tsx`) -const ContactPageTemplate = require.resolve(`./src/templates/contact-page`) +const ContactPageTemplate = require.resolve( + `./src/layouts/ContactPageLayout.tsx` +) const ThankYouPageTemplate = require.resolve( "./src/layouts/ThankYouPageLayout.tsx" ) diff --git a/packages/gatsby-theme-project-portal/src/layouts/ContactPageLayout.tsx b/packages/gatsby-theme-project-portal/src/layouts/ContactPageLayout.tsx index 87e7275e0..fc9a58664 100644 --- a/packages/gatsby-theme-project-portal/src/layouts/ContactPageLayout.tsx +++ b/packages/gatsby-theme-project-portal/src/layouts/ContactPageLayout.tsx @@ -1,10 +1,12 @@ import React, { Component, FunctionComponent } from "react" -import { navigate } from "gatsby" +import { graphql, navigate } from "gatsby" import { MarkdownText } from "../components" import { HeaderWithImage } from "../components" import ReCAPTCHA from "react-google-recaptcha" import { ImageDataLike } from "gatsby-plugin-image" +export { Head } from "../hooks" + const encode = (data: { [Key: string]: string }) => { return Object.keys(data) .map((key) => encodeURIComponent(key) + "=" + encodeURIComponent(data[key])) @@ -326,3 +328,26 @@ export const ContactPageLayout: FunctionComponent = ({ ) } + +export default ContactPageLayout + +export const query = graphql` + query ContactQuery($slug: String!) { + ...HeadData + ...LayoutData + page: generalPage(slug: { eq: $slug }) { + title + description: lede + } + generalPage(slug: { eq: $slug }) { + title + lede + image { + ...HeaderWithImageBackground + } + } + projectPortalConfig { + recaptchaSiteKey + } + } +` diff --git a/packages/gatsby-theme-project-portal/src/templates/contact-page.js b/packages/gatsby-theme-project-portal/src/templates/contact-page.js deleted file mode 100644 index 2115dde53..000000000 --- a/packages/gatsby-theme-project-portal/src/templates/contact-page.js +++ /dev/null @@ -1,26 +0,0 @@ -import { graphql } from "gatsby" -import { ContactPageLayout } from "../layouts" - -export default ContactPageLayout -export { Head } from "../hooks" - -export const query = graphql` - query ContactQuery($slug: String!) { - ...HeadData - ...LayoutData - page: generalPage(slug: { eq: $slug }) { - title - description: lede - } - generalPage(slug: { eq: $slug }) { - title - lede - image { - ...HeaderWithImageBackground - } - } - projectPortalConfig { - recaptchaSiteKey - } - } -` From 11a426377ff9d825df623a8c77f16c70d91772a3 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Tue, 10 Oct 2023 13:36:08 -0400 Subject: [PATCH 13/17] chore: remove extra project detail page js file --- .../gatsby-node.js | 7 +- .../src/layouts/ProjectDetailPage.tsx | 100 +++++++++++++++++- .../src/templates/project-detail-page.js | 99 ----------------- 3 files changed, 102 insertions(+), 104 deletions(-) delete mode 100644 packages/gatsby-theme-project-portal/src/templates/project-detail-page.js diff --git a/packages/gatsby-theme-project-portal/gatsby-node.js b/packages/gatsby-theme-project-portal/gatsby-node.js index edc244691..8119c73e0 100644 --- a/packages/gatsby-theme-project-portal/gatsby-node.js +++ b/packages/gatsby-theme-project-portal/gatsby-node.js @@ -15,6 +15,9 @@ const ContactPageTemplate = require.resolve( const ThankYouPageTemplate = require.resolve( "./src/layouts/ThankYouPageLayout.tsx" ) +const ProjectDetailPageTemplate = require.resolve( + `./src/layouts/ProjectDetailPage.tsx` +) exports.onPreBootstrap = ({ reporter }, themeOptions) => { const { themeImageDirectory } = withDefaults(themeOptions) @@ -55,10 +58,6 @@ exports.sourceNodes = ({ actions, createContentDigest }, themeOptions) => { }) } -const ProjectDetailPageTemplate = require.resolve( - `./src/templates/project-detail-page` -) - exports.createPages = async ({ graphql, actions, reporter }) => { const { createPage } = actions diff --git a/packages/gatsby-theme-project-portal/src/layouts/ProjectDetailPage.tsx b/packages/gatsby-theme-project-portal/src/layouts/ProjectDetailPage.tsx index ea18591bd..3ada69808 100644 --- a/packages/gatsby-theme-project-portal/src/layouts/ProjectDetailPage.tsx +++ b/packages/gatsby-theme-project-portal/src/layouts/ProjectDetailPage.tsx @@ -1,8 +1,10 @@ import { BackIcon, ProjectDetail, ProjectDetailProps } from "../components" import React, { FunctionComponent } from "react" -import { Link, withPrefix } from "gatsby" +import { graphql, Link, withPrefix } from "gatsby" import { ImageDataLike } from "gatsby-plugin-image" +export { Head } from "../hooks" + // For the ProjectDetailPage we add the slug which isn't on the layout interface ProjectDetailPageProps extends ProjectDetailProps { slug: string @@ -70,3 +72,99 @@ export const ProjectDetailPage: FunctionComponent< ) } + +export default ProjectDetailPage + +export const query = graphql` + query ProjectDetailPageQuery($slug: String!) { + ...HeadData + ...LayoutData + page: project(slug: { eq: $slug }) { + title: question + description: summary + } + defaultContactImage: file( + name: { eq: "default-contact" } + extension: { in: ["png", "jpg", "jpeg"] } + # only match files in the "themeImages" sourced directory: + sourceInstanceName: { eq: "themeImages" } + ) { + childImageSharp { + gatsbyImageData( + width: 100 + height: 100 + placeholder: BLURRED + layout: FIXED + ) + } + } + projectPortalConfig { + projectInterestLink + staticText { + mainContactText: main_contact_text { + ongoingText + completeText + } + } + } + project(slug: { eq: $slug }) { + question + title + summary + status + opportunityCloses + startDate + endDate + lastModified + agency + topics { + ...TopicDetails + } + deliverable + purpose + expertise + requirement + keyDates + priorResearch + statusOfData + fundingInfo + openText: emailContent + mainContact { + name + title + employer + email + image { + childImageSharp { + gatsbyImageData( + width: 100 + height: 100 + placeholder: BLURRED + layout: FIXED + ) + } + } + } + projectTeam { + name + title + employer + email + image { + childImageSharp { + gatsbyImageData( + width: 100 + height: 100 + placeholder: BLURRED + layout: FIXED + ) + } + } + } + faq { + text + title + } + } + } +` diff --git a/packages/gatsby-theme-project-portal/src/templates/project-detail-page.js b/packages/gatsby-theme-project-portal/src/templates/project-detail-page.js deleted file mode 100644 index 43e1ece76..000000000 --- a/packages/gatsby-theme-project-portal/src/templates/project-detail-page.js +++ /dev/null @@ -1,99 +0,0 @@ -import { graphql } from "gatsby" -import { ProjectDetailPage } from "../layouts" - -export default ProjectDetailPage -export { Head } from "../hooks" - -export const query = graphql` - query ProjectDetailPageQuery($slug: String!) { - ...HeadData - ...LayoutData - page: project(slug: { eq: $slug }) { - title: question - description: summary - } - defaultContactImage: file( - name: { eq: "default-contact" } - extension: { in: ["png", "jpg", "jpeg"] } - # only match files in the "themeImages" sourced directory: - sourceInstanceName: { eq: "themeImages" } - ) { - childImageSharp { - gatsbyImageData( - width: 100 - height: 100 - placeholder: BLURRED - layout: FIXED - ) - } - } - projectPortalConfig { - projectInterestLink - staticText { - mainContactText: main_contact_text { - ongoingText - completeText - } - } - } - project(slug: { eq: $slug }) { - question - title - summary - status - opportunityCloses - startDate - endDate - lastModified - agency - topics { - ...TopicDetails - } - deliverable - purpose - expertise - requirement - keyDates - priorResearch - statusOfData - fundingInfo - openText: emailContent - mainContact { - name - title - employer - email - image { - childImageSharp { - gatsbyImageData( - width: 100 - height: 100 - placeholder: BLURRED - layout: FIXED - ) - } - } - } - projectTeam { - name - title - employer - email - image { - childImageSharp { - gatsbyImageData( - width: 100 - height: 100 - placeholder: BLURRED - layout: FIXED - ) - } - } - } - faq { - text - title - } - } - } -` From abc0125a686fcf136cdcc3f15db0d7cbeb4aa5af Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Tue, 10 Oct 2023 13:36:34 -0400 Subject: [PATCH 14/17] chore: remove unused dev-banner.js file --- .../gatsby-theme-project-portal/src/templates/dev-banner.js | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 packages/gatsby-theme-project-portal/src/templates/dev-banner.js diff --git a/packages/gatsby-theme-project-portal/src/templates/dev-banner.js b/packages/gatsby-theme-project-portal/src/templates/dev-banner.js deleted file mode 100644 index b40b25e7f..000000000 --- a/packages/gatsby-theme-project-portal/src/templates/dev-banner.js +++ /dev/null @@ -1,4 +0,0 @@ -// import { graphql } from "gatsby" -import { DevelopmentBanner } from "../components" - -export default DevelopmentBanner From aa2030413abaf0a637832d648f01e917856a9768 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Tue, 10 Oct 2023 13:40:31 -0400 Subject: [PATCH 15/17] chore: remove single use variables --- .../gatsby-node.js | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/packages/gatsby-theme-project-portal/gatsby-node.js b/packages/gatsby-theme-project-portal/gatsby-node.js index 8119c73e0..a1319fdbf 100644 --- a/packages/gatsby-theme-project-portal/gatsby-node.js +++ b/packages/gatsby-theme-project-portal/gatsby-node.js @@ -7,17 +7,6 @@ const { contactTypeDefs, pageTypeDefs, } = require(`./utils/types`) -const CardPageTemplate = require.resolve(`./src/layouts/CardPageLayout.tsx`) -const AboutPageTemplate = require.resolve(`./src/layouts/AboutPageLayout.tsx`) -const ContactPageTemplate = require.resolve( - `./src/layouts/ContactPageLayout.tsx` -) -const ThankYouPageTemplate = require.resolve( - "./src/layouts/ThankYouPageLayout.tsx" -) -const ProjectDetailPageTemplate = require.resolve( - `./src/layouts/ProjectDetailPage.tsx` -) exports.onPreBootstrap = ({ reporter }, themeOptions) => { const { themeImageDirectory } = withDefaults(themeOptions) @@ -104,7 +93,7 @@ exports.createPages = async ({ graphql, actions, reporter }) => { const { slug } = project createPage({ path: `project/${slug}`, - component: ProjectDetailPageTemplate, + component: require.resolve(`./src/layouts/ProjectDetailPage.tsx`), context: { slug: slug, }, @@ -119,7 +108,7 @@ exports.createPages = async ({ graphql, actions, reporter }) => { } = page createPage({ path: `/${slug}`, - component: CardPageTemplate, + component: require.resolve(`./src/layouts/CardPageLayout.tsx`), context: { slug: slug, statusFilter: status, @@ -132,7 +121,7 @@ exports.createPages = async ({ graphql, actions, reporter }) => { const { slug } = page createPage({ path: `/${slug}`, - component: AboutPageTemplate, + component: require.resolve(`./src/layouts/AboutPageLayout.tsx`), context: { slug: slug, }, @@ -144,7 +133,7 @@ exports.createPages = async ({ graphql, actions, reporter }) => { const thankYouPagePath = `/${slug}/thank-you` createPage({ path: `/${slug}`, - component: ContactPageTemplate, + component: require.resolve(`./src/layouts/ContactPageLayout.tsx`), context: { slug: slug, thankYouPagePath: thankYouPagePath, @@ -152,7 +141,7 @@ exports.createPages = async ({ graphql, actions, reporter }) => { }) createPage({ path: thankYouPagePath, - component: ThankYouPageTemplate, + component: require.resolve("./src/layouts/ThankYouPageLayout.tsx"), context: { slug: slug, }, From 617a55c6b09fed50a0f507aeb3623db18af03a48 Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Tue, 10 Oct 2023 13:48:35 -0400 Subject: [PATCH 16/17] chore: reorder imports, making ordering more consistent --- .../src/layouts/AboutPageLayout.tsx | 8 ++------ .../src/layouts/CardPageLayout.tsx | 4 ++-- .../src/layouts/ContactPageLayout.tsx | 5 ++--- .../src/layouts/ProjectDetailPage.tsx | 2 +- .../src/layouts/ThankYouPageLayout.tsx | 2 +- 5 files changed, 8 insertions(+), 13 deletions(-) diff --git a/packages/gatsby-theme-project-portal/src/layouts/AboutPageLayout.tsx b/packages/gatsby-theme-project-portal/src/layouts/AboutPageLayout.tsx index 3e27ca846..362023535 100644 --- a/packages/gatsby-theme-project-portal/src/layouts/AboutPageLayout.tsx +++ b/packages/gatsby-theme-project-portal/src/layouts/AboutPageLayout.tsx @@ -1,12 +1,8 @@ import React, { FunctionComponent } from "react" import { graphql } from "gatsby" -import { Accordion } from "../components/Accordion" -import { - HeaderWithImage, - MarkdownText, -} from "@thepolicylab-projectportals/gatsby-theme-project-portal/src/components" -import { isNA } from "../utils" import { ImageDataLike } from "gatsby-plugin-image" +import { HeaderWithImage, MarkdownText, Accordion } from "../components" +import { isNA } from "../utils" export { Head } from "../hooks" diff --git a/packages/gatsby-theme-project-portal/src/layouts/CardPageLayout.tsx b/packages/gatsby-theme-project-portal/src/layouts/CardPageLayout.tsx index 2e732a15b..ffa588fc1 100644 --- a/packages/gatsby-theme-project-portal/src/layouts/CardPageLayout.tsx +++ b/packages/gatsby-theme-project-portal/src/layouts/CardPageLayout.tsx @@ -1,7 +1,7 @@ -import { ProjectPage, CardProps } from "../components" import React, { FunctionComponent } from "react" -import { ImageDataLike } from "gatsby-plugin-image" import { graphql } from "gatsby" +import { ImageDataLike } from "gatsby-plugin-image" +import { ProjectPage, CardProps } from "../components" export { Head } from "../hooks" diff --git a/packages/gatsby-theme-project-portal/src/layouts/ContactPageLayout.tsx b/packages/gatsby-theme-project-portal/src/layouts/ContactPageLayout.tsx index fc9a58664..89d07af5c 100644 --- a/packages/gatsby-theme-project-portal/src/layouts/ContactPageLayout.tsx +++ b/packages/gatsby-theme-project-portal/src/layouts/ContactPageLayout.tsx @@ -1,9 +1,8 @@ import React, { Component, FunctionComponent } from "react" import { graphql, navigate } from "gatsby" -import { MarkdownText } from "../components" -import { HeaderWithImage } from "../components" -import ReCAPTCHA from "react-google-recaptcha" import { ImageDataLike } from "gatsby-plugin-image" +import ReCAPTCHA from "react-google-recaptcha" +import { MarkdownText, HeaderWithImage } from "../components" export { Head } from "../hooks" diff --git a/packages/gatsby-theme-project-portal/src/layouts/ProjectDetailPage.tsx b/packages/gatsby-theme-project-portal/src/layouts/ProjectDetailPage.tsx index 3ada69808..41b12f977 100644 --- a/packages/gatsby-theme-project-portal/src/layouts/ProjectDetailPage.tsx +++ b/packages/gatsby-theme-project-portal/src/layouts/ProjectDetailPage.tsx @@ -1,7 +1,7 @@ -import { BackIcon, ProjectDetail, ProjectDetailProps } from "../components" import React, { FunctionComponent } from "react" import { graphql, Link, withPrefix } from "gatsby" import { ImageDataLike } from "gatsby-plugin-image" +import { BackIcon, ProjectDetail, ProjectDetailProps } from "../components" export { Head } from "../hooks" diff --git a/packages/gatsby-theme-project-portal/src/layouts/ThankYouPageLayout.tsx b/packages/gatsby-theme-project-portal/src/layouts/ThankYouPageLayout.tsx index 038b8d406..036af539d 100644 --- a/packages/gatsby-theme-project-portal/src/layouts/ThankYouPageLayout.tsx +++ b/packages/gatsby-theme-project-portal/src/layouts/ThankYouPageLayout.tsx @@ -1,7 +1,7 @@ import React, { FunctionComponent } from "react" import { graphql, Link } from "gatsby" -import { HeaderWithImage } from "../components" import { ImageDataLike } from "gatsby-plugin-image" +import { HeaderWithImage } from "../components" export { Head } from "../hooks" From 4aa288bf1f275d72c3088d737f13620b6b3d0f2b Mon Sep 17 00:00:00 2001 From: John Gerrard Holland Date: Tue, 10 Oct 2023 17:11:12 -0400 Subject: [PATCH 17/17] chore: rename mainContact variab le din query --- .../src/layouts/ProjectDetailPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/gatsby-theme-project-portal/src/layouts/ProjectDetailPage.tsx b/packages/gatsby-theme-project-portal/src/layouts/ProjectDetailPage.tsx index ab10ced9d..cfd5f2ffd 100644 --- a/packages/gatsby-theme-project-portal/src/layouts/ProjectDetailPage.tsx +++ b/packages/gatsby-theme-project-portal/src/layouts/ProjectDetailPage.tsx @@ -101,7 +101,7 @@ export const query = graphql` projectPortalConfig { projectInterestLink staticText { - mainContactText { + mainContact { ongoingText completeText }