-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
partialize graphql to separate customizations from core
- Loading branch information
Showing
12 changed files
with
629 additions
and
528 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import sectionOptions from './fragmentSectionOptions'; | ||
|
||
export function flexHero(template = 'Flex') { | ||
const fragment = /* GraphQL */ ` | ||
... on Template_${template}_Acfflex_FlexContent_Hero { | ||
heroHeading | ||
heroSubheading | ||
heroImage { | ||
sourceUrl | ||
mediaDetails { | ||
width | ||
height | ||
} | ||
} | ||
${sectionOptions} | ||
} | ||
`; | ||
|
||
return fragment; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import sectionOptions from './fragmentSectionOptions'; | ||
|
||
export function flexMedia(template = 'Flex') { | ||
const fragment = /* GraphQL */ ` | ||
... on Template_${template}_Acfflex_FlexContent_Media { | ||
youtubeUrl | ||
variant | ||
width | ||
backgroundVideo { | ||
mediaItemUrl | ||
mediaDetails { | ||
width | ||
height | ||
} | ||
} | ||
image { | ||
altText | ||
mediaDetails { | ||
width | ||
height | ||
} | ||
sourceUrl(size: _1600_WIDE) | ||
mediaItemUrl | ||
} | ||
${sectionOptions} | ||
} | ||
`; | ||
|
||
return fragment; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import sectionOptions from './fragmentSectionOptions'; | ||
|
||
export function flexWysiwygContent(template = 'Flex') { | ||
const fragment = /* GraphQL */ ` | ||
... on Template_${template}_Acfflex_FlexContent_WysiwygContent { | ||
# contentWidth | ||
sectionHeading | ||
wysiwygContent | ||
${sectionOptions} | ||
} | ||
`; | ||
|
||
return fragment; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const fragmentCategories = /* GraphQL */ ` | ||
categories { | ||
nodes { | ||
name | ||
slug | ||
uri | ||
} | ||
} | ||
`; | ||
|
||
export default fragmentCategories; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const fragmentPageOptions = /* GraphQL */ ` | ||
acfPageOptions { | ||
footerHideNav | ||
footerHideSearch | ||
footerHideSignup | ||
footerHideSocial | ||
footerStyle | ||
headerHideNav | ||
} | ||
`; | ||
|
||
export default fragmentPageOptions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const sectionOptions = /* GraphQL */ ` | ||
backgroundColor | ||
hideSection | ||
fieldGroupName | ||
sectionClasses | ||
sectionSlug | ||
`; | ||
|
||
export default sectionOptions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const fragmentSeo = /* GraphQL */ ` | ||
seo { | ||
breadcrumbs { | ||
text | ||
url | ||
} | ||
canonical | ||
metaDesc | ||
metaRobotsNofollow | ||
metaRobotsNoindex | ||
opengraphImage { | ||
sourceUrl | ||
mediaDetails { | ||
height | ||
width | ||
} | ||
} | ||
opengraphDescription | ||
opengraphTitle | ||
twitterDescription | ||
title | ||
twitterTitle | ||
twitterImage { | ||
sourceUrl | ||
mediaDetails { | ||
height | ||
width | ||
} | ||
} | ||
} | ||
`; | ||
|
||
export default fragmentSeo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import { flexHero } from './flexHero'; | ||
import { flexMedia } from './flexMedia'; | ||
import { flexWysiwygContent } from './flexWysiwygContent'; | ||
import pageOptions from './fragmentPageOptions'; | ||
import seo from './fragmentSeo'; | ||
|
||
export const queryContent = /* GraphQL */ ` | ||
query GetContent($slug: ID!, $preview: Boolean) { | ||
contentNode(id: $slug, idType: URI, asPreview: $preview) { | ||
__typename | ||
id | ||
databaseId | ||
isPreview | ||
link | ||
slug | ||
uri | ||
date | ||
template { | ||
... on Template_Flex { | ||
acfFlex { | ||
fieldGroupName | ||
flexContent { | ||
${flexHero()} | ||
${flexMedia()} | ||
${flexWysiwygContent()} | ||
} | ||
} | ||
} | ||
} | ||
... on NodeWithTitle { | ||
title | ||
} | ||
... on NodeWithFeaturedImage { | ||
featuredImage { | ||
node { | ||
caption | ||
sourceUrl | ||
mediaDetails { | ||
height | ||
width | ||
} | ||
} | ||
} | ||
} | ||
... on NodeWithTemplate { | ||
template { | ||
__typename | ||
templateName | ||
} | ||
} | ||
... on NodeWithAuthor { | ||
authorId | ||
author { | ||
node { | ||
id | ||
name | ||
nicename | ||
lastName | ||
} | ||
} | ||
} | ||
... on NodeWithExcerpt { | ||
excerpt | ||
} | ||
... on Page { | ||
isFrontPage | ||
content | ||
${seo} | ||
${pageOptions} | ||
} | ||
... on Post { | ||
content | ||
${seo} | ||
${pageOptions} | ||
} | ||
... on PressRelease { | ||
content | ||
${seo} | ||
# $ {pageOptions} | ||
} | ||
... on Action { | ||
content | ||
${seo} | ||
# $ {pageOptions} | ||
} | ||
} | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
const fragmentMenu = /* GraphQL */ ` | ||
nodes { | ||
id | ||
databaseId | ||
label | ||
parentId | ||
url | ||
path | ||
cssClasses | ||
} | ||
`; | ||
|
||
const redirectsRedirection = /* GraphQL */ ` | ||
redirection { | ||
redirects { | ||
origin | ||
target | ||
type | ||
matchType | ||
statusCode: code | ||
} | ||
} | ||
`; | ||
|
||
const menus = /* GraphQL */ ` | ||
menuHeader: menuItems(where: { location: HEADER }, first: 100) { | ||
${fragmentMenu} | ||
} | ||
menuFooter: menuItems(where: { location: FOOTER }, first: 100) { | ||
${fragmentMenu} | ||
} | ||
menuFooterSocial: menuItems(where: { location: FOOTER_SOCIAL }, first: 100) { | ||
${fragmentMenu} | ||
} | ||
menuFooterSecondary: menuItems(where: { location: FOOTER_SECONDARY }, first: 100) { | ||
${fragmentMenu} | ||
} | ||
`; | ||
|
||
const globalOptions = /* GraphQL */ ` | ||
themeSettings: acfOptionsThemeSettings { | ||
acfGlobalOptions { | ||
fieldGroupName | ||
footer { | ||
footerCopyright | ||
copyrightAppend | ||
copyrightPrepend | ||
} | ||
} | ||
} | ||
`; | ||
|
||
const seoGlobal = /* GraphQL */ ` | ||
seo { | ||
openGraph { | ||
defaultImage { | ||
mediaDetails { | ||
width | ||
height | ||
} | ||
sourceUrl | ||
} | ||
} | ||
} | ||
`; | ||
|
||
export const queryGlobals = /* GraphQL */ ` | ||
fragment Redirects on RootQuery { | ||
redirection: ${redirectsRedirection} | ||
} | ||
fragment GlobalOptions on RootQuery { | ||
${globalOptions} | ||
} | ||
fragment SEO on RootQuery { | ||
${seoGlobal} | ||
} | ||
fragment Menus on RootQuery { | ||
${menus} | ||
} | ||
query AllGlobals { | ||
...Menus | ||
...SEO | ||
...Redirects | ||
...GlobalOptions | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// import pageOptions from './fragmentPageOptions'; | ||
import categories from './fragmentCategories'; | ||
// import seo from './fragmentSeo'; | ||
|
||
export function queryPosts(taxonomyType, taxonomyTerms) { | ||
const taxonomyQuery = | ||
'taxQuery: {taxArray: { taxonomy: $taxonomyType, terms: $taxonomyTerms, field: SLUG }},'; | ||
|
||
const taxonomyParams = ` | ||
$taxonomyType: TaxonomyEnum! | ||
$taxonomyTerms: [String]`; | ||
|
||
const query = /* GraphQL */ ` | ||
# query GetPosts($first: Int, $contentTypes: Array) { | ||
query GetPosts( | ||
$ids: [ID] | ||
$first: Int | ||
$after: String | ||
$contentTypes: [ContentTypeEnum!]! | ||
$searchQuery: String | ||
$orderField: PostObjectsConnectionOrderbyEnum! | ||
$orderDirection: OrderEnum! | ||
${taxonomyType && taxonomyTerms ? taxonomyParams : ''} | ||
) { | ||
contentNodes( | ||
first: $first | ||
after: $after | ||
where: { | ||
${taxonomyType && taxonomyTerms ? taxonomyQuery : ''} | ||
in: $ids, | ||
search: $searchQuery, | ||
contentTypes: $contentTypes, | ||
orderby: {field: $orderField, order: $orderDirection}} | ||
) { | ||
pageInfo { | ||
hasNextPage | ||
endCursor | ||
} | ||
nodes { | ||
date | ||
slug | ||
uri | ||
... on NodeWithFeaturedImage { | ||
featuredImage { | ||
node { | ||
caption | ||
sourceUrl(size: SOCIAL) | ||
mediaDetails { | ||
height | ||
width | ||
} | ||
} | ||
} | ||
} | ||
... on NodeWithTitle { | ||
title | ||
} | ||
contentType { | ||
node { | ||
name | ||
} | ||
} | ||
... on Post { | ||
${categories} | ||
} | ||
} | ||
} | ||
} | ||
`; | ||
|
||
return query; | ||
} |
Oops, something went wrong.