diff --git a/gatsby-node.js b/gatsby-node.js index 12224ef1..91b45648 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -86,6 +86,22 @@ exports.createPages = async ({ graphql, actions }) => { } } `); + // Need to generate pages for each individual person as well to route to + const people = await graphql(` + { + allMarkdownRemark( + filter: { fileAbsolutePath: { regex: "/pages/people/bios/.*.md/" } } + ) { + edges { + node { + frontmatter { + uid + } + } + } + } + } + `); /* List creators */ const creators = [ @@ -101,6 +117,11 @@ exports.createPages = async ({ graphql, actions }) => { src: works, component: path.resolve("lib/ui/templates/ProjectItemTpl.tsx"), prefix: "projects" + }, + { + src: people, + component: path.resolve("lib/ui/templates/PeopleTpl.tsx"), + prefix: "people" } ]; diff --git a/lib/gatsby-types.d.ts b/lib/gatsby-types.d.ts index b78a4774..bbf7e21b 100644 --- a/lib/gatsby-types.d.ts +++ b/lib/gatsby-types.d.ts @@ -3177,7 +3177,7 @@ type PeopleTplQueryVariables = Exact<{ }>; -type PeopleTplQuery = { readonly markdownRemark: { readonly html: string | null, readonly frontmatter: { readonly uid: string | null, readonly title: string | null, readonly heading: string | null, readonly subheading: string | null, readonly accomplicesHeading: string | null, readonly accomplicesDescr: string | null, readonly membersHeading: string | null, readonly membersDescr: string | null, readonly overlordsHeading: string | null, readonly overlordsDescr: string | null } | null } | null, readonly defaultAvatar: { readonly edges: ReadonlyArray<{ readonly node: { readonly childImageSharp: { readonly gatsbyImageData: import('gatsby-plugin-image').IGatsbyImageData } | null } }> }, readonly overlords: { readonly edges: ReadonlyArray<{ readonly node: { readonly id: string, readonly html: string | null, readonly frontmatter: { readonly bluesky: string | null, readonly fname: string | null, readonly github: string | null, readonly lname: string | null, readonly mastodon: string | null, readonly quote: string | null, readonly score: number | null, readonly twitter: string | null, readonly website: string | null, readonly uid: string | null, readonly avatar: { readonly childImageSharp: { readonly gatsbyImageData: import('gatsby-plugin-image').IGatsbyImageData } | null } | null } | null } }> }, readonly members: { readonly edges: ReadonlyArray<{ readonly node: { readonly id: string, readonly html: string | null, readonly frontmatter: { readonly bluesky: string | null, readonly fname: string | null, readonly github: string | null, readonly lname: string | null, readonly mastodon: string | null, readonly quote: string | null, readonly score: number | null, readonly twitter: string | null, readonly website: string | null, readonly uid: string | null, readonly avatar: { readonly childImageSharp: { readonly gatsbyImageData: import('gatsby-plugin-image').IGatsbyImageData } | null } | null } | null } }> }, readonly accomplices: { readonly edges: ReadonlyArray<{ readonly node: { readonly id: string, readonly html: string | null, readonly frontmatter: { readonly bluesky: string | null, readonly fname: string | null, readonly github: string | null, readonly lname: string | null, readonly mastodon: string | null, readonly quote: string | null, readonly score: number | null, readonly twitter: string | null, readonly website: string | null, readonly uid: string | null, readonly avatar: { readonly childImageSharp: { readonly gatsbyImageData: import('gatsby-plugin-image').IGatsbyImageData } | null } | null } | null } }> } }; +type PeopleTplQuery = { readonly markdownRemark: { readonly html: string | null, readonly frontmatter: { readonly uid: string | null, readonly title: string | null, readonly heading: string | null, readonly subheading: string | null, readonly accomplicesHeading: string | null, readonly accomplicesDescr: string | null, readonly membersHeading: string | null, readonly membersDescr: string | null, readonly overlordsHeading: string | null, readonly overlordsDescr: string | null } | null } | null, readonly defaultAvatar: { readonly edges: ReadonlyArray<{ readonly node: { readonly childImageSharp: { readonly gatsbyImageData: import('gatsby-plugin-image').IGatsbyImageData } | null } }> }, readonly overlords: { readonly edges: ReadonlyArray<{ readonly node: { readonly id: string, readonly html: string | null, readonly frontmatter: { readonly bluesky: string | null, readonly fname: string | null, readonly github: string | null, readonly lname: string | null, readonly mastodon: string | null, readonly quote: string | null, readonly score: number | null, readonly twitter: string | null, readonly website: string | null, readonly uid: string | null, readonly avatar: { readonly childImageSharp: { readonly gatsbyImageData: import('gatsby-plugin-image').IGatsbyImageData } | null } | null } | null } }> }, readonly members: { readonly edges: ReadonlyArray<{ readonly node: { readonly id: string, readonly html: string | null, readonly frontmatter: { readonly bluesky: string | null, readonly fname: string | null, readonly github: string | null, readonly lname: string | null, readonly mastodon: string | null, readonly quote: string | null, readonly score: number | null, readonly twitter: string | null, readonly website: string | null, readonly uid: string | null, readonly avatar: { readonly childImageSharp: { readonly gatsbyImageData: import('gatsby-plugin-image').IGatsbyImageData } | null } | null } | null } }> }, readonly accomplices: { readonly edges: ReadonlyArray<{ readonly node: { readonly id: string, readonly html: string | null, readonly frontmatter: { readonly bluesky: string | null, readonly fname: string | null, readonly github: string | null, readonly lname: string | null, readonly mastodon: string | null, readonly quote: string | null, readonly score: number | null, readonly twitter: string | null, readonly website: string | null, readonly uid: string | null, readonly avatar: { readonly childImageSharp: { readonly gatsbyImageData: import('gatsby-plugin-image').IGatsbyImageData } | null } | null } | null } }> }, readonly all: { readonly edges: ReadonlyArray<{ readonly node: { readonly id: string, readonly html: string | null, readonly frontmatter: { readonly bluesky: string | null, readonly fname: string | null, readonly github: string | null, readonly lname: string | null, readonly mastodon: string | null, readonly quote: string | null, readonly score: number | null, readonly twitter: string | null, readonly website: string | null, readonly uid: string | null, readonly avatar: { readonly childImageSharp: { readonly gatsbyImageData: import('gatsby-plugin-image').IGatsbyImageData } | null } | null } | null } }> } }; type PortfolioItemsByUIDQueryVariables = Exact<{ uid: Scalars['String']; diff --git a/lib/ui/templates/PeopleTpl.tsx b/lib/ui/templates/PeopleTpl.tsx index b967c463..455d4bc9 100644 --- a/lib/ui/templates/PeopleTpl.tsx +++ b/lib/ui/templates/PeopleTpl.tsx @@ -1,5 +1,5 @@ import React, { useState } from "react"; -import { graphql, type PageProps } from "gatsby"; +import { graphql, navigate, type PageProps } from "gatsby"; import styled from "styled-components"; import { Body, Header, Helmet, Layout } from "ui/partials"; @@ -48,19 +48,30 @@ const PeopleIntro = styled.div` `; const PeopleTpl = (props: PageProps) => { - const [currentPerson, setCurrentPerson] = useState(null); + const { defaultAvatar, overlords, members, accomplices, all } = props.data; + const { frontmatter } = props.data.markdownRemark ?? {}; + const genericAvatar = defaultAvatar.edges[0].node.childImageSharp; - function handleShowPerson(obj: PersonNode) { - if (currentPerson === null) { - setCurrentPerson(obj); - } else { - setCurrentPerson(null); - } + // For routing to a specific person + let personObj + if (typeof window !== "undefined") { + const personId = window.location.pathname + .replace("/people/", "") + .replace("/", ""); + personObj = all.edges.find( + ({ node }: { node: PersonNode }) => node.frontmatter?.uid === personId + )?.node; } - const { defaultAvatar, overlords, members, accomplices } = props.data; - const { frontmatter } = props.data.markdownRemark ?? {}; - const genericAvatar = defaultAvatar.edges[0].node.childImageSharp; + const [currentPerson, setCurrentPerson] = useState( + personObj ?? null + ); + + // from the component when it closes force a navigation back to + // parent page + function closeModal() { + navigate("/people"); + } return ( <> @@ -82,7 +93,6 @@ const PeopleTpl = (props: PageProps) => { data={node} defaultAvatar={genericAvatar} key={node.frontmatter?.uid} - toggleModal={() => handleShowPerson(node)} /> ))} @@ -98,7 +108,6 @@ const PeopleTpl = (props: PageProps) => { data={node} defaultAvatar={genericAvatar} key={node.frontmatter?.uid} - toggleModal={() => handleShowPerson(node)} /> ))} @@ -114,7 +123,6 @@ const PeopleTpl = (props: PageProps) => { data={node} defaultAvatar={genericAvatar} key={node.frontmatter?.uid} - toggleModal={() => handleShowPerson(node)} /> ))} @@ -122,7 +130,7 @@ const PeopleTpl = (props: PageProps) => { {currentPerson !== null ? ( @@ -279,5 +287,39 @@ export const pageQuery = graphql` } } } + all: allMarkdownRemark( + filter: { fileAbsolutePath: { regex: "//pages/people/bios/*/.*/*.md/" } } + sort: { frontmatter: { fname: ASC } } + ) { + edges { + node { + id + html + frontmatter { + bluesky + fname + github + lname + mastodon + quote + score + twitter + website + uid + avatar { + childImageSharp { + gatsbyImageData( + width: 240 + height: 300 + placeholder: DOMINANT_COLOR + transformOptions: { cropFocus: CENTER } + layout: CONSTRAINED + ) + } + } + } + } + } + } } `; diff --git a/lib/ui/templates/ofPeople/Person.tsx b/lib/ui/templates/ofPeople/Person.tsx index e2fc514c..5a443e55 100644 --- a/lib/ui/templates/ofPeople/Person.tsx +++ b/lib/ui/templates/ofPeople/Person.tsx @@ -1,4 +1,5 @@ import React from "react"; +import { Link } from "gatsby"; import { GatsbyImage } from "gatsby-plugin-image"; import styled from "styled-components"; @@ -73,85 +74,95 @@ const PersonLinks = styled.div` interface MemberProps { data: PersonNode; defaultAvatar: any; - toggleModal: VoidFunction; } function Member(props: MemberProps) { const { defaultAvatar } = props; const { frontmatter } = props.data; - const { avatar, bluesky, fname, github, lname, mastodon, twitter, website } = - frontmatter ?? {}; + const { + uid, + avatar, + bluesky, + fname, + github, + lname, + mastodon, + twitter, + website, + } = frontmatter ?? {}; return ( - - - - - - - {fname} {lname} - - - {website ? ( - e.stopPropagation()} - href={`https://${website}/`} - rel="external noopener noreferrer" - target="_blank" - > - - - ) : null} - {bluesky ? ( - e.stopPropagation()} - href={`https://bsky.app/profile/${bluesky}`} - rel="external noopener noreferrer" - target="_blank" - > - - - ) : null} - {mastodon ? ( - e.stopPropagation()} - href={`https://${mastodon}`} - rel="external noopener noreferrer" - target="_blank" - > - - - ) : null} - {twitter ? ( - e.stopPropagation()} - href={`https://twitter.com/${twitter}`} - rel="external noopener noreferrer" - target="_blank" - > - - - ) : null} - {github ? ( - e.stopPropagation()} - href={`https://github.com/${github}`} - rel="external noopener noreferrer" - target="_blank" - > - - - ) : null} - - - + + + + + + + + {fname} {lname} + + + {website ? ( + e.stopPropagation()} + href={`https://${website}/`} + rel="external noopener noreferrer" + target="_blank" + > + + + ) : null} + {bluesky ? ( + e.stopPropagation()} + href={`https://bsky.app/profile/${bluesky}`} + rel="external noopener noreferrer" + target="_blank" + > + + + ) : null} + {mastodon ? ( + e.stopPropagation()} + href={`https://${mastodon}`} + rel="external noopener noreferrer" + target="_blank" + > + + + ) : null} + {twitter ? ( + e.stopPropagation()} + href={`https://twitter.com/${twitter}`} + rel="external noopener noreferrer" + target="_blank" + > + + + ) : null} + {github ? ( + e.stopPropagation()} + href={`https://github.com/${github}`} + rel="external noopener noreferrer" + target="_blank" + > + + + ) : null} + + + + ); }