@@ -138,7 +136,9 @@ export function Layout({ data, children, toc, title }) {
diff --git a/components/LayoutFrontPage.jsx b/components/LayoutFrontPage.jsx
index eb0d0c8..4e23011 100644
--- a/components/LayoutFrontPage.jsx
+++ b/components/LayoutFrontPage.jsx
@@ -1,5 +1,5 @@
import { gql } from '@apollo/client'
-import { flatListToHierarchical } from '@faustwp/core'
+import { flatListToHierarchical, useFaustQuery } from '@faustwp/core'
import { FooterNavigation } from './FooterNavigation'
import { SiteFooter } from './SiteFooter'
@@ -9,8 +9,8 @@ import { SiteHeader } from '@/components/SiteHeader'
import { SitewideNotice } from '@/components/SitewideNotice'
-LayoutFrontPage.fragment = gql`
- fragment LayoutFrontPageFragment on RootQuery {
+export const LAYOUT_FRONT_PAGE_QUERY = gql`
+ query LayoutFrontPageFragment {
...SitewideNoticeFragment
...PrimaryNavigationFragment
...FooterNavigationFragment
@@ -20,8 +20,10 @@ LayoutFrontPage.fragment = gql`
${FooterNavigation.fragment}
`
-export function LayoutFrontPage({ data, children }) {
- const primaryMenuItems = data?.primaryMenuItems ?? []
+export function LayoutFrontPage({ children }) {
+
+ const { sitewideNotice, primaryMenuItems, footerMenuItems } = useFaustQuery(LAYOUT_FRONT_PAGE_QUERY);
+
const primaryNavigation = primaryMenuItems?.nodes
? flatListToHierarchical(primaryMenuItems.nodes, {
idKey: 'id',
@@ -29,7 +31,6 @@ export function LayoutFrontPage({ data, children }) {
parentKey: 'parentId',
})
: []
- const footerMenuItems = data?.footerMenuItems ?? []
const footerNavigation = footerMenuItems?.nodes
? flatListToHierarchical(footerMenuItems.nodes, {
idKey: 'id',
@@ -39,8 +40,8 @@ export function LayoutFrontPage({ data, children }) {
: []
return (
<>
-
-
+
+
{children}
diff --git a/next.config.mjs b/next.config.mjs
index bf95845..1527bce 100644
--- a/next.config.mjs
+++ b/next.config.mjs
@@ -2,35 +2,16 @@ import { withFaust, getWpHostname } from '@faustwp/core';
import withMarkdoc from '@markdoc/next.js'
import withSearch from './markdoc/search.mjs'
-function experimentalConfig() {
-
- const experimental = {
- scrollRestoration: true,
- }
-
- if (process.env.ATLAS_CACHE_HANDLER_ENABLED === undefined) {
- const atlasExperimentalOptions = { ...experimental, ...{
- incrementalCacheHandlerPath: require.resolve('./.atlas/atlas-cache-handler.js'),
- isrMemoryCacheSize: 0
- }}
- console.log( { atlasExperimentalOptions })
- return atlasExperimentalOptions
- }
-
- return experimental
-}
-
const nextConfig = {
reactStrictMode: true,
pageExtensions: ['js', 'jsx', 'ts', 'tsx', 'mdx'],
- experimental: experimentalConfig(),
+ experimental: {
+ scrollRestoration: true,
+ },
trailingSlash: true,
images: {
domains: [getWpHostname()],
},
};
-
-
-
-export default withFaust( withSearch( withMarkdoc({ schemaPath: './src/markdoc' })(nextConfig) ) );
+export default withFaust( withSearch( withMarkdoc({ schemaPath: './src/markdoc' })(nextConfig) ) );
\ No newline at end of file
diff --git a/wp-blocks/AcfFieldTypeConfigurationBlock.js b/wp-blocks/AcfFieldTypeConfigurationBlock.js
index be77ab5..be4b9d2 100644
--- a/wp-blocks/AcfFieldTypeConfigurationBlock.js
+++ b/wp-blocks/AcfFieldTypeConfigurationBlock.js
@@ -61,6 +61,11 @@ function TabContent({ fieldTypeConfigurationBlockFields, uniqueId, format }) {
export function AcfFieldTypeConfigurationBlock({ fieldTypeConfigurationBlockFields }) {
const { acfFieldType } = fieldTypeConfigurationBlockFields;
+ const [uniqueId, setUniqueId] = useState('');
+ useEffect(() => {
+ setUniqueId(stringToHash(acfFieldType));
+ }, [acfFieldType]);
+
if ( ! acfFieldType ) {
return (
@@ -70,11 +75,6 @@ export function AcfFieldTypeConfigurationBlock({ fieldTypeConfigurationBlockFiel
);
};
- const [uniqueId, setUniqueId] = useState('');
-
- useEffect(() => {
- setUniqueId(stringToHash(acfFieldType));
- }, [acfFieldType]);
const tabData = [
{ key: 'php', name: 'PHP' },
diff --git a/wp-blocks/AcfFieldTypeSettingsBlock.js b/wp-blocks/AcfFieldTypeSettingsBlock.js
index 6246348..640105c 100644
--- a/wp-blocks/AcfFieldTypeSettingsBlock.js
+++ b/wp-blocks/AcfFieldTypeSettingsBlock.js
@@ -48,7 +48,7 @@ export function AcfFieldTypeSettingsBlock({ fieldTypeSettingsBlockFields }) {
};
- if ( ! fieldTypeSettings?.nodes?.length ) {
+ if ( fieldTypeSettings?.nodes?.length === 0 ) {
return (
@@ -59,7 +59,7 @@ export function AcfFieldTypeSettingsBlock({ fieldTypeSettingsBlockFields }) {
}
// copy the nodes so we can sort them before returning
- const settings = [...fieldTypeSettings?.nodes];
+ const settings = [...fieldTypeSettings.nodes];
// sort by name
settings.sort((a, b) => {
diff --git a/wp-blocks/index.js b/wp-blocks/index.js
index 9636478..18dc9c1 100644
--- a/wp-blocks/index.js
+++ b/wp-blocks/index.js
@@ -1,5 +1,4 @@
import { CoreBlocks } from '@faustwp/blocks'
-
import { AcfFieldTypeConfigurationBlock } from './AcfFieldTypeConfigurationBlock'
import { AcfFieldTypeSettingsBlock } from './AcfFieldTypeSettingsBlock'
import { AcfGraphqlQuery } from './AcfGraphqlQuery'
diff --git a/wp-templates/IndexTemplate.js b/wp-templates/IndexTemplate.js
index 1bd0399..bb9d958 100644
--- a/wp-templates/IndexTemplate.js
+++ b/wp-templates/IndexTemplate.js
@@ -1,13 +1,62 @@
import { gql } from '@apollo/client'
import { WordPressBlocksViewer } from '@faustwp/blocks'
-import { flatListToHierarchical } from '@faustwp/core'
+import { flatListToHierarchical, useFaustQuery } from '@faustwp/core'
import Head from 'next/head'
-import { Layout } from '@/components/Layout'
+import { LAYOUT_QUERY, Layout } from '@/components/Layout'
import blocks from '@/wp-blocks'
-export const IndexTemplate = ({ data }) => {
- const { node } = data
+const INDEX_TEMPLATE_QUERY = gql`
+query IndexTemplate($uri: String!) {
+ node: nodeByUri(uri: $uri) {
+ __typename
+ uri
+ ...on NodeWithTitle {
+ title
+ }
+ ...on NodeWithEditorBlocks {
+ editorBlocks {
+ __typename
+ name
+ renderedHtml
+ id: clientId
+ parentId: parentClientId
+ ...${blocks.CoreParagraph.fragments.key}
+ ...${blocks.CoreColumns.fragments.key}
+ ...${blocks.CoreColumn.fragments.key}
+ ...${blocks.CoreCode.fragments.key}
+ ...${blocks.CoreButtons.fragments.key}
+ ...${blocks.CoreButton.fragments.key}
+ ...${blocks.CoreQuote.fragments.key}
+ ...${blocks.CoreImage.fragments.key}
+ ...${blocks.CoreSeparator.fragments.key}
+ ...${blocks.CoreList.fragments.key}
+ ...${blocks.CoreHeading.fragments.key}
+ }
+ }
+ ...on ContentNode {
+ modified
+ ...on NodeWithContentEditor {
+ content
+ }
+ }
+ }
+}
+${blocks.CoreParagraph.fragments.entry}
+${blocks.CoreColumns.fragments.entry}
+${blocks.CoreColumn.fragments.entry}
+${blocks.CoreCode.fragments.entry}
+${blocks.CoreButtons.fragments.entry}
+${blocks.CoreButton.fragments.entry}
+${blocks.CoreQuote.fragments.entry}
+${blocks.CoreImage.fragments.entry}
+${blocks.CoreSeparator.fragments.entry}
+${blocks.CoreList.fragments.entry}
+${blocks.CoreHeading.fragments.entry}
+`
+
+export const IndexTemplate = () => {
+ const { node } = useFaustQuery(INDEX_TEMPLATE_QUERY)
if (!node) {
return null
@@ -54,9 +103,8 @@ export const IndexTemplate = ({ data }) => {
{node?.modified && (
@@ -83,55 +131,12 @@ export const IndexTemplate = ({ data }) => {
)
}
-IndexTemplate.query = gql`
-query IndexTemplate($uri: String!) {
- node: nodeByUri(uri: $uri) {
- __typename
- uri
- ...on NodeWithTitle {
- title
- }
- ...on NodeWithEditorBlocks {
- editorBlocks {
- __typename
- name
- renderedHtml
- id: clientId
- parentId: parentClientId
- ...${blocks.CoreParagraph.fragments.key}
- ...${blocks.CoreColumns.fragments.key}
- ...${blocks.CoreColumn.fragments.key}
- ...${blocks.CoreCode.fragments.key}
- ...${blocks.CoreButtons.fragments.key}
- ...${blocks.CoreButton.fragments.key}
- ...${blocks.CoreQuote.fragments.key}
- ...${blocks.CoreImage.fragments.key}
- ...${blocks.CoreSeparator.fragments.key}
- ...${blocks.CoreList.fragments.key}
- ...${blocks.CoreHeading.fragments.key}
- }
- }
- ...on ContentNode {
- modified
- ...on NodeWithContentEditor {
- content
- }
- }
- }
- ...LayoutFragment
-}
-${blocks.CoreParagraph.fragments.entry}
-${blocks.CoreColumns.fragments.entry}
-${blocks.CoreColumn.fragments.entry}
-${blocks.CoreCode.fragments.entry}
-${blocks.CoreButtons.fragments.entry}
-${blocks.CoreButton.fragments.entry}
-${blocks.CoreQuote.fragments.entry}
-${blocks.CoreImage.fragments.entry}
-${blocks.CoreSeparator.fragments.entry}
-${blocks.CoreList.fragments.entry}
-${blocks.CoreHeading.fragments.entry}
-${Layout.fragment}
-`
-
-IndexTemplate.variables = ({ uri }) => ({ uri })
+IndexTemplate.queries = [
+ {
+ query: LAYOUT_QUERY,
+ },
+ {
+ query: INDEX_TEMPLATE_QUERY,
+ variables: ({ uri }) => ({ uri }),
+ }
+];
\ No newline at end of file
diff --git a/wp-templates/archive-field_type.js b/wp-templates/archive-field_type.js
index f9e8395..10da1c1 100644
--- a/wp-templates/archive-field_type.js
+++ b/wp-templates/archive-field_type.js
@@ -1,6 +1,6 @@
import { gql } from '@apollo/client'
-import Head from 'next/head'
import { useFaustQuery } from "@faustwp/core";
+import Head from 'next/head'
import { FieldTypesList } from '@/components/FieldTypesList'
import { LayoutArchive, GET_LAYOUT_QUERY } from '@/components/LayoutArchive'
@@ -38,7 +38,7 @@ export const GET_POST_QUERY = gql`
}
`;
-export const ArchiveFieldType = (props) => {
+export const ArchiveFieldType = () => {
const { node } = useFaustQuery(GET_POST_QUERY);
const {
docsSidebarMenuItems,
@@ -47,8 +47,6 @@ export const ArchiveFieldType = (props) => {
sitewideNotice
} = useFaustQuery(GET_LAYOUT_QUERY);
- // console.log({ node, docsSidebarMenuItems, footerMenuItems, primaryMenuItems, sitewideNotice });
-
if (!node) {
return null
}
diff --git a/wp-templates/archive.js b/wp-templates/archive.js
index c32e874..bccb6dc 100644
--- a/wp-templates/archive.js
+++ b/wp-templates/archive.js
@@ -1,27 +1,9 @@
import { gql } from '@apollo/client'
+import { useFaustQuery } from "@faustwp/core";
import Head from 'next/head'
import { LayoutArchive, GET_LAYOUT_QUERY } from '@/components/LayoutArchive'
-export const Archive = (props) => {
- const { data } = props
-
- return (
- <>
-
- {`${data?.node?.name} - WPGraphQL for ACF`}
-
-
- {/*
- >
- )
-}
-
const GET_ARCHIVE_QUERY = gql`
query GetArchive($uri: String!) {
node: nodeByUri(uri: $uri) {
@@ -44,9 +26,47 @@ const GET_ARCHIVE_QUERY = gql`
}
`
-Archive.variables = (seedNode) => {
- console.log({seedNode});
- return {
- uri: seedNode.uri
- };
+export const Archive = () => {
+ const { node } = useFaustQuery(GET_ARCHIVE_QUERY);
+ const {
+ docsSidebarMenuItems,
+ footerMenuItems,
+ primaryMenuItems,
+ sitewideNotice
+ } = useFaustQuery(GET_LAYOUT_QUERY);
+
+ return (
+ <>
+
+ {`${node?.name} - WPGraphQL for ACF`}
+
+
+ {/*
+ >
+ )
}
+
+
+Archive.queries = [
+ {
+ query: GET_LAYOUT_QUERY,
+ },
+ {
+ query: GET_ARCHIVE_QUERY,
+ variables: (seedNode) => {
+ return {
+ uri: seedNode.uri
+ }
+ }
+ }
+];
diff --git a/wp-templates/front-page.js b/wp-templates/front-page.js
index 2aadb83..fd2c3c4 100644
--- a/wp-templates/front-page.js
+++ b/wp-templates/front-page.js
@@ -4,32 +4,10 @@ import HomepageLayoutsLayoutsFaqsLayout from '@/components/HomepageLayoutsLayout
import HomepageLayoutsLayoutsFeaturesLayout from '@/components/HomepageLayoutsLayoutsFeaturesLayout'
import HomepageLayoutsLayoutsHeroLayout from '@/components/HomepageLayoutsLayoutsHeroLayout'
import HomepageLayoutsLayoutsSupportedFieldTypesLayout from '@/components/HomepageLayoutsLayoutsSupportedFieldTypesLayout'
-import { LayoutFrontPage } from '@/components/LayoutFrontPage'
+import { LayoutFrontPage, LAYOUT_FRONT_PAGE_QUERY } from '@/components/LayoutFrontPage'
+import { useFaustQuery } from '@faustwp/core'
-export const FrontPage = ({ data }) => {
- return (
-
- {data?.frontPage?.homepageLayouts?.layouts?.map((layout, i) => {
- switch (layout.__typename) {
- case 'HomepageLayoutsLayoutsHeroLayout':
- return
- case 'HomepageLayoutsLayoutsFeaturesLayout':
- return
- case 'HomepageLayoutsLayoutsSupportedFieldTypesLayout':
- return (
-
- )
- case 'HomepageLayoutsLayoutsFaqsLayout':
- return
- default:
- return
- )
-}
-
-FrontPage.query = gql`
+const FRONT_PAGE_QUERY = gql`
query GetFrontPage($uri: String!) {
frontPage: nodeByUri(uri: $uri) {
__typename
@@ -53,13 +31,47 @@ FrontPage.query = gql`
}
}
}
- ...LayoutFrontPageFragment
}
${HomepageLayoutsLayoutsHeroLayout.fragment}
${HomepageLayoutsLayoutsFeaturesLayout.fragment}
${HomepageLayoutsLayoutsSupportedFieldTypesLayout.fragment}
${HomepageLayoutsLayoutsFaqsLayout.fragment}
- ${LayoutFrontPage.fragment}
-`
+`;
+
+export const FrontPage = () => {
+
+ const { frontPage } = useFaustQuery(FRONT_PAGE_QUERY);
+
+ return (
+
+ {frontPage?.homepageLayouts?.layouts?.map((layout, i) => {
+ switch (layout.__typename) {
+ case 'HomepageLayoutsLayoutsHeroLayout':
+ return
+ case 'HomepageLayoutsLayoutsFeaturesLayout':
+ return
+ case 'HomepageLayoutsLayoutsSupportedFieldTypesLayout':
+ return (
+
+ )
+ case 'HomepageLayoutsLayoutsFaqsLayout':
+ return
+ default:
+ return
+ )
+}
+
+
+FrontPage.queries = [
+ {
+ query: LAYOUT_FRONT_PAGE_QUERY,
+ },
+ {
+ query: FRONT_PAGE_QUERY,
+ variables: ({ uri }) => ({ uri }),
+ },
+]
-FrontPage.variables = ({ uri }) => ({ uri })
diff --git a/wp-templates/single-field_type.js b/wp-templates/single-field_type.js
index 55ba9c8..ed867ae 100644
--- a/wp-templates/single-field_type.js
+++ b/wp-templates/single-field_type.js
@@ -1,18 +1,81 @@
import { gql } from '@apollo/client'
import { WordPressBlocksViewer } from '@faustwp/blocks'
-import { flatListToHierarchical } from '@faustwp/core'
+import { flatListToHierarchical, useFaustQuery } from '@faustwp/core'
import { Separator } from '@radix-ui/react-separator'
import Head from 'next/head'
-import { Layout } from '@/components/Layout'
+import { Layout, LAYOUT_QUERY } from '@/components/Layout'
import { Badge } from '@/components/ui/badge'
import blocks from '@/wp-blocks'
import { AcfFieldTypeConfigurationBlock } from '@/wp-blocks/AcfFieldTypeConfigurationBlock'
import { AcfFieldTypeSettingsBlock } from '@/wp-blocks/AcfFieldTypeSettingsBlock'
import { AcfGraphqlQuery } from '@/wp-blocks/AcfGraphqlQuery'
-export const SingleFieldType = ({ data }) => {
- const { node } = data
+const aCFFieldTypeCategoriesFragment = gql`
+ fragment aCFFieldTypeCategoriesFragment on FieldType {
+ aCFFieldTypeCategories {
+ nodes {
+ id
+ name
+ }
+ }
+ }
+`
+
+const SINGLE_ACF_FIELD_TYPE_QUERY = gql`
+query SingleAcfFieldType($uri: String!) {
+ node: nodeByUri(uri: $uri) {
+ __typename
+ uri
+ ...on FieldType {
+ title
+ # content
+ modified
+ editorBlocks {
+ __typename
+ name
+ renderedHtml
+ id: clientId
+ parentId: parentClientId
+ ...${blocks.CoreParagraph.fragments.key}
+ ...${blocks.CoreColumns.fragments.key}
+ ...${blocks.CoreColumn.fragments.key}
+ ...${blocks.CoreCode.fragments.key}
+ ...${blocks.CoreButtons.fragments.key}
+ ...${blocks.CoreButton.fragments.key}
+ ...${blocks.CoreQuote.fragments.key}
+ ...${blocks.CoreImage.fragments.key}
+ ...${blocks.CoreSeparator.fragments.key}
+ ...${blocks.CoreList.fragments.key}
+ ...${blocks.CoreHeading.fragments.key}
+ ...${AcfFieldTypeSettingsBlock.fragments.key}
+ ...${AcfFieldTypeConfigurationBlock.fragments.key}
+ ...${AcfGraphqlQuery.fragments.key}
+ }
+ }
+ ...aCFFieldTypeCategoriesFragment
+ }
+}
+${aCFFieldTypeCategoriesFragment}
+${AcfFieldTypeSettingsBlock.fragments.entry}
+${AcfFieldTypeConfigurationBlock.fragments.entry}
+${AcfGraphqlQuery.fragments.entry}
+
+${blocks.CoreParagraph.fragments.entry}
+${blocks.CoreColumns.fragments.entry}
+${blocks.CoreColumn.fragments.entry}
+${blocks.CoreCode.fragments.entry}
+${blocks.CoreButtons.fragments.entry}
+${blocks.CoreButton.fragments.entry}
+${blocks.CoreQuote.fragments.entry}
+${blocks.CoreImage.fragments.entry}
+${blocks.CoreSeparator.fragments.entry}
+${blocks.CoreList.fragments.entry}
+${blocks.CoreHeading.fragments.entry}
+`
+
+export const SingleFieldType = () => {
+ const { node } = useFaustQuery(SINGLE_ACF_FIELD_TYPE_QUERY)
if (!node) {
return null
@@ -50,7 +113,7 @@ export const SingleFieldType = ({ data }) => {
{`${title} - WPGraphQL for ACF`}
-
+
{JSON.stringify(props, null, 2)}*/} -
{JSON.stringify(props, null, 2)}*/} +
{JSON.stringify(layout, null, 2)}- } - })} -
{JSON.stringify(layout, null, 2)}+ } + })} +
{title}
{node?.aCFFieldTypeCategories && node?.aCFFieldTypeCategories?.nodes && (
@@ -79,69 +142,12 @@ export const SingleFieldType = ({ data }) => {
)
}
-const aCFFieldTypeCategoriesFragment = gql`
- fragment aCFFieldTypeCategoriesFragment on FieldType {
- aCFFieldTypeCategories {
- nodes {
- id
- name
- }
- }
- }
-`
-
-SingleFieldType.query = gql`
-query SingleAcfFieldType($uri: String!) {
- ...LayoutFragment
- node: nodeByUri(uri: $uri) {
- __typename
- uri
- ...on FieldType {
- title
- # content
- modified
- editorBlocks {
- __typename
- name
- renderedHtml
- id: clientId
- parentId: parentClientId
- ...${blocks.CoreParagraph.fragments.key}
- ...${blocks.CoreColumns.fragments.key}
- ...${blocks.CoreColumn.fragments.key}
- ...${blocks.CoreCode.fragments.key}
- ...${blocks.CoreButtons.fragments.key}
- ...${blocks.CoreButton.fragments.key}
- ...${blocks.CoreQuote.fragments.key}
- ...${blocks.CoreImage.fragments.key}
- ...${blocks.CoreSeparator.fragments.key}
- ...${blocks.CoreList.fragments.key}
- ...${blocks.CoreHeading.fragments.key}
- ...${AcfFieldTypeSettingsBlock.fragments.key}
- ...${AcfFieldTypeConfigurationBlock.fragments.key}
- ...${AcfGraphqlQuery.fragments.key}
- }
- }
- ...aCFFieldTypeCategoriesFragment
- }
-}
-${Layout.fragment}
-${aCFFieldTypeCategoriesFragment}
-${AcfFieldTypeSettingsBlock.fragments.entry}
-${AcfFieldTypeConfigurationBlock.fragments.entry}
-${AcfGraphqlQuery.fragments.entry}
-
-${blocks.CoreParagraph.fragments.entry}
-${blocks.CoreColumns.fragments.entry}
-${blocks.CoreColumn.fragments.entry}
-${blocks.CoreCode.fragments.entry}
-${blocks.CoreButtons.fragments.entry}
-${blocks.CoreButton.fragments.entry}
-${blocks.CoreQuote.fragments.entry}
-${blocks.CoreImage.fragments.entry}
-${blocks.CoreSeparator.fragments.entry}
-${blocks.CoreList.fragments.entry}
-${blocks.CoreHeading.fragments.entry}
-`
-
-SingleFieldType.variables = ({ uri }) => ({ uri })
+SingleFieldType.queries = [
+ {
+ query: LAYOUT_QUERY,
+ },
+ {
+ query: SINGLE_ACF_FIELD_TYPE_QUERY,
+ variables: ({ uri }) => ({ uri }),
+ },
+];
\ No newline at end of file