From 8f1f1dec7de0456eaa5e7eeb1342dc3912355160 Mon Sep 17 00:00:00 2001 From: Jake Laderman Date: Tue, 26 Nov 2024 21:35:51 -0600 Subject: [PATCH] add resource pages cms --- pages/resources/[resource].tsx | 75 +++ src/components/AppsList.tsx | 112 ---- src/contexts/ReposContext.tsx | 8 - src/data/getSiteSettings.tsx | 49 +- src/generated/graphqlDirectus.ts | 624 +++++++++++++++++- src/graph/directus/globalData.graphql | 18 + src/graph/directus/pageData/resources.graphql | 31 + src/utils/getGlobalProps.tsx | 52 +- 8 files changed, 755 insertions(+), 214 deletions(-) create mode 100644 pages/resources/[resource].tsx delete mode 100644 src/components/AppsList.tsx delete mode 100644 src/contexts/ReposContext.tsx create mode 100644 src/graph/directus/globalData.graphql create mode 100644 src/graph/directus/pageData/resources.graphql diff --git a/pages/resources/[resource].tsx b/pages/resources/[resource].tsx new file mode 100644 index 00000000..aaf03fa8 --- /dev/null +++ b/pages/resources/[resource].tsx @@ -0,0 +1,75 @@ +import { type GetStaticPaths, type InferGetStaticPropsType } from 'next' + +import { directusClient } from '@src/apollo-client' +import { CustomComponents } from '@src/components/custom-page/common' +import { FooterVariant } from '@src/components/FooterFull' +import { + ResourcePageDocument, + type ResourcePageQuery, + type ResourcePageQueryVariables, + ResourcesPageSlugsDocument, + type ResourcesPageSlugsQuery, + type ResourcesPageSlugsQueryVariables, +} from '@src/generated/graphqlDirectus' +import { propsWithGlobalSettings } from '@src/utils/getGlobalProps' + +export default function Resource({ + resourceInfo, +}: InferGetStaticPropsType) { + return +} + +export const getStaticPaths: GetStaticPaths = async () => { + const { data, error } = await directusClient.query< + ResourcesPageSlugsQuery, + ResourcesPageSlugsQueryVariables + >({ + query: ResourcesPageSlugsDocument, + }) + + if (error) { + console.error('GraphQL query error in static:', error) + } + + return { + paths: data.resource_pages.map((page) => ({ + params: { resource: page.slug }, + })), + fallback: 'blocking', + } +} + +export const getStaticProps = async (context) => { + const slug = + typeof context?.params?.resource === 'string' + ? context?.params?.resource + : null + + if (!slug) { + return { notFound: true } + } + + const { data, error } = await directusClient.query< + ResourcePageQuery, + ResourcePageQueryVariables + >({ + query: ResourcePageDocument, + variables: { slug }, + }) + + if (error) { + console.error('GraphQL query error in static: ', error) + } + const resourceInfo = data.resource_pages?.[0] || null + + if (!resourceInfo) { + return { notFound: true } + } + + return propsWithGlobalSettings({ + metaTitle: resourceInfo?.dropdown_title ?? '', + metaDescription: '', + footerVariant: FooterVariant.kitchenSink, + resourceInfo, + }) +} diff --git a/src/components/AppsList.tsx b/src/components/AppsList.tsx deleted file mode 100644 index 64307bec..00000000 --- a/src/components/AppsList.tsx +++ /dev/null @@ -1,112 +0,0 @@ -import { useMemo, useState } from 'react' - -import { - Input, - MagnifyingGlassIcon, - RepositoryChip, -} from '@pluralsh/design-system' -import Link from 'next/link' - -import chroma from 'chroma-js' -import Fuse from 'fuse.js' -import styled from 'styled-components' - -import { appUrl } from '@src/consts/routes' - -import { useRepos } from '../contexts/ReposContext' - -function AppsList({ className, ...props }: { className?: string }) { - const applications = useRepos() - const [search, setSearch] = useState('') - - const fuse = useMemo( - () => - new Fuse(applications, { - threshold: 0.3, - keys: ['name', 'displayName', 'tags.tag'], - }), - [applications] - ) - - const filteredApplications = search - ? fuse.search(search).map((x) => x.item) - : applications - - if (!applications || applications.length <= 0) { - return null - } - - return ( - - ) -} - -export default styled(AppsList)(({ theme }) => ({ - 'ul, li': { - margin: 0, - padding: 0, - listStyle: 'none', - }, - '.appList': { - flexGrow: 1, - display: 'grid', - gridTemplateColumns: 'repeat(auto-fit, minmax(200px, 1fr))', - gridTemplateRows: 'repeat(auto-fill, 42px)', - gridColumnGap: theme.spacing.medium, - gridRowGap: '16px', - paddingRight: 'xsmall', - paddingBottom: 'medium', - minHeight: 'calc(100vh - var(--top-nav-height) - 420px)', - }, - '.inputWrap': { - position: 'sticky', - top: 'var(--top-nav-height)', - marginBottom: theme.spacing.large, - backgroundColor: theme.colors['fill-zero'], - - '&::after': { - content: '""', - display: 'block', - position: 'absolute', - top: '100%', - left: 0, - width: '100%', - height: theme.spacing.large, - background: `linear-gradient(0deg, ${chroma( - theme.colors['fill-zero'] - ).alpha(0.0)} 0%, ${chroma(theme.colors['fill-zero']).alpha(1.0)} 100%)`, - }, - }, - '.searchInput': {}, -})) diff --git a/src/contexts/ReposContext.tsx b/src/contexts/ReposContext.tsx deleted file mode 100644 index d200e276..00000000 --- a/src/contexts/ReposContext.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import { createContext, useContext } from 'react' - -import type { BasicRepo } from '../data/getRepos' - -export type ReposContextT = any -export const ReposContext = createContext([]) -export const useRepos = () => useContext(ReposContext) -export const ReposProvider = ReposContext.Provider diff --git a/src/data/getSiteSettings.tsx b/src/data/getSiteSettings.tsx index c6b81d2d..2575f560 100644 --- a/src/data/getSiteSettings.tsx +++ b/src/data/getSiteSettings.tsx @@ -2,6 +2,7 @@ import { getImageUrl } from '@src/consts/routes' import { type NavList } from '@src/contexts/NavDataContext' import { type ProductPageTinyFragment, + type ResourcePageTinyFragment, type SiteSettingsFragment, type SolutionPageTinyFragment, } from '@src/generated/graphqlDirectus' @@ -9,7 +10,8 @@ import { export const getSiteSettings = ( siteSettings: SiteSettingsFragment, solutions?: SolutionPageTinyFragment[], - products?: ProductPageTinyFragment[] + products?: ProductPageTinyFragment[], + resources?: ResourcePageTinyFragment[] ) => ({ og_description: siteSettings.og_description ?? 'Plural', og_image: getImageUrl(siteSettings.og_image), @@ -43,36 +45,7 @@ export const getSiteSettings = ( title: 'Resources', url: '/resources', }, - subnav: [ - { - id: 'docs', - link: { - title: 'Docs', - url: 'https://docs.plural.sh', - }, - }, - { - id: 'blog', - link: { - title: 'Blog', - url: 'https://www.plural.sh/blog', - }, - }, - { - id: 'releases', - link: { - title: 'Releases', - url: 'https://github.com/pluralsh/plural/releases', - }, - }, - { - id: 'security and compliance', - link: { - title: 'Security & Compliance', - url: 'https://app.secureframe.com/ext/trust-center/plural/', - }, - }, - ], + subnav: getResourcesSubnav(resources), }, company: { id: 'company', @@ -143,3 +116,17 @@ function getProductSubnav(products?: ProductPageTinyFragment[]): NavList[] { // })) // .reverse() // } + +function getResourcesSubnav(resources?: ResourcePageTinyFragment[]) { + if (!resources || !resources.length) return [] + + return resources.map((resource) => ({ + id: resource.slug, + link: { + title: resource.dropdown_title ?? '', + url: resource.external + ? resource.url ?? '#' + : `/resources/${resource.slug}`, + }, + })) +} diff --git a/src/generated/graphqlDirectus.ts b/src/generated/graphqlDirectus.ts index 40959afb..e21cee6e 100644 --- a/src/generated/graphqlDirectus.ts +++ b/src/generated/graphqlDirectus.ts @@ -106,6 +106,10 @@ export type Mutation = { create_quote_lists_items_items: Array; create_quotes_item?: Maybe; create_quotes_items: Array; + create_resource_pages_custom_component_item?: Maybe; + create_resource_pages_custom_component_items: Array; + create_resource_pages_item?: Maybe; + create_resource_pages_items: Array; create_rich_text_columns_item?: Maybe; create_rich_text_columns_items: Array; create_section_header_item?: Maybe; @@ -206,6 +210,10 @@ export type Mutation = { delete_quote_lists_items_items?: Maybe; delete_quotes_item?: Maybe; delete_quotes_items?: Maybe; + delete_resource_pages_custom_component_item?: Maybe; + delete_resource_pages_custom_component_items?: Maybe; + delete_resource_pages_item?: Maybe; + delete_resource_pages_items?: Maybe; delete_rich_text_columns_item?: Maybe; delete_rich_text_columns_items?: Maybe; delete_section_header_item?: Maybe; @@ -350,6 +358,12 @@ export type Mutation = { update_quotes_batch: Array; update_quotes_item?: Maybe; update_quotes_items: Array; + update_resource_pages_batch: Array; + update_resource_pages_custom_component_batch: Array; + update_resource_pages_custom_component_item?: Maybe; + update_resource_pages_custom_component_items: Array; + update_resource_pages_item?: Maybe; + update_resource_pages_items: Array; update_rich_text_columns_batch: Array; update_rich_text_columns_item?: Maybe; update_rich_text_columns_items: Array; @@ -1024,6 +1038,38 @@ export type MutationCreate_Quotes_ItemsArgs = { }; +export type MutationCreate_Resource_Pages_Custom_Component_ItemArgs = { + data: Create_Resource_Pages_Custom_Component_Input; +}; + + +export type MutationCreate_Resource_Pages_Custom_Component_ItemsArgs = { + data?: InputMaybe>; + filter?: InputMaybe; + limit?: InputMaybe; + offset?: InputMaybe; + page?: InputMaybe; + search?: InputMaybe; + sort?: InputMaybe>>; +}; + + +export type MutationCreate_Resource_Pages_ItemArgs = { + data: Create_Resource_Pages_Input; +}; + + +export type MutationCreate_Resource_Pages_ItemsArgs = { + data?: InputMaybe>; + filter?: InputMaybe; + limit?: InputMaybe; + offset?: InputMaybe; + page?: InputMaybe; + search?: InputMaybe; + sort?: InputMaybe>>; +}; + + export type MutationCreate_Rich_Text_Columns_ItemArgs = { data: Create_Rich_Text_Columns_Input; }; @@ -1584,6 +1630,26 @@ export type MutationDelete_Quotes_ItemsArgs = { }; +export type MutationDelete_Resource_Pages_Custom_Component_ItemArgs = { + id: Scalars['ID']['input']; +}; + + +export type MutationDelete_Resource_Pages_Custom_Component_ItemsArgs = { + ids: Array>; +}; + + +export type MutationDelete_Resource_Pages_ItemArgs = { + id: Scalars['ID']['input']; +}; + + +export type MutationDelete_Resource_Pages_ItemsArgs = { + ids: Array>; +}; + + export type MutationDelete_Rich_Text_Columns_ItemArgs = { id: Scalars['ID']['input']; }; @@ -2864,6 +2930,64 @@ export type MutationUpdate_Quotes_ItemsArgs = { }; +export type MutationUpdate_Resource_Pages_BatchArgs = { + data?: InputMaybe>; + filter?: InputMaybe; + limit?: InputMaybe; + offset?: InputMaybe; + page?: InputMaybe; + search?: InputMaybe; + sort?: InputMaybe>>; +}; + + +export type MutationUpdate_Resource_Pages_Custom_Component_BatchArgs = { + data?: InputMaybe>; + filter?: InputMaybe; + limit?: InputMaybe; + offset?: InputMaybe; + page?: InputMaybe; + search?: InputMaybe; + sort?: InputMaybe>>; +}; + + +export type MutationUpdate_Resource_Pages_Custom_Component_ItemArgs = { + data: Update_Resource_Pages_Custom_Component_Input; + id: Scalars['ID']['input']; +}; + + +export type MutationUpdate_Resource_Pages_Custom_Component_ItemsArgs = { + data: Update_Resource_Pages_Custom_Component_Input; + filter?: InputMaybe; + ids: Array>; + limit?: InputMaybe; + offset?: InputMaybe; + page?: InputMaybe; + search?: InputMaybe; + sort?: InputMaybe>>; +}; + + +export type MutationUpdate_Resource_Pages_ItemArgs = { + data: Update_Resource_Pages_Input; + id: Scalars['ID']['input']; +}; + + +export type MutationUpdate_Resource_Pages_ItemsArgs = { + data: Update_Resource_Pages_Input; + filter?: InputMaybe; + ids: Array>; + limit?: InputMaybe; + offset?: InputMaybe; + page?: InputMaybe; + search?: InputMaybe; + sort?: InputMaybe>>; +}; + + export type MutationUpdate_Rich_Text_Columns_BatchArgs = { data?: InputMaybe>; filter?: InputMaybe; @@ -3284,6 +3408,12 @@ export type Query = { quotes: Array; quotes_aggregated: Array; quotes_by_id?: Maybe; + resource_pages: Array; + resource_pages_aggregated: Array; + resource_pages_by_id?: Maybe; + resource_pages_custom_component: Array; + resource_pages_custom_component_aggregated: Array; + resource_pages_custom_component_by_id?: Maybe; rich_text_columns: Array; rich_text_columns_aggregated: Array; rich_text_columns_by_id?: Maybe; @@ -4358,6 +4488,58 @@ export type QueryQuotes_By_IdArgs = { }; +export type QueryResource_PagesArgs = { + filter?: InputMaybe; + limit?: InputMaybe; + offset?: InputMaybe; + page?: InputMaybe; + search?: InputMaybe; + sort?: InputMaybe>>; +}; + + +export type QueryResource_Pages_AggregatedArgs = { + filter?: InputMaybe; + groupBy?: InputMaybe>>; + limit?: InputMaybe; + offset?: InputMaybe; + page?: InputMaybe; + search?: InputMaybe; + sort?: InputMaybe>>; +}; + + +export type QueryResource_Pages_By_IdArgs = { + id: Scalars['ID']['input']; +}; + + +export type QueryResource_Pages_Custom_ComponentArgs = { + filter?: InputMaybe; + limit?: InputMaybe; + offset?: InputMaybe; + page?: InputMaybe; + search?: InputMaybe; + sort?: InputMaybe>>; +}; + + +export type QueryResource_Pages_Custom_Component_AggregatedArgs = { + filter?: InputMaybe; + groupBy?: InputMaybe>>; + limit?: InputMaybe; + offset?: InputMaybe; + page?: InputMaybe; + search?: InputMaybe; + sort?: InputMaybe>>; +}; + + +export type QueryResource_Pages_Custom_Component_By_IdArgs = { + id: Scalars['ID']['input']; +}; + + export type QueryRich_Text_ColumnsArgs = { filter?: InputMaybe; limit?: InputMaybe; @@ -6222,6 +6404,32 @@ export type Create_Quotes_Input = { user_updated?: InputMaybe; }; +export type Create_Resource_Pages_Custom_Component_Input = { + custom_component_id?: InputMaybe; + id?: InputMaybe; + resource_pages_id?: InputMaybe; + sort?: InputMaybe; +}; + +export type Create_Resource_Pages_Input = { + components?: InputMaybe>>; + date_created?: InputMaybe; + date_updated?: InputMaybe; + /** actual text displayed in the dropdown */ + dropdown_title?: InputMaybe; + /** if toggled, the link will point to *url*, otherwise it will point to /resources/{slug} where the component list will be shown */ + external: Scalars['Boolean']['input']; + id?: InputMaybe; + /** url keyword if not an external link */ + slug: Scalars['String']['input']; + /** order link should appear */ + sort?: InputMaybe; + status?: InputMaybe; + url?: InputMaybe; + user_created?: InputMaybe; + user_updated?: InputMaybe; +}; + export type Create_Rich_Text_Columns_Input = { body_text: Scalars['String']['input']; date_created?: InputMaybe; @@ -9190,6 +9398,187 @@ export type Quotes_Filter = { user_updated?: InputMaybe; }; +export type Resource_Pages = { + __typename?: 'resource_pages'; + components?: Maybe>>; + components_func?: Maybe; + date_created?: Maybe; + date_created_func?: Maybe; + date_updated?: Maybe; + date_updated_func?: Maybe; + /** actual text displayed in the dropdown */ + dropdown_title?: Maybe; + /** if toggled, the link will point to *url*, otherwise it will point to /resources/{slug} where the component list will be shown */ + external: Scalars['Boolean']['output']; + id: Scalars['ID']['output']; + /** url keyword if not an external link */ + slug: Scalars['String']['output']; + /** order link should appear */ + sort?: Maybe; + status?: Maybe; + url?: Maybe; + user_created?: Maybe; + user_updated?: Maybe; +}; + + +export type Resource_PagesComponentsArgs = { + filter?: InputMaybe; + limit?: InputMaybe; + offset?: InputMaybe; + page?: InputMaybe; + search?: InputMaybe; + sort?: InputMaybe>>; +}; + + +export type Resource_PagesUser_CreatedArgs = { + filter?: InputMaybe; + limit?: InputMaybe; + offset?: InputMaybe; + page?: InputMaybe; + search?: InputMaybe; + sort?: InputMaybe>>; +}; + + +export type Resource_PagesUser_UpdatedArgs = { + filter?: InputMaybe; + limit?: InputMaybe; + offset?: InputMaybe; + page?: InputMaybe; + search?: InputMaybe; + sort?: InputMaybe>>; +}; + +export type Resource_Pages_Aggregated = { + __typename?: 'resource_pages_aggregated'; + avg?: Maybe; + avgDistinct?: Maybe; + count?: Maybe; + countAll?: Maybe; + countDistinct?: Maybe; + group?: Maybe; + max?: Maybe; + min?: Maybe; + sum?: Maybe; + sumDistinct?: Maybe; +}; + +export type Resource_Pages_Aggregated_Count = { + __typename?: 'resource_pages_aggregated_count'; + components?: Maybe; + date_created?: Maybe; + date_updated?: Maybe; + /** actual text displayed in the dropdown */ + dropdown_title?: Maybe; + /** if toggled, the link will point to *url*, otherwise it will point to /resources/{slug} where the component list will be shown */ + external?: Maybe; + id?: Maybe; + /** url keyword if not an external link */ + slug?: Maybe; + /** order link should appear */ + sort?: Maybe; + status?: Maybe; + url?: Maybe; + user_created?: Maybe; + user_updated?: Maybe; +}; + +export type Resource_Pages_Aggregated_Fields = { + __typename?: 'resource_pages_aggregated_fields'; + id?: Maybe; + /** order link should appear */ + sort?: Maybe; +}; + +export type Resource_Pages_Custom_Component = { + __typename?: 'resource_pages_custom_component'; + custom_component_id?: Maybe; + id: Scalars['ID']['output']; + resource_pages_id?: Maybe; + sort?: Maybe; +}; + + +export type Resource_Pages_Custom_ComponentCustom_Component_IdArgs = { + filter?: InputMaybe; + limit?: InputMaybe; + offset?: InputMaybe; + page?: InputMaybe; + search?: InputMaybe; + sort?: InputMaybe>>; +}; + + +export type Resource_Pages_Custom_ComponentResource_Pages_IdArgs = { + filter?: InputMaybe; + limit?: InputMaybe; + offset?: InputMaybe; + page?: InputMaybe; + search?: InputMaybe; + sort?: InputMaybe>>; +}; + +export type Resource_Pages_Custom_Component_Aggregated = { + __typename?: 'resource_pages_custom_component_aggregated'; + avg?: Maybe; + avgDistinct?: Maybe; + count?: Maybe; + countAll?: Maybe; + countDistinct?: Maybe; + group?: Maybe; + max?: Maybe; + min?: Maybe; + sum?: Maybe; + sumDistinct?: Maybe; +}; + +export type Resource_Pages_Custom_Component_Aggregated_Count = { + __typename?: 'resource_pages_custom_component_aggregated_count'; + custom_component_id?: Maybe; + id?: Maybe; + resource_pages_id?: Maybe; + sort?: Maybe; +}; + +export type Resource_Pages_Custom_Component_Aggregated_Fields = { + __typename?: 'resource_pages_custom_component_aggregated_fields'; + custom_component_id?: Maybe; + id?: Maybe; + resource_pages_id?: Maybe; + sort?: Maybe; +}; + +export type Resource_Pages_Custom_Component_Filter = { + _and?: InputMaybe>>; + _or?: InputMaybe>>; + custom_component_id?: InputMaybe; + id?: InputMaybe; + resource_pages_id?: InputMaybe; + sort?: InputMaybe; +}; + +export type Resource_Pages_Filter = { + _and?: InputMaybe>>; + _or?: InputMaybe>>; + components?: InputMaybe; + components_func?: InputMaybe; + date_created?: InputMaybe; + date_created_func?: InputMaybe; + date_updated?: InputMaybe; + date_updated_func?: InputMaybe; + dropdown_title?: InputMaybe; + external?: InputMaybe; + id?: InputMaybe; + slug?: InputMaybe; + sort?: InputMaybe; + status?: InputMaybe; + url?: InputMaybe; + user_created?: InputMaybe; + user_updated?: InputMaybe; +}; + export type Rich_Text_Columns = { __typename?: 'rich_text_columns'; body_text: Scalars['String']['output']; @@ -10722,6 +11111,32 @@ export type Update_Quotes_Input = { user_updated?: InputMaybe; }; +export type Update_Resource_Pages_Custom_Component_Input = { + custom_component_id?: InputMaybe; + id?: InputMaybe; + resource_pages_id?: InputMaybe; + sort?: InputMaybe; +}; + +export type Update_Resource_Pages_Input = { + components?: InputMaybe>>; + date_created?: InputMaybe; + date_updated?: InputMaybe; + /** actual text displayed in the dropdown */ + dropdown_title?: InputMaybe; + /** if toggled, the link will point to *url*, otherwise it will point to /resources/{slug} where the component list will be shown */ + external?: InputMaybe; + id?: InputMaybe; + /** url keyword if not an external link */ + slug?: InputMaybe; + /** order link should appear */ + sort?: InputMaybe; + status?: InputMaybe; + url?: InputMaybe; + user_created?: InputMaybe; + user_updated?: InputMaybe; +}; + export type Update_Rich_Text_Columns_Input = { body_text?: InputMaybe; date_created?: InputMaybe; @@ -10904,6 +11319,13 @@ export type OurImpactComponentFragment = { __typename?: 'our_impact', top_left_m export type QuoteCarouselComponentFragment = { __typename?: 'quote_carousel', title?: string | null, quotes?: { __typename?: 'quote_lists', slug: string, items?: Array<{ __typename?: 'quote_lists_items', item?: { __typename?: 'quotes', id: string, quote?: string | null, author_text?: string | null } | null } | null> | null } | null }; +export type GlobalDataFragment = { __typename?: 'Query', site_settings?: { __typename?: 'site_settings', og_description?: string | null, og_image?: { __typename?: 'directus_files', id: string, title?: string | null, description?: string | null, tags?: any | null, filename_disk?: string | null, filename_download: string, metadata?: any | null, type?: string | null, filesize?: any | null } | null } | null, solutions_pages: Array<{ __typename?: 'solutions_pages', id: string, slug: string, category?: string | null, dropdown_icon?: string | null, dropdown_title?: string | null }>, product_pages: Array<{ __typename?: 'product_pages', id: string, slug: string, dropdown_icon?: string | null, dropdown_title?: string | null, dropdown_description?: string | null }>, resource_pages: Array<{ __typename?: 'resource_pages', id: string, external: boolean, slug: string, url?: string | null, dropdown_title?: string | null }> }; + +export type GetGlobalDataQueryVariables = Exact<{ [key: string]: never; }>; + + +export type GetGlobalDataQuery = { __typename?: 'Query', site_settings?: { __typename?: 'site_settings', og_description?: string | null, og_image?: { __typename?: 'directus_files', id: string, title?: string | null, description?: string | null, tags?: any | null, filename_disk?: string | null, filename_download: string, metadata?: any | null, type?: string | null, filesize?: any | null } | null } | null, solutions_pages: Array<{ __typename?: 'solutions_pages', id: string, slug: string, category?: string | null, dropdown_icon?: string | null, dropdown_title?: string | null }>, product_pages: Array<{ __typename?: 'product_pages', id: string, slug: string, dropdown_icon?: string | null, dropdown_title?: string | null, dropdown_description?: string | null }>, resource_pages: Array<{ __typename?: 'resource_pages', id: string, external: boolean, slug: string, url?: string | null, dropdown_title?: string | null }> }; + export type MinJobListingFragment = { __typename?: 'job_listings', id: string, slug: string, job_title?: string | null, department?: string | null, tags?: any | null, location?: string | null, status?: string | null }; export type FullJobListingFragment = { __typename?: 'job_listings', content?: string | null, id: string, slug: string, job_title?: string | null, department?: string | null, tags?: any | null, location?: string | null, status?: string | null }; @@ -10983,6 +11405,22 @@ export type ProductPageQueryVariables = Exact<{ export type ProductPageQuery = { __typename?: 'Query', product_pages: Array<{ __typename?: 'product_pages', id: string, slug: string, dropdown_icon?: string | null, dropdown_title?: string | null, dropdown_description?: string | null, custom_components?: Array<{ __typename?: 'product_pages_custom_component', custom_component_id?: { __typename?: 'custom_component', id: string, theme?: string | null, spacing_top?: string | null, spacing_bottom?: string | null, item?: Array<{ __typename?: 'custom_component_item', collection?: string | null, item?: { __typename?: 'article_cards', id: string, heading?: string | null, description?: string | null, videoUrl?: string | null, date?: any | null, author?: string | null, ctas?: any | null, url?: string | null, thumbnail?: { __typename?: 'directus_files', id: string, title?: string | null, description?: string | null, tags?: any | null, filename_disk?: string | null, filename_download: string, metadata?: any | null, type?: string | null, filesize?: any | null } | null } | { __typename?: 'blog_cards', id: string } | { __typename?: 'cards', cards?: Array<{ __typename?: 'cards_card', card_id?: { __typename?: 'card', heading: string, body_text: string, url?: string | null, image?: { __typename?: 'directus_files', id: string, title?: string | null, description?: string | null, tags?: any | null, filename_disk?: string | null, filename_download: string, metadata?: any | null, type?: string | null, filesize?: any | null } | null } | null } | null> | null } | { __typename?: 'cta', heading?: string | null, body_text?: string | null, cta_text?: string | null, cta_url?: string | null } | { __typename?: 'customer_quote', quote?: { __typename?: 'quotes', id: string, quote?: string | null, author_text?: string | null } | null } | { __typename?: 'hero', heading?: string | null, body_text?: string | null, media_type?: string | null, video_url?: string | null, form?: string | null, cta_text?: string | null, cta_url?: string | null, image?: { __typename?: 'directus_files', id: string, title?: string | null, description?: string | null, tags?: any | null, filename_disk?: string | null, filename_download: string, metadata?: any | null, type?: string | null, filesize?: any | null } | null } | { __typename?: 'large_image', overline?: string | null, heading?: string | null, body_text?: string | null, media_type?: string | null, image_position?: string | null, video_url?: string | null, form?: string | null, cta_text?: string | null, cta_url?: string | null, image?: { __typename?: 'directus_files', id: string, title?: string | null, description?: string | null, tags?: any | null, filename_disk?: string | null, filename_download: string, metadata?: any | null, type?: string | null, filesize?: any | null } | null } | { __typename?: 'logo_strip', logo_list?: { __typename?: 'company_logo_lists', slug?: string | null, logos?: Array<{ __typename?: 'company_logo_lists_company_logos', company_logos_id?: { __typename?: 'company_logos', slug?: string | null, name: string, url?: string | null, logo_light?: { __typename?: 'directus_files', id: string, title?: string | null, description?: string | null, tags?: any | null, filename_disk?: string | null, filename_download: string, metadata?: any | null, type?: string | null, filesize?: any | null } | null, logo_dark?: { __typename?: 'directus_files', id: string, title?: string | null, description?: string | null, tags?: any | null, filename_disk?: string | null, filename_download: string, metadata?: any | null, type?: string | null, filesize?: any | null } | null } | null } | null> | null } | null } | { __typename?: 'multi_column_text', columns?: Array<{ __typename?: 'multi_column_text_rich_text_columns', rich_text_columns_id?: { __typename?: 'rich_text_columns', icon?: string | null, heading?: string | null, body_text: string } | null } | null> | null } | { __typename?: 'our_impact', top_left_metric?: string | null, top_left_subtitle?: string | null, top_left_tooltip?: string | null, top_right_metric?: string | null, top_right_subtitle?: string | null, top_right_tooltip?: string | null, bottom_left_metric?: string | null, bottom_left_subtitle?: string | null, bottom_left_tooltip?: string | null, bottom_right_metric?: string | null, bottom_right_subtitle?: string | null, bottom_right_tooltip?: string | null } | { __typename?: 'quote_carousel', title?: string | null, quotes?: { __typename?: 'quote_lists', slug: string, items?: Array<{ __typename?: 'quote_lists_items', item?: { __typename?: 'quotes', id: string, quote?: string | null, author_text?: string | null } | null } | null> | null } | null } | { __typename?: 'section_header', overline?: string | null, title?: string | null, description?: string | null } | { __typename?: 'two_column_text', main_content: string, side_content: string } | null } | null> | null } | null } | null> | null }> }; +export type ResourcePageFragment = { __typename?: 'resource_pages', id: string, slug: string, url?: string | null, dropdown_title?: string | null, components?: Array<{ __typename?: 'resource_pages_custom_component', custom_component_id?: { __typename?: 'custom_component', id: string, theme?: string | null, spacing_top?: string | null, spacing_bottom?: string | null, item?: Array<{ __typename?: 'custom_component_item', collection?: string | null, item?: { __typename?: 'article_cards', id: string, heading?: string | null, description?: string | null, videoUrl?: string | null, date?: any | null, author?: string | null, ctas?: any | null, url?: string | null, thumbnail?: { __typename?: 'directus_files', id: string, title?: string | null, description?: string | null, tags?: any | null, filename_disk?: string | null, filename_download: string, metadata?: any | null, type?: string | null, filesize?: any | null } | null } | { __typename?: 'blog_cards', id: string } | { __typename?: 'cards', cards?: Array<{ __typename?: 'cards_card', card_id?: { __typename?: 'card', heading: string, body_text: string, url?: string | null, image?: { __typename?: 'directus_files', id: string, title?: string | null, description?: string | null, tags?: any | null, filename_disk?: string | null, filename_download: string, metadata?: any | null, type?: string | null, filesize?: any | null } | null } | null } | null> | null } | { __typename?: 'cta', heading?: string | null, body_text?: string | null, cta_text?: string | null, cta_url?: string | null } | { __typename?: 'customer_quote', quote?: { __typename?: 'quotes', id: string, quote?: string | null, author_text?: string | null } | null } | { __typename?: 'hero', heading?: string | null, body_text?: string | null, media_type?: string | null, video_url?: string | null, form?: string | null, cta_text?: string | null, cta_url?: string | null, image?: { __typename?: 'directus_files', id: string, title?: string | null, description?: string | null, tags?: any | null, filename_disk?: string | null, filename_download: string, metadata?: any | null, type?: string | null, filesize?: any | null } | null } | { __typename?: 'large_image', overline?: string | null, heading?: string | null, body_text?: string | null, media_type?: string | null, image_position?: string | null, video_url?: string | null, form?: string | null, cta_text?: string | null, cta_url?: string | null, image?: { __typename?: 'directus_files', id: string, title?: string | null, description?: string | null, tags?: any | null, filename_disk?: string | null, filename_download: string, metadata?: any | null, type?: string | null, filesize?: any | null } | null } | { __typename?: 'logo_strip', logo_list?: { __typename?: 'company_logo_lists', slug?: string | null, logos?: Array<{ __typename?: 'company_logo_lists_company_logos', company_logos_id?: { __typename?: 'company_logos', slug?: string | null, name: string, url?: string | null, logo_light?: { __typename?: 'directus_files', id: string, title?: string | null, description?: string | null, tags?: any | null, filename_disk?: string | null, filename_download: string, metadata?: any | null, type?: string | null, filesize?: any | null } | null, logo_dark?: { __typename?: 'directus_files', id: string, title?: string | null, description?: string | null, tags?: any | null, filename_disk?: string | null, filename_download: string, metadata?: any | null, type?: string | null, filesize?: any | null } | null } | null } | null> | null } | null } | { __typename?: 'multi_column_text', columns?: Array<{ __typename?: 'multi_column_text_rich_text_columns', rich_text_columns_id?: { __typename?: 'rich_text_columns', icon?: string | null, heading?: string | null, body_text: string } | null } | null> | null } | { __typename?: 'our_impact', top_left_metric?: string | null, top_left_subtitle?: string | null, top_left_tooltip?: string | null, top_right_metric?: string | null, top_right_subtitle?: string | null, top_right_tooltip?: string | null, bottom_left_metric?: string | null, bottom_left_subtitle?: string | null, bottom_left_tooltip?: string | null, bottom_right_metric?: string | null, bottom_right_subtitle?: string | null, bottom_right_tooltip?: string | null } | { __typename?: 'quote_carousel', title?: string | null, quotes?: { __typename?: 'quote_lists', slug: string, items?: Array<{ __typename?: 'quote_lists_items', item?: { __typename?: 'quotes', id: string, quote?: string | null, author_text?: string | null } | null } | null> | null } | null } | { __typename?: 'section_header', overline?: string | null, title?: string | null, description?: string | null } | { __typename?: 'two_column_text', main_content: string, side_content: string } | null } | null> | null } | null } | null> | null }; + +export type ResourcePageTinyFragment = { __typename?: 'resource_pages', id: string, external: boolean, slug: string, url?: string | null, dropdown_title?: string | null }; + +export type ResourcesPageSlugsQueryVariables = Exact<{ [key: string]: never; }>; + + +export type ResourcesPageSlugsQuery = { __typename?: 'Query', resource_pages: Array<{ __typename?: 'resource_pages', id: string, external: boolean, slug: string, url?: string | null, dropdown_title?: string | null }> }; + +export type ResourcePageQueryVariables = Exact<{ + slug: Scalars['String']['input']; +}>; + + +export type ResourcePageQuery = { __typename?: 'Query', resource_pages: Array<{ __typename?: 'resource_pages', id: string, slug: string, url?: string | null, dropdown_title?: string | null, components?: Array<{ __typename?: 'resource_pages_custom_component', custom_component_id?: { __typename?: 'custom_component', id: string, theme?: string | null, spacing_top?: string | null, spacing_bottom?: string | null, item?: Array<{ __typename?: 'custom_component_item', collection?: string | null, item?: { __typename?: 'article_cards', id: string, heading?: string | null, description?: string | null, videoUrl?: string | null, date?: any | null, author?: string | null, ctas?: any | null, url?: string | null, thumbnail?: { __typename?: 'directus_files', id: string, title?: string | null, description?: string | null, tags?: any | null, filename_disk?: string | null, filename_download: string, metadata?: any | null, type?: string | null, filesize?: any | null } | null } | { __typename?: 'blog_cards', id: string } | { __typename?: 'cards', cards?: Array<{ __typename?: 'cards_card', card_id?: { __typename?: 'card', heading: string, body_text: string, url?: string | null, image?: { __typename?: 'directus_files', id: string, title?: string | null, description?: string | null, tags?: any | null, filename_disk?: string | null, filename_download: string, metadata?: any | null, type?: string | null, filesize?: any | null } | null } | null } | null> | null } | { __typename?: 'cta', heading?: string | null, body_text?: string | null, cta_text?: string | null, cta_url?: string | null } | { __typename?: 'customer_quote', quote?: { __typename?: 'quotes', id: string, quote?: string | null, author_text?: string | null } | null } | { __typename?: 'hero', heading?: string | null, body_text?: string | null, media_type?: string | null, video_url?: string | null, form?: string | null, cta_text?: string | null, cta_url?: string | null, image?: { __typename?: 'directus_files', id: string, title?: string | null, description?: string | null, tags?: any | null, filename_disk?: string | null, filename_download: string, metadata?: any | null, type?: string | null, filesize?: any | null } | null } | { __typename?: 'large_image', overline?: string | null, heading?: string | null, body_text?: string | null, media_type?: string | null, image_position?: string | null, video_url?: string | null, form?: string | null, cta_text?: string | null, cta_url?: string | null, image?: { __typename?: 'directus_files', id: string, title?: string | null, description?: string | null, tags?: any | null, filename_disk?: string | null, filename_download: string, metadata?: any | null, type?: string | null, filesize?: any | null } | null } | { __typename?: 'logo_strip', logo_list?: { __typename?: 'company_logo_lists', slug?: string | null, logos?: Array<{ __typename?: 'company_logo_lists_company_logos', company_logos_id?: { __typename?: 'company_logos', slug?: string | null, name: string, url?: string | null, logo_light?: { __typename?: 'directus_files', id: string, title?: string | null, description?: string | null, tags?: any | null, filename_disk?: string | null, filename_download: string, metadata?: any | null, type?: string | null, filesize?: any | null } | null, logo_dark?: { __typename?: 'directus_files', id: string, title?: string | null, description?: string | null, tags?: any | null, filename_disk?: string | null, filename_download: string, metadata?: any | null, type?: string | null, filesize?: any | null } | null } | null } | null> | null } | null } | { __typename?: 'multi_column_text', columns?: Array<{ __typename?: 'multi_column_text_rich_text_columns', rich_text_columns_id?: { __typename?: 'rich_text_columns', icon?: string | null, heading?: string | null, body_text: string } | null } | null> | null } | { __typename?: 'our_impact', top_left_metric?: string | null, top_left_subtitle?: string | null, top_left_tooltip?: string | null, top_right_metric?: string | null, top_right_subtitle?: string | null, top_right_tooltip?: string | null, bottom_left_metric?: string | null, bottom_left_subtitle?: string | null, bottom_left_tooltip?: string | null, bottom_right_metric?: string | null, bottom_right_subtitle?: string | null, bottom_right_tooltip?: string | null } | { __typename?: 'quote_carousel', title?: string | null, quotes?: { __typename?: 'quote_lists', slug: string, items?: Array<{ __typename?: 'quote_lists_items', item?: { __typename?: 'quotes', id: string, quote?: string | null, author_text?: string | null } | null } | null> | null } | null } | { __typename?: 'section_header', overline?: string | null, title?: string | null, description?: string | null } | { __typename?: 'two_column_text', main_content: string, side_content: string } | null } | null> | null } | null } | null> | null }> }; + export type SolutionPageFragment = { __typename?: 'solutions_pages', id: string, slug: string, category?: string | null, dropdown_icon?: string | null, dropdown_title?: string | null, custom_components?: Array<{ __typename?: 'solutions_pages_custom_component', custom_component_id?: { __typename?: 'custom_component', id: string, theme?: string | null, spacing_top?: string | null, spacing_bottom?: string | null, item?: Array<{ __typename?: 'custom_component_item', collection?: string | null, item?: { __typename?: 'article_cards', id: string, heading?: string | null, description?: string | null, videoUrl?: string | null, date?: any | null, author?: string | null, ctas?: any | null, url?: string | null, thumbnail?: { __typename?: 'directus_files', id: string, title?: string | null, description?: string | null, tags?: any | null, filename_disk?: string | null, filename_download: string, metadata?: any | null, type?: string | null, filesize?: any | null } | null } | { __typename?: 'blog_cards', id: string } | { __typename?: 'cards', cards?: Array<{ __typename?: 'cards_card', card_id?: { __typename?: 'card', heading: string, body_text: string, url?: string | null, image?: { __typename?: 'directus_files', id: string, title?: string | null, description?: string | null, tags?: any | null, filename_disk?: string | null, filename_download: string, metadata?: any | null, type?: string | null, filesize?: any | null } | null } | null } | null> | null } | { __typename?: 'cta', heading?: string | null, body_text?: string | null, cta_text?: string | null, cta_url?: string | null } | { __typename?: 'customer_quote', quote?: { __typename?: 'quotes', id: string, quote?: string | null, author_text?: string | null } | null } | { __typename?: 'hero', heading?: string | null, body_text?: string | null, media_type?: string | null, video_url?: string | null, form?: string | null, cta_text?: string | null, cta_url?: string | null, image?: { __typename?: 'directus_files', id: string, title?: string | null, description?: string | null, tags?: any | null, filename_disk?: string | null, filename_download: string, metadata?: any | null, type?: string | null, filesize?: any | null } | null } | { __typename?: 'large_image', overline?: string | null, heading?: string | null, body_text?: string | null, media_type?: string | null, image_position?: string | null, video_url?: string | null, form?: string | null, cta_text?: string | null, cta_url?: string | null, image?: { __typename?: 'directus_files', id: string, title?: string | null, description?: string | null, tags?: any | null, filename_disk?: string | null, filename_download: string, metadata?: any | null, type?: string | null, filesize?: any | null } | null } | { __typename?: 'logo_strip', logo_list?: { __typename?: 'company_logo_lists', slug?: string | null, logos?: Array<{ __typename?: 'company_logo_lists_company_logos', company_logos_id?: { __typename?: 'company_logos', slug?: string | null, name: string, url?: string | null, logo_light?: { __typename?: 'directus_files', id: string, title?: string | null, description?: string | null, tags?: any | null, filename_disk?: string | null, filename_download: string, metadata?: any | null, type?: string | null, filesize?: any | null } | null, logo_dark?: { __typename?: 'directus_files', id: string, title?: string | null, description?: string | null, tags?: any | null, filename_disk?: string | null, filename_download: string, metadata?: any | null, type?: string | null, filesize?: any | null } | null } | null } | null> | null } | null } | { __typename?: 'multi_column_text', columns?: Array<{ __typename?: 'multi_column_text_rich_text_columns', rich_text_columns_id?: { __typename?: 'rich_text_columns', icon?: string | null, heading?: string | null, body_text: string } | null } | null> | null } | { __typename?: 'our_impact', top_left_metric?: string | null, top_left_subtitle?: string | null, top_left_tooltip?: string | null, top_right_metric?: string | null, top_right_subtitle?: string | null, top_right_tooltip?: string | null, bottom_left_metric?: string | null, bottom_left_subtitle?: string | null, bottom_left_tooltip?: string | null, bottom_right_metric?: string | null, bottom_right_subtitle?: string | null, bottom_right_tooltip?: string | null } | { __typename?: 'quote_carousel', title?: string | null, quotes?: { __typename?: 'quote_lists', slug: string, items?: Array<{ __typename?: 'quote_lists_items', item?: { __typename?: 'quotes', id: string, quote?: string | null, author_text?: string | null } | null } | null> | null } | null } | { __typename?: 'section_header', overline?: string | null, title?: string | null, description?: string | null } | { __typename?: 'two_column_text', main_content: string, side_content: string } | null } | null> | null } | null } | null> | null }; export type SolutionPageTinyFragment = { __typename?: 'solutions_pages', id: string, slug: string, category?: string | null, dropdown_icon?: string | null, dropdown_title?: string | null }; @@ -11290,6 +11728,60 @@ export const CustomPageTinyFragmentDoc = gql` slug } `; +export const SiteSettingsFragmentDoc = gql` + fragment SiteSettings on site_settings { + og_description + og_image { + ...ImageFile + } +} + ${ImageFileFragmentDoc}`; +export const SolutionPageTinyFragmentDoc = gql` + fragment SolutionPageTiny on solutions_pages { + id + slug + category + dropdown_icon + dropdown_title +} + `; +export const ProductPageTinyFragmentDoc = gql` + fragment ProductPageTiny on product_pages { + id + slug + dropdown_icon + dropdown_title + dropdown_description +} + `; +export const ResourcePageTinyFragmentDoc = gql` + fragment ResourcePageTiny on resource_pages { + id + external + slug + url + dropdown_title +} + `; +export const GlobalDataFragmentDoc = gql` + fragment GlobalData on Query { + site_settings { + ...SiteSettings + } + solutions_pages(filter: {status: {_neq: "hidden"}}) { + ...SolutionPageTiny + } + product_pages { + ...ProductPageTiny + } + resource_pages(filter: {status: {_neq: "hidden"}}) { + ...ResourcePageTiny + } +} + ${SiteSettingsFragmentDoc} +${SolutionPageTinyFragmentDoc} +${ProductPageTinyFragmentDoc} +${ResourcePageTinyFragmentDoc}`; export const MinJobListingFragmentDoc = gql` fragment MinJobListing on job_listings { id @@ -11389,15 +11881,19 @@ export const ProductPageFragmentDoc = gql` } } ${CustomComponentFragmentDoc}`; -export const ProductPageTinyFragmentDoc = gql` - fragment ProductPageTiny on product_pages { +export const ResourcePageFragmentDoc = gql` + fragment ResourcePage on resource_pages { id slug - dropdown_icon + url dropdown_title - dropdown_description + components { + custom_component_id { + ...CustomComponent + } + } } - `; + ${CustomComponentFragmentDoc}`; export const SolutionPageFragmentDoc = gql` fragment SolutionPage on solutions_pages { id @@ -11412,23 +11908,6 @@ export const SolutionPageFragmentDoc = gql` } } ${CustomComponentFragmentDoc}`; -export const SolutionPageTinyFragmentDoc = gql` - fragment SolutionPageTiny on solutions_pages { - id - slug - category - dropdown_icon - dropdown_title -} - `; -export const SiteSettingsFragmentDoc = gql` - fragment SiteSettings on site_settings { - og_description - og_image { - ...ImageFile - } -} - ${ImageFileFragmentDoc}`; export const MarkdownPageFragmentDoc = gql` fragment MarkdownPage on markdown_pages { id @@ -11557,6 +12036,38 @@ export function useCustomPageLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions export type CustomPageQueryHookResult = ReturnType; export type CustomPageLazyQueryHookResult = ReturnType; export type CustomPageQueryResult = Apollo.QueryResult; +export const GetGlobalDataDocument = gql` + query GetGlobalData { + ...GlobalData +} + ${GlobalDataFragmentDoc}`; + +/** + * __useGetGlobalDataQuery__ + * + * To run a query within a React component, call `useGetGlobalDataQuery` and pass it any options that fit your needs. + * When your component renders, `useGetGlobalDataQuery` returns an object from Apollo Client that contains loading, error, and data properties + * you can use to render your UI. + * + * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; + * + * @example + * const { data, loading, error } = useGetGlobalDataQuery({ + * variables: { + * }, + * }); + */ +export function useGetGlobalDataQuery(baseOptions?: Apollo.QueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useQuery(GetGlobalDataDocument, options); + } +export function useGetGlobalDataLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useLazyQuery(GetGlobalDataDocument, options); + } +export type GetGlobalDataQueryHookResult = ReturnType; +export type GetGlobalDataLazyQueryHookResult = ReturnType; +export type GetGlobalDataQueryResult = Apollo.QueryResult; export const JobListingsDocument = gql` query JobListings { job_listings(filter: {status: {_neq: "archived"}}) { @@ -11866,6 +12377,75 @@ export function useProductPageLazyQuery(baseOptions?: Apollo.LazyQueryHookOption export type ProductPageQueryHookResult = ReturnType; export type ProductPageLazyQueryHookResult = ReturnType; export type ProductPageQueryResult = Apollo.QueryResult; +export const ResourcesPageSlugsDocument = gql` + query ResourcesPageSlugs { + resource_pages(filter: {status: {_neq: "hidden"}}) { + ...ResourcePageTiny + } +} + ${ResourcePageTinyFragmentDoc}`; + +/** + * __useResourcesPageSlugsQuery__ + * + * To run a query within a React component, call `useResourcesPageSlugsQuery` and pass it any options that fit your needs. + * When your component renders, `useResourcesPageSlugsQuery` returns an object from Apollo Client that contains loading, error, and data properties + * you can use to render your UI. + * + * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; + * + * @example + * const { data, loading, error } = useResourcesPageSlugsQuery({ + * variables: { + * }, + * }); + */ +export function useResourcesPageSlugsQuery(baseOptions?: Apollo.QueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useQuery(ResourcesPageSlugsDocument, options); + } +export function useResourcesPageSlugsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useLazyQuery(ResourcesPageSlugsDocument, options); + } +export type ResourcesPageSlugsQueryHookResult = ReturnType; +export type ResourcesPageSlugsLazyQueryHookResult = ReturnType; +export type ResourcesPageSlugsQueryResult = Apollo.QueryResult; +export const ResourcePageDocument = gql` + query ResourcePage($slug: String!) { + resource_pages(filter: {slug: {_eq: $slug}, status: {_neq: "hidden"}}) { + ...ResourcePage + } +} + ${ResourcePageFragmentDoc}`; + +/** + * __useResourcePageQuery__ + * + * To run a query within a React component, call `useResourcePageQuery` and pass it any options that fit your needs. + * When your component renders, `useResourcePageQuery` returns an object from Apollo Client that contains loading, error, and data properties + * you can use to render your UI. + * + * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; + * + * @example + * const { data, loading, error } = useResourcePageQuery({ + * variables: { + * slug: // value for 'slug' + * }, + * }); + */ +export function useResourcePageQuery(baseOptions: Apollo.QueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useQuery(ResourcePageDocument, options); + } +export function useResourcePageLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useLazyQuery(ResourcePageDocument, options); + } +export type ResourcePageQueryHookResult = ReturnType; +export type ResourcePageLazyQueryHookResult = ReturnType; +export type ResourcePageQueryResult = Apollo.QueryResult; export const SolutionPageSlugsDocument = gql` query SolutionPageSlugs { solutions_pages(filter: {status: {_neq: "hidden"}}) { diff --git a/src/graph/directus/globalData.graphql b/src/graph/directus/globalData.graphql new file mode 100644 index 00000000..efc8cd99 --- /dev/null +++ b/src/graph/directus/globalData.graphql @@ -0,0 +1,18 @@ +fragment GlobalData on Query { + site_settings { + ...SiteSettings + } + solutions_pages(filter: { status: { _neq: "hidden" } }) { + ...SolutionPageTiny + } + product_pages { + ...ProductPageTiny + } + resource_pages(filter: { status: { _neq: "hidden" } }) { + ...ResourcePageTiny + } +} + +query GetGlobalData { + ...GlobalData +} diff --git a/src/graph/directus/pageData/resources.graphql b/src/graph/directus/pageData/resources.graphql new file mode 100644 index 00000000..139fc513 --- /dev/null +++ b/src/graph/directus/pageData/resources.graphql @@ -0,0 +1,31 @@ +fragment ResourcePage on resource_pages { + id + slug + url + dropdown_title + components { + custom_component_id { + ...CustomComponent + } + } +} + +fragment ResourcePageTiny on resource_pages { + id + external + slug + url + dropdown_title +} + +query ResourcesPageSlugs { + resource_pages(filter: { status: { _neq: "hidden" } }) { + ...ResourcePageTiny + } +} + +query ResourcePage($slug: String!) { + resource_pages(filter: { slug: { _eq: $slug }, status: { _neq: "hidden" } }) { + ...ResourcePage + } +} diff --git a/src/utils/getGlobalProps.tsx b/src/utils/getGlobalProps.tsx index 1858af87..a91fbb10 100644 --- a/src/utils/getGlobalProps.tsx +++ b/src/utils/getGlobalProps.tsx @@ -11,24 +11,12 @@ import { import { REVALIDATE_TIME } from '@src/consts' import { getSiteSettings } from '@src/data/getSiteSettings' import { - ProductPageSlugsDocument, - type ProductPageSlugsQuery, - type ProductPageSlugsQueryVariables, - SiteSettingsDocument, - type SiteSettingsQuery, - type SiteSettingsQueryVariables, - SolutionPageSlugsDocument, - type SolutionPageSlugsQuery, - type SolutionPageSlugsQueryVariables, + GetGlobalDataDocument, + type GetGlobalDataQuery, } from '@src/generated/graphqlDirectus' import { combineErrors } from './combineErrors' -const CACHE_POLICY = { - fetchPolicy: 'cache-first', - nextFetchPolicy: 'cache-first', -} as const - async function getGlobalProps() { const { data: githubData, error: githubError } = await until(() => getGithubDataServer() @@ -40,41 +28,23 @@ async function getGlobalProps() { swrFallback[GITHUB_DATA_URL] = githubData } - const { data: solutionsData } = await directusClient.query< - SolutionPageSlugsQuery, - SolutionPageSlugsQueryVariables - >({ - query: SolutionPageSlugsDocument, - ...CACHE_POLICY, - }) - const solutions = solutionsData.solutions_pages - - const { data: productData } = await directusClient.query< - ProductPageSlugsQuery, - ProductPageSlugsQueryVariables - >({ - query: ProductPageSlugsDocument, - ...CACHE_POLICY, + const { data, error } = await directusClient.query({ + query: GetGlobalDataDocument, }) - const products = productData.product_pages - const { data: siteSettingsData } = await directusClient.query< - SiteSettingsQuery, - SiteSettingsQueryVariables - >({ - query: SiteSettingsDocument, - ...CACHE_POLICY, - }) - const siteSettingsQuery = siteSettingsData.site_settings ?? {} - - const siteSettings = getSiteSettings(siteSettingsQuery, solutions, products) + const siteSettings = getSiteSettings( + data.site_settings ?? {}, + data.solutions_pages, + data.product_pages, + data.resource_pages + ) return { siteSettings, swrConfig: { fallback: swrFallback, }, - errors: combineErrors([githubError]), + errors: combineErrors([githubError, error]), } } type AsyncReturnType Promise> = T extends (