diff --git a/components/molecules/Blocks/Blocks.js b/components/molecules/Blocks/Blocks.js index 8bd55f492..a512087ad 100644 --- a/components/molecules/Blocks/Blocks.js +++ b/components/molecules/Blocks/Blocks.js @@ -1,6 +1,6 @@ +import displayBlock from '@/functions/wordpress/blocks/displayBlock' import PropTypes from 'prop-types' import React from 'react' -import displayBlock from '@/functions/displayBlock' /** * Render the Blocks component. diff --git a/components/molecules/Comments/Comments.js b/components/molecules/Comments/Comments.js index 1f669e730..7d37d5c8f 100644 --- a/components/molecules/Comments/Comments.js +++ b/components/molecules/Comments/Comments.js @@ -1,6 +1,6 @@ import Text from '@/components/atoms/Inputs/Text' import Form from '@/components/molecules/Form' -import processPostComment from '@/lib/next-api/wordpress/comments/processPostComment' +import processPostComment from '@/functions/next-api/wordpress/comments/processPostComment' import {useSession} from 'next-auth/client' import PropTypes from 'prop-types' import React, {useState} from 'react' diff --git a/components/molecules/GravityForm/Fields/Checkbox.js b/components/molecules/GravityForm/Fields/Checkbox.js index 48a5541d3..56946524d 100644 --- a/components/molecules/GravityForm/Fields/Checkbox.js +++ b/components/molecules/GravityForm/Fields/Checkbox.js @@ -1,7 +1,10 @@ -import PropTypes from 'prop-types' -import {getGfFieldId, getGfHiddenClassName} from '@/functions/gravityForms' -import cn from 'classnames' import * as Input from '@/components/atoms/Inputs' +import { + getGfFieldId, + getGfHiddenClassName +} from '@/functions/wordpress/gravityForms' +import cn from 'classnames' +import PropTypes from 'prop-types' /** * Merge GravityForm checkbox field data into single Array. diff --git a/components/molecules/GravityForm/Fields/File.js b/components/molecules/GravityForm/Fields/File.js index 2e86e61ac..dea16ae43 100644 --- a/components/molecules/GravityForm/Fields/File.js +++ b/components/molecules/GravityForm/Fields/File.js @@ -1,9 +1,12 @@ -import PropTypes from 'prop-types' -import {getGfFieldId, getGfHiddenClassName} from '@/functions/gravityForms' -import {Field} from 'formik' import InputError from '@/components/atoms/Inputs/InputError' import styles from '@/components/atoms/Inputs/Text/Text.module.css' +import { + getGfFieldId, + getGfHiddenClassName +} from '@/functions/wordpress/gravityForms' import cn from 'classnames' +import {Field} from 'formik' +import PropTypes from 'prop-types' /** * Render GravityForms File field component. diff --git a/components/molecules/GravityForm/Fields/Select.js b/components/molecules/GravityForm/Fields/Select.js index 4c1729512..480a52b2a 100644 --- a/components/molecules/GravityForm/Fields/Select.js +++ b/components/molecules/GravityForm/Fields/Select.js @@ -1,7 +1,10 @@ -import PropTypes from 'prop-types' -import {getGfFieldId, getGfHiddenClassName} from '@/functions/gravityForms' import * as Input from '@/components/atoms/Inputs' +import { + getGfFieldId, + getGfHiddenClassName +} from '@/functions/wordpress/gravityForms' import cn from 'classnames' +import PropTypes from 'prop-types' /** * Render GravityForms Select field component. diff --git a/components/molecules/GravityForm/Fields/Text.js b/components/molecules/GravityForm/Fields/Text.js index 306ca7e35..fa665d9e8 100644 --- a/components/molecules/GravityForm/Fields/Text.js +++ b/components/molecules/GravityForm/Fields/Text.js @@ -1,7 +1,10 @@ -import PropTypes from 'prop-types' import * as Input from '@/components/atoms/Inputs' -import {getGfFieldId, getGfHiddenClassName} from '@/functions/gravityForms' +import { + getGfFieldId, + getGfHiddenClassName +} from '@/functions/wordpress/gravityForms' import cn from 'classnames' +import PropTypes from 'prop-types' /** * Render the GravityForm Text component. diff --git a/components/molecules/GravityForm/Fields/Textarea.js b/components/molecules/GravityForm/Fields/Textarea.js index b31f82227..788c0e595 100644 --- a/components/molecules/GravityForm/Fields/Textarea.js +++ b/components/molecules/GravityForm/Fields/Textarea.js @@ -1,9 +1,12 @@ -import PropTypes from 'prop-types' -import {getGfFieldId, getGfHiddenClassName} from '@/functions/gravityForms' -import {Field} from 'formik' import InputError from '@/components/atoms/Inputs/InputError' import styles from '@/components/atoms/Inputs/Text/Text.module.css' +import { + getGfFieldId, + getGfHiddenClassName +} from '@/functions/wordpress/gravityForms' import cn from 'classnames' +import {Field} from 'formik' +import PropTypes from 'prop-types' /** * Render GravityForms Textarea field component. diff --git a/components/molecules/GravityForm/GravityForm.js b/components/molecules/GravityForm/GravityForm.js index b0a78c7eb..6bbb3f086 100644 --- a/components/molecules/GravityForm/GravityForm.js +++ b/components/molecules/GravityForm/GravityForm.js @@ -1,6 +1,6 @@ import Form from '@/components/molecules/Form' -import getGfFormDefaults from '@/functions/gravityForms/getGfFormDefaults' -import getGfFormValidationSchema from '@/functions/gravityForms/getGfFormValidationSchema' +import getGfFormDefaults from '@/functions/wordpress/gravityForms/getGfFormDefaults' +import getGfFormValidationSchema from '@/functions/wordpress/gravityForms/getGfFormValidationSchema' import cn from 'classnames' import PropTypes from 'prop-types' import React, {useState} from 'react' diff --git a/functions/getPagePropTypes.js b/functions/getPagePropTypes.js index 144eed530..921bb5ed0 100644 --- a/functions/getPagePropTypes.js +++ b/functions/getPagePropTypes.js @@ -1,7 +1,5 @@ -import { - isHierarchicalPostType, - isValidPostType -} from '@/lib/wordpress/_global/postTypes' +import isHierarchicalPostType from '@/functions/wordpress/postTypes/isHierarchicalPostType' +import isValidPostType from '@/functions/wordpress/postTypes/isValidPostType' import PropTypes from 'prop-types' // Yoast SEO social prop types. @@ -74,7 +72,7 @@ export const archivePropTypes = { * * @author WebDevStudios * @param {string} postType WP post type. - * @return {object} Page prop types. + * @return {object} Page prop types. */ export default function getPagePropTypes(postType) { // Check if post type is valid. diff --git a/functions/next-api/README.md b/functions/next-api/README.md new file mode 100644 index 000000000..6f4de152d --- /dev/null +++ b/functions/next-api/README.md @@ -0,0 +1,5 @@ +# /functions/next-api/ + +Functions for interacting with our Next.js API Routes, defined in `pages/api/`. + +Subfolders should correspond to API routes, e.g., `/functions/next-api/wordpress/` matches with `/pages/api/wordpress/`. diff --git a/functions/next-api/wordpress/README.md b/functions/next-api/wordpress/README.md new file mode 100644 index 000000000..05daf02d7 --- /dev/null +++ b/functions/next-api/wordpress/README.md @@ -0,0 +1,3 @@ +# /functions/next-api/wordpress/ + +Functions for interacting with our WordPress-specific Next.js API Routes, defined in `/pages/api/wordpress/`. diff --git a/lib/next-api/wordpress/archive/getArchivePosts.js b/functions/next-api/wordpress/archive/getArchivePosts.js similarity index 92% rename from lib/next-api/wordpress/archive/getArchivePosts.js rename to functions/next-api/wordpress/archive/getArchivePosts.js index 15a1f1be6..ef11d1f37 100644 --- a/lib/next-api/wordpress/archive/getArchivePosts.js +++ b/functions/next-api/wordpress/archive/getArchivePosts.js @@ -1,5 +1,5 @@ import {initializeNextApiApollo} from '@/lib/next-api/connector' -import queryArchivePosts from './queryArchivePosts' +import queryArchivePosts from '@/lib/next-api/wordpress/archive/queryArchivePosts' /** * Retrieve next page of posts for post type archive. diff --git a/lib/next-api/wordpress/comments/processPostComment.js b/functions/next-api/wordpress/comments/processPostComment.js similarity index 95% rename from lib/next-api/wordpress/comments/processPostComment.js rename to functions/next-api/wordpress/comments/processPostComment.js index ab07bc2a9..d20a0e1aa 100644 --- a/lib/next-api/wordpress/comments/processPostComment.js +++ b/functions/next-api/wordpress/comments/processPostComment.js @@ -1,5 +1,5 @@ import {initializeNextApiApollo} from '@/lib/next-api/connector' -import mutationAddComment from './mutationAddComment' +import mutationAddComment from '@/lib/next-api/wordpress/comments/mutationAddComment' /** * Add a comment to the given post. Follows established WordPress diff --git a/functions/wordpress/README.md b/functions/wordpress/README.md new file mode 100644 index 000000000..8ac40b437 --- /dev/null +++ b/functions/wordpress/README.md @@ -0,0 +1,3 @@ +# /functions/wordpress/ + +Functions for interacting with the WordPress GraphQL API or processing WordPress data. diff --git a/lib/wordpress/users/loginUser.js b/functions/wordpress/auth/loginUser.js similarity index 91% rename from lib/wordpress/users/loginUser.js rename to functions/wordpress/auth/loginUser.js index d12c2a76f..e1989c8af 100644 --- a/lib/wordpress/users/loginUser.js +++ b/functions/wordpress/auth/loginUser.js @@ -1,5 +1,5 @@ +import mutationLoginUser from '@/lib/wordpress/auth/mutationLoginUser' import {initializeWpApollo} from '@/lib/wordpress/connector' -import mutationLoginUser from './mutationLoginUser' /** * Log user into WP. diff --git a/lib/wordpress/users/refreshAuthToken.js b/functions/wordpress/auth/refreshAuthToken.js similarity index 90% rename from lib/wordpress/users/refreshAuthToken.js rename to functions/wordpress/auth/refreshAuthToken.js index 321dd6e38..4e0694e5d 100644 --- a/lib/wordpress/users/refreshAuthToken.js +++ b/functions/wordpress/auth/refreshAuthToken.js @@ -1,5 +1,5 @@ +import mutationRefreshAuthToken from '@/lib/wordpress/auth/mutationRefreshAuthToken' import {initializeWpApollo} from '@/lib/wordpress/connector' -import mutationRefreshAuthToken from './mutationRefreshAuthToken' /** * Get a new auth token using refresh token. diff --git a/lib/wordpress/users/registerUser.js b/functions/wordpress/auth/registerUser.js similarity index 93% rename from lib/wordpress/users/registerUser.js rename to functions/wordpress/auth/registerUser.js index 56f76c637..c9e16375f 100644 --- a/lib/wordpress/users/registerUser.js +++ b/functions/wordpress/auth/registerUser.js @@ -1,5 +1,5 @@ +import mutationRegisterUser from '@/lib/wordpress/auth/mutationRegisterUser' import {initializeWpApollo} from '@/lib/wordpress/connector' -import mutationRegisterUser from './mutationRegisterUser' /** * Register a user in WP. diff --git a/functions/displayBlock.js b/functions/wordpress/blocks/displayBlock.js similarity index 100% rename from functions/displayBlock.js rename to functions/wordpress/blocks/displayBlock.js diff --git a/functions/formatBlockData.js b/functions/wordpress/blocks/formatBlockData.js similarity index 78% rename from functions/formatBlockData.js rename to functions/wordpress/blocks/formatBlockData.js index ca696cb03..ab2deef16 100644 --- a/functions/formatBlockData.js +++ b/functions/wordpress/blocks/formatBlockData.js @@ -1,5 +1,5 @@ -import getFormById from '@/lib/wordpress/gravityForms/getFormById' -import getMediaByID from '@/lib/wordpress/media/getMediaByID' +import getGfFormById from '@/functions/wordpress/gravityForms/getGfFormById' +import getMediaByID from '@/functions/wordpress/media/getMediaByID' /** * Format and retrieve expanded block data. @@ -23,7 +23,7 @@ export default async function formatBlockData(blocks) { break case 'gravityforms/form': // Retrieve form data. - attributes.formData = await getFormById(attributes?.formId) + attributes.formData = await getGfFormById(attributes?.formId) break } diff --git a/lib/wordpress/comments/insertPostComment.js b/functions/wordpress/comments/insertPostComment.js similarity index 96% rename from lib/wordpress/comments/insertPostComment.js rename to functions/wordpress/comments/insertPostComment.js index f6468ace5..2c7592a6c 100644 --- a/lib/wordpress/comments/insertPostComment.js +++ b/functions/wordpress/comments/insertPostComment.js @@ -1,5 +1,5 @@ +import mutationInsertComment from '@/lib/wordpress/comments/mutationInsertComment' import {initializeWpApollo} from '@/lib/wordpress/connector' -import mutationInsertComment from './mutationInsertComment' /** * Add a comment to the given post. Follows established WordPress diff --git a/functions/gravityForms/getGfFieldId.js b/functions/wordpress/gravityForms/getGfFieldId.js similarity index 100% rename from functions/gravityForms/getGfFieldId.js rename to functions/wordpress/gravityForms/getGfFieldId.js diff --git a/lib/wordpress/gravityForms/getFormById.js b/functions/wordpress/gravityForms/getGfFormById.js similarity index 87% rename from lib/wordpress/gravityForms/getFormById.js rename to functions/wordpress/gravityForms/getGfFormById.js index 0db09fa21..04afb5bfd 100644 --- a/lib/wordpress/gravityForms/getFormById.js +++ b/functions/wordpress/gravityForms/getGfFormById.js @@ -1,5 +1,5 @@ import {initializeWpApollo} from '@/lib/wordpress/connector' -import queryFormById from './queryFormById' +import queryFormById from '@/lib/wordpress/gravityForms/queryFormById' /** * Retrieve single form by ID. @@ -8,7 +8,7 @@ import queryFormById from './queryFormById' * @param {string} id Form ID. * @return {object} Post data or error object. */ -export default async function getFormById(id) { +export default async function getGfFormById(id) { // Determine form global ID. const formId = Buffer.from(`GravityFormsForm:${id}`).toString('base64') diff --git a/functions/gravityForms/getGfFormDefaults.js b/functions/wordpress/gravityForms/getGfFormDefaults.js similarity index 96% rename from functions/gravityForms/getGfFormDefaults.js rename to functions/wordpress/gravityForms/getGfFormDefaults.js index 6e4f71a5f..6186b81c3 100644 --- a/functions/gravityForms/getGfFormDefaults.js +++ b/functions/wordpress/gravityForms/getGfFormDefaults.js @@ -1,4 +1,4 @@ -import getGfFieldId from '@/functions/gravityForms/getGfFieldId' +import getGfFieldId from '@/functions/wordpress/gravityForms/getGfFieldId' /** * Assign default values for GravityForm Checkboxes. diff --git a/functions/gravityForms/getGfFormValidationSchema.js b/functions/wordpress/gravityForms/getGfFormValidationSchema.js similarity index 87% rename from functions/gravityForms/getGfFormValidationSchema.js rename to functions/wordpress/gravityForms/getGfFormValidationSchema.js index 9bd510b2b..d505a5b71 100644 --- a/functions/gravityForms/getGfFormValidationSchema.js +++ b/functions/wordpress/gravityForms/getGfFormValidationSchema.js @@ -1,7 +1,7 @@ +import getGfFieldId from '@/functions/wordpress/gravityForms/getGfFieldId' +import ArraySchemaFactory from '@/functions/wordpress/gravityForms/yupSchema/ArraySchemaFactory' +import StringSchemaFactory from '@/functions/wordpress/gravityForms/yupSchema/StringSchemaFactory' import * as Yup from 'yup' -import getGfFieldId from '@/functions/gravityForms/getGfFieldId' -import StringSchemaFactory from '@/functions/gravityForms/yupSchema/StringSchemaFactory' -import ArraySchemaFactory from '@/functions/gravityForms/yupSchema/ArraySchemaFactory' /** * Match field type with Yup schema object. diff --git a/functions/gravityForms/getHiddenClassName.js b/functions/wordpress/gravityForms/getHiddenClassName.js similarity index 100% rename from functions/gravityForms/getHiddenClassName.js rename to functions/wordpress/gravityForms/getHiddenClassName.js diff --git a/functions/gravityForms/index.js b/functions/wordpress/gravityForms/index.js similarity index 100% rename from functions/gravityForms/index.js rename to functions/wordpress/gravityForms/index.js diff --git a/functions/gravityForms/yupSchema/ArraySchemaFactory.js b/functions/wordpress/gravityForms/yupSchema/ArraySchemaFactory.js similarity index 100% rename from functions/gravityForms/yupSchema/ArraySchemaFactory.js rename to functions/wordpress/gravityForms/yupSchema/ArraySchemaFactory.js diff --git a/functions/gravityForms/yupSchema/StringSchemaFactory.js b/functions/wordpress/gravityForms/yupSchema/StringSchemaFactory.js similarity index 100% rename from functions/gravityForms/yupSchema/StringSchemaFactory.js rename to functions/wordpress/gravityForms/yupSchema/StringSchemaFactory.js diff --git a/lib/wordpress/media/getMediaByID.js b/functions/wordpress/media/getMediaByID.js similarity index 90% rename from lib/wordpress/media/getMediaByID.js rename to functions/wordpress/media/getMediaByID.js index 766b54f51..42a3bea12 100644 --- a/lib/wordpress/media/getMediaByID.js +++ b/functions/wordpress/media/getMediaByID.js @@ -1,5 +1,5 @@ import {initializeWpApollo} from '@/lib/wordpress/connector' -import queryMediaAttributes from './queryMediaAttributes' +import queryMediaAttributes from '@/lib/wordpress/media/queryMediaAttributes' /** * Retrieve media details by ID. diff --git a/functions/filterMenusByLocation.js b/functions/wordpress/menus/filterMenusByLocation.js similarity index 100% rename from functions/filterMenusByLocation.js rename to functions/wordpress/menus/filterMenusByLocation.js diff --git a/functions/formatHeirarchialMenu.js b/functions/wordpress/menus/formatHeirarchialMenu.js similarity index 100% rename from functions/formatHeirarchialMenu.js rename to functions/wordpress/menus/formatHeirarchialMenu.js diff --git a/lib/wordpress/menus/getMenus.js b/functions/wordpress/menus/getMenus.js similarity index 74% rename from lib/wordpress/menus/getMenus.js rename to functions/wordpress/menus/getMenus.js index e5d0095c6..88a101a4c 100644 --- a/lib/wordpress/menus/getMenus.js +++ b/functions/wordpress/menus/getMenus.js @@ -1,7 +1,5 @@ -import filterMenusByLocation from '@/functions/filterMenusByLocation' - -// Define default menu locations. -export const menuLocations = ['primary-menu', 'footer-menu', 'mobile-menu'] +import filterMenusByLocation from '@/functions/wordpress/menus/filterMenusByLocation' +import menuLocations from '@/lib/wordpress/_config/menuLocations' /** * Get menu data from WPGraphQL. diff --git a/lib/wordpress/_global/getFrontendPage.js b/functions/wordpress/postTypes/getFrontendPage.js similarity index 72% rename from lib/wordpress/_global/getFrontendPage.js rename to functions/wordpress/postTypes/getFrontendPage.js index 4d2d0f435..56c08f1a3 100644 --- a/lib/wordpress/_global/getFrontendPage.js +++ b/functions/wordpress/postTypes/getFrontendPage.js @@ -1,27 +1,8 @@ -import formatDefaultSeoData from '@/functions/formatDefaultSeoData' +import getMenus from '@/functions/wordpress/menus/getMenus' +import formatDefaultSeoData from '@/functions/wordpress/seo/formatDefaultSeoData' import {initializeWpApollo} from '@/lib/wordpress/connector' -import getMenus from '@/lib/wordpress/menus/getMenus' -import queryDefaultPageData from './queryDefaultPageData' - -// Define SEO for Frontend routes. -export const frontendPageSeo = { - search: { - title: 'Search', - description: 'Search page' - }, - login: { - title: 'Login', - description: 'Login page' - }, - register: { - title: 'Register', - description: 'Registration page' - }, - profile: { - title: 'Profile', - description: 'Profile page' - } -} +import queryDefaultPageData from '@/lib/wordpress/pages/queryDefaultPageData' +import frontendPageSeo from '@/lib/wordpress/_config/frontendPageSeo' /** * Retrieve data for Frontend-only route (i.e., page does not exist in WordPress). diff --git a/functions/wordpress/postTypes/getHeadlessConfigPage.js b/functions/wordpress/postTypes/getHeadlessConfigPage.js new file mode 100644 index 000000000..38b8cf3f1 --- /dev/null +++ b/functions/wordpress/postTypes/getHeadlessConfigPage.js @@ -0,0 +1,32 @@ +import processPostTypeQuery from '@/functions/wordpress/postTypes/processPostTypeQuery' +import headlessConfigPageQuerySeo from '@/lib/wordpress/_config/headlessConfigPageQuerySeo' + +/** + * Retrieve single page set via Headless Config. + * + * @author WebDevStudios + * @param {string} page Custom page name in config. + * @return {object} Object containing Apollo client instance and post data or error object. + */ +export default async function getHeadlessConfigPage(page) { + // Retrieve page query. + const query = headlessConfigPageQuerySeo?.[page]?.query ?? null + + const data = await processPostTypeQuery('page', page, query) + + // Add custom SEO if missing. + if (!data?.post?.seo) { + data.post = { + ...data?.post, + seo: { + title: `${headlessConfigPageQuerySeo[page]?.title ?? ''} - ${ + data.defaultSeo?.openGraph?.siteName ?? '' + }`, + description: headlessConfigPageQuerySeo[page]?.description ?? '', + canonical: `${data.defaultSeo?.openGraph?.url ?? ''}/${page}` + } + } + } + + return data +} diff --git a/lib/wordpress/_global/getPostTypeArchive.js b/functions/wordpress/postTypes/getPostTypeArchive.js similarity index 83% rename from lib/wordpress/_global/getPostTypeArchive.js rename to functions/wordpress/postTypes/getPostTypeArchive.js index 96cfb40a0..b8da3f753 100644 --- a/lib/wordpress/_global/getPostTypeArchive.js +++ b/functions/wordpress/postTypes/getPostTypeArchive.js @@ -1,24 +1,9 @@ -import formatArchiveSeoData from '@/functions/formatArchiveSeoData' -import formatDefaultSeoData from '@/functions/formatDefaultSeoData' +import getMenus from '@/functions/wordpress/menus/getMenus' +import formatArchiveSeoData from '@/functions/wordpress/seo/formatArchiveSeoData' +import formatDefaultSeoData from '@/functions/wordpress/seo/formatDefaultSeoData' import {initializeWpApollo} from '@/lib/wordpress/connector' -import getMenus from '@/lib/wordpress/menus/getMenus' -import queryPostsArchive from '@/lib/wordpress/posts/queryPostsArchive' -import queryTeamsArchive from '@/lib/wordpress/teams/queryTeamsArchive' -import {postTypes} from './postTypes' - -// Define SEO for archives. -export const archiveQuerySeo = { - post: { - query: queryPostsArchive, - title: 'Blog', - description: '' - }, - team: { - query: queryTeamsArchive, - title: 'Team Members', - description: '' - } -} +import archiveQuerySeo from '@/lib/wordpress/_config/archiveQuerySeo' +import {postTypes} from '@/lib/wordpress/_config/postTypes' /** * Retrieve post archive. diff --git a/lib/wordpress/_global/getPostTypeById.js b/functions/wordpress/postTypes/getPostTypeById.js similarity index 87% rename from lib/wordpress/_global/getPostTypeById.js rename to functions/wordpress/postTypes/getPostTypeById.js index 5616957f8..6f47f052f 100644 --- a/lib/wordpress/_global/getPostTypeById.js +++ b/functions/wordpress/postTypes/getPostTypeById.js @@ -1,8 +1,8 @@ +import isHierarchicalPostType from '@/functions/wordpress/postTypes/isHierarchicalPostType' +import processPostTypeQuery from '@/functions/wordpress/postTypes/processPostTypeQuery' import queryPageById from '@/lib/wordpress/pages/queryPageById' import queryPostById from '@/lib/wordpress/posts/queryPostById' import queryTeamById from '@/lib/wordpress/teams/queryTeamById' -import {isHierarchicalPostType} from './postTypes' -import processPostTypeQuery from './processPostTypeQuery' /** * Retrieve single post by specified identifier. diff --git a/lib/wordpress/_global/getPostTypeStaticPaths.js b/functions/wordpress/postTypes/getPostTypeStaticPaths.js similarity index 85% rename from lib/wordpress/_global/getPostTypeStaticPaths.js rename to functions/wordpress/postTypes/getPostTypeStaticPaths.js index 25b1bebf6..21b053b98 100644 --- a/lib/wordpress/_global/getPostTypeStaticPaths.js +++ b/functions/wordpress/postTypes/getPostTypeStaticPaths.js @@ -1,13 +1,15 @@ +import isHierarchicalPostType from '@/functions/wordpress/postTypes/isHierarchicalPostType' +import isValidPostType from '@/functions/wordpress/postTypes/isValidPostType' import {initializeWpApollo} from '@/lib/wordpress/connector' +import {postTypes} from '@/lib/wordpress/_config/postTypes' import {gql} from '@apollo/client' -import {isHierarchicalPostType, isValidPostType, postTypes} from './postTypes' /** * Retrieve static paths by post type. * * @author WebDevStudios * @param {string} postType WP post type. - * @return {object} Post type paths. + * @return {object} Post type paths. */ export default async function getPostTypeStaticPaths(postType) { if (!postType || !isValidPostType(postType)) { diff --git a/lib/wordpress/_global/getPostTypeStaticProps.js b/functions/wordpress/postTypes/getPostTypeStaticProps.js similarity index 84% rename from lib/wordpress/_global/getPostTypeStaticProps.js rename to functions/wordpress/postTypes/getPostTypeStaticProps.js index dbd11473e..1c1821deb 100644 --- a/lib/wordpress/_global/getPostTypeStaticProps.js +++ b/functions/wordpress/postTypes/getPostTypeStaticProps.js @@ -1,12 +1,13 @@ +import getFrontendPage from '@/functions/wordpress/postTypes/getFrontendPage' +import getHeadlessConfigPage from '@/functions/wordpress/postTypes/getHeadlessConfigPage' +import getPostTypeArchive from '@/functions/wordpress/postTypes/getPostTypeArchive' +import getPostTypeById from '@/functions/wordpress/postTypes/getPostTypeById' +import getPostTypeTaxonomyArchive from '@/functions/wordpress/postTypes/getPostTypeTaxonomyArchive' import {algoliaIndexName} from '@/lib/algolia/connector' import {addApolloState} from '@/lib/apolloConfig' -import getFrontendPage, {frontendPageSeo} from './getFrontendPage' -import getPostTypeArchive, {archiveQuerySeo} from './getPostTypeArchive' -import getPostTypeById from './getPostTypeById' -import getPostTypeTaxonomyArchive from './getPostTypeTaxonomyArchive' -import getSettingsCustomPage, { - customPageQuerySeo -} from './getSettingsCustomPage' +import archiveQuerySeo from '@/lib/wordpress/_config/archiveQuerySeo' +import frontendPageSeo from '@/lib/wordpress/_config/frontendPageSeo' +import headlessConfigPageQuerySeo from '@/lib/wordpress/_config/headlessConfigPageQuerySeo' /** * Retrieve static props by post type. @@ -106,8 +107,8 @@ export default async function getPostTypeStaticProps( const slug = Array.isArray(params.slug) ? params.slug.join('/') : params.slug /* -- Handle pages set via Additional Settings. -- */ - if (Object.keys(customPageQuerySeo).includes(slug)) { - const {apolloClient, ...pageData} = await getSettingsCustomPage(slug) + if (Object.keys(headlessConfigPageQuerySeo).includes(slug)) { + const {apolloClient, ...pageData} = await getHeadlessConfigPage(slug) // Display 404 error page if error encountered. if (pageData.error && '404' !== slug) { diff --git a/lib/wordpress/_global/getPostTypeTaxonomyArchive.js b/functions/wordpress/postTypes/getPostTypeTaxonomyArchive.js similarity index 95% rename from lib/wordpress/_global/getPostTypeTaxonomyArchive.js rename to functions/wordpress/postTypes/getPostTypeTaxonomyArchive.js index 7ac35ba94..f02bcd2e1 100644 --- a/lib/wordpress/_global/getPostTypeTaxonomyArchive.js +++ b/functions/wordpress/postTypes/getPostTypeTaxonomyArchive.js @@ -1,9 +1,9 @@ -import formatDefaultSeoData from '@/functions/formatDefaultSeoData' +import getMenus from '@/functions/wordpress/menus/getMenus' +import formatDefaultSeoData from '@/functions/wordpress/seo/formatDefaultSeoData' import queryPostsByCategory from '@/lib/wordpress/categories/queryPostsByCategory' import {initializeWpApollo} from '@/lib/wordpress/connector' -import getMenus from '@/lib/wordpress/menus/getMenus' import queryPostsByTag from '@/lib/wordpress/tags/queryPostsByTag' -import {postTypes} from './postTypes' +import {postTypes} from '@/lib/wordpress/_config/postTypes' /** * Retrieve post taxnomy archive. diff --git a/functions/wordpress/postTypes/isHierarchicalPostType.js b/functions/wordpress/postTypes/isHierarchicalPostType.js new file mode 100644 index 000000000..dbaf72865 --- /dev/null +++ b/functions/wordpress/postTypes/isHierarchicalPostType.js @@ -0,0 +1,12 @@ +import {hierarchicalPostTypes} from '@/lib/wordpress/_config/postTypes' + +/** + * Check if post type is hierarchical. + * + * @author WebDevStudios + * @param {string} postType WP post type. + * @return {boolean} Whether provided post type is hierarchical. + */ +export default function isHierarchicalPostType(postType) { + return hierarchicalPostTypes.includes(postType) +} diff --git a/functions/wordpress/postTypes/isValidPostType.js b/functions/wordpress/postTypes/isValidPostType.js new file mode 100644 index 000000000..bccf140e5 --- /dev/null +++ b/functions/wordpress/postTypes/isValidPostType.js @@ -0,0 +1,11 @@ +import {postTypes} from '@/lib/wordpress/_config/postTypes' +/** + * Check if post type is valid. + * + * @author WebDevStudios + * @param {string} postType WP post type. + * @return {boolean} Whether provided post type is valid. + */ +export default function isValidPostType(postType) { + return Object.keys(postTypes).includes(postType) +} diff --git a/lib/wordpress/_global/processPostTypeQuery.js b/functions/wordpress/postTypes/processPostTypeQuery.js similarity index 92% rename from lib/wordpress/_global/processPostTypeQuery.js rename to functions/wordpress/postTypes/processPostTypeQuery.js index 33f6f48e1..2c524b7e8 100644 --- a/lib/wordpress/_global/processPostTypeQuery.js +++ b/functions/wordpress/postTypes/processPostTypeQuery.js @@ -1,10 +1,10 @@ -import formatBlockData from '@/functions/formatBlockData' -import formatDefaultSeoData from '@/functions/formatDefaultSeoData' +import formatBlockData from '@/functions/wordpress/blocks/formatBlockData' +import getMenus from '@/functions/wordpress/menus/getMenus' +import formatDefaultSeoData from '@/functions/wordpress/seo/formatDefaultSeoData' import { createWpApolloClient, initializeWpApollo } from '@/lib/wordpress/connector' -import getMenus from '@/lib/wordpress/menus/getMenus' /** * Retrieve single post. diff --git a/functions/formatArchiveSeoData.js b/functions/wordpress/seo/formatArchiveSeoData.js similarity index 95% rename from functions/formatArchiveSeoData.js rename to functions/wordpress/seo/formatArchiveSeoData.js index 54d10f649..894637a59 100644 --- a/functions/formatArchiveSeoData.js +++ b/functions/wordpress/seo/formatArchiveSeoData.js @@ -1,4 +1,4 @@ -import {postTypes} from '@/lib/wordpress/_global/postTypes' +import {postTypes} from '@/lib/wordpress/_config/postTypes' /** * Format archive SEO data. diff --git a/functions/formatDefaultSeoData.js b/functions/wordpress/seo/formatDefaultSeoData.js similarity index 100% rename from functions/formatDefaultSeoData.js rename to functions/wordpress/seo/formatDefaultSeoData.js diff --git a/lib/next-api/wordpress/comments/mutationAddComment.js b/lib/next-api/wordpress/comments/mutationAddComment.js index 589872d79..5a9547e73 100644 --- a/lib/next-api/wordpress/comments/mutationAddComment.js +++ b/lib/next-api/wordpress/comments/mutationAddComment.js @@ -1,5 +1,5 @@ import {nextApiRoutes} from '@/lib/next-api/connector' -import commentsFields from '@/lib/wordpress/_partials/commentsFields' +import commentsFields from '@/lib/wordpress/_query-partials/commentsFields' import {gql} from '@apollo/client' // Mutation: Add a comment to the given post. diff --git a/lib/wordpress/_config/archiveQuerySeo.js b/lib/wordpress/_config/archiveQuerySeo.js new file mode 100644 index 000000000..a454bee9b --- /dev/null +++ b/lib/wordpress/_config/archiveQuerySeo.js @@ -0,0 +1,18 @@ +import queryPostsArchive from '@/lib/wordpress/posts/queryPostsArchive' +import queryTeamsArchive from '@/lib/wordpress/teams/queryTeamsArchive' + +// Define SEO for archives. +const archiveQuerySeo = { + post: { + query: queryPostsArchive, + title: 'Blog', + description: '' + }, + team: { + query: queryTeamsArchive, + title: 'Team Members', + description: '' + } +} + +export default archiveQuerySeo diff --git a/lib/wordpress/_config/frontendPageSeo.js b/lib/wordpress/_config/frontendPageSeo.js new file mode 100644 index 000000000..f5586d199 --- /dev/null +++ b/lib/wordpress/_config/frontendPageSeo.js @@ -0,0 +1,21 @@ +// Define SEO for Frontend routes. +const frontendPageSeo = { + search: { + title: 'Search', + description: 'Search page' + }, + login: { + title: 'Login', + description: 'Login page' + }, + register: { + title: 'Register', + description: 'Registration page' + }, + profile: { + title: 'Profile', + description: 'Profile page' + } +} + +export default frontendPageSeo diff --git a/lib/wordpress/_config/headlessConfigPageQuerySeo.js b/lib/wordpress/_config/headlessConfigPageQuerySeo.js new file mode 100644 index 000000000..9a5a7be64 --- /dev/null +++ b/lib/wordpress/_config/headlessConfigPageQuerySeo.js @@ -0,0 +1,12 @@ +import queryError404Page from '@/lib/wordpress/pages/queryError404Page' + +// Define single page query based on page name. +const headlessConfigPageQuerySeo = { + 404: { + query: queryError404Page, + title: '404 Not Found', + description: '' + } +} + +export default headlessConfigPageQuerySeo diff --git a/lib/wordpress/_config/menuLocations.js b/lib/wordpress/_config/menuLocations.js new file mode 100644 index 000000000..b766083b7 --- /dev/null +++ b/lib/wordpress/_config/menuLocations.js @@ -0,0 +1,4 @@ +// Define default menu locations. +const menuLocations = ['primary-menu', 'footer-menu', 'mobile-menu'] + +export default menuLocations diff --git a/lib/wordpress/_config/postTypes.js b/lib/wordpress/_config/postTypes.js new file mode 100644 index 000000000..f3bdb752a --- /dev/null +++ b/lib/wordpress/_config/postTypes.js @@ -0,0 +1,18 @@ +// Define valid WP post types (singular and plural GraphQL names). +export const postTypes = { + page: { + pluralName: 'pages', + route: '' + }, + post: { + pluralName: 'posts', + route: 'blog' + }, + team: { + pluralName: 'teams', + route: 'team' + } +} + +// Define hierarchical post types. +export const hierarchicalPostTypes = ['page'] diff --git a/lib/wordpress/_global/getSettingsCustomPage.js b/lib/wordpress/_global/getSettingsCustomPage.js deleted file mode 100644 index 0fbac4cc2..000000000 --- a/lib/wordpress/_global/getSettingsCustomPage.js +++ /dev/null @@ -1,41 +0,0 @@ -import queryError404Page from '@/lib/wordpress/pages/queryError404Page' -import processPostTypeQuery from './processPostTypeQuery' - -// Define single page query based on page name. -export const customPageQuerySeo = { - 404: { - query: queryError404Page, - title: '404 Not Found', - description: '' - } -} - -/** - * Retrieve single page set via Additional Settings. - * - * @author WebDevStudios - * @param {string} page Custom page name in settings. - * @return {object} Object containing Apollo client instance and post data or error object. - */ -export default async function getSettingsCustomPage(page) { - // Retrieve page query. - const query = customPageQuerySeo?.[page]?.query ?? null - - const data = await processPostTypeQuery('page', page, query) - - // Add custom SEO if missing. - if (!data?.post?.seo) { - data.post = { - ...data?.post, - seo: { - title: `${customPageQuerySeo[page]?.title ?? ''} - ${ - data.defaultSeo?.openGraph?.siteName ?? '' - }`, - description: customPageQuerySeo[page]?.description ?? '', - canonical: `${data.defaultSeo?.openGraph?.url ?? ''}/${page}` - } - } - } - - return data -} diff --git a/lib/wordpress/_global/postTypes.js b/lib/wordpress/_global/postTypes.js deleted file mode 100644 index 7799ffda3..000000000 --- a/lib/wordpress/_global/postTypes.js +++ /dev/null @@ -1,40 +0,0 @@ -// Define valid WP post types (singular and plural GraphQL names). -export const postTypes = { - page: { - pluralName: 'pages', - route: '' - }, - post: { - pluralName: 'posts', - route: 'blog' - }, - team: { - pluralName: 'teams', - route: 'team' - } -} - -// Define hierarchical post types. -export const hierarchicalPostTypes = ['page'] - -/** - * Check if post type is valid. - * - * @author WebDevStudios - * @param {string} postType WP post type. - * @return {boolean} Whether provided post type is valid. - */ -export function isValidPostType(postType) { - return Object.keys(postTypes).includes(postType) -} - -/** - * Check if post type is hierarchical. - * - * @author WebDevStudios - * @param {string} postType WP post type. - * @return {boolean} Whether provided post type is hierarchical. - */ -export function isHierarchicalPostType(postType) { - return hierarchicalPostTypes.includes(postType) -} diff --git a/lib/wordpress/_partials/allMenus.js b/lib/wordpress/_query-partials/allMenus.js similarity index 100% rename from lib/wordpress/_partials/allMenus.js rename to lib/wordpress/_query-partials/allMenus.js diff --git a/lib/wordpress/_partials/archiveData.js b/lib/wordpress/_query-partials/archiveData.js similarity index 100% rename from lib/wordpress/_partials/archiveData.js rename to lib/wordpress/_query-partials/archiveData.js diff --git a/lib/wordpress/_partials/archivePageInfo.js b/lib/wordpress/_query-partials/archivePageInfo.js similarity index 100% rename from lib/wordpress/_partials/archivePageInfo.js rename to lib/wordpress/_query-partials/archivePageInfo.js diff --git a/lib/wordpress/_partials/archiveSeo.js b/lib/wordpress/_query-partials/archiveSeo.js similarity index 100% rename from lib/wordpress/_partials/archiveSeo.js rename to lib/wordpress/_query-partials/archiveSeo.js diff --git a/lib/wordpress/_partials/authorPostFields.js b/lib/wordpress/_query-partials/authorPostFields.js similarity index 100% rename from lib/wordpress/_partials/authorPostFields.js rename to lib/wordpress/_query-partials/authorPostFields.js diff --git a/lib/wordpress/_partials/categoriesPostFields.js b/lib/wordpress/_query-partials/categoriesPostFields.js similarity index 100% rename from lib/wordpress/_partials/categoriesPostFields.js rename to lib/wordpress/_query-partials/categoriesPostFields.js diff --git a/lib/wordpress/_partials/commentsFields.js b/lib/wordpress/_query-partials/commentsFields.js similarity index 100% rename from lib/wordpress/_partials/commentsFields.js rename to lib/wordpress/_query-partials/commentsFields.js diff --git a/lib/wordpress/_partials/commentsPostFields.js b/lib/wordpress/_query-partials/commentsPostFields.js similarity index 100% rename from lib/wordpress/_partials/commentsPostFields.js rename to lib/wordpress/_query-partials/commentsPostFields.js diff --git a/lib/wordpress/_partials/defaultPageData.js b/lib/wordpress/_query-partials/defaultPageData.js similarity index 100% rename from lib/wordpress/_partials/defaultPageData.js rename to lib/wordpress/_query-partials/defaultPageData.js diff --git a/lib/wordpress/_partials/defaultSeoFields.js b/lib/wordpress/_query-partials/defaultSeoFields.js similarity index 100% rename from lib/wordpress/_partials/defaultSeoFields.js rename to lib/wordpress/_query-partials/defaultSeoFields.js diff --git a/lib/wordpress/_partials/featuredImagePostFields.js b/lib/wordpress/_query-partials/featuredImagePostFields.js similarity index 100% rename from lib/wordpress/_partials/featuredImagePostFields.js rename to lib/wordpress/_query-partials/featuredImagePostFields.js diff --git a/lib/wordpress/_partials/globalPostFields.js b/lib/wordpress/_query-partials/globalPostFields.js similarity index 100% rename from lib/wordpress/_partials/globalPostFields.js rename to lib/wordpress/_query-partials/globalPostFields.js diff --git a/lib/wordpress/_partials/seoPostFields.js b/lib/wordpress/_query-partials/seoPostFields.js similarity index 100% rename from lib/wordpress/_partials/seoPostFields.js rename to lib/wordpress/_query-partials/seoPostFields.js diff --git a/lib/wordpress/_partials/tagsPostFields.js b/lib/wordpress/_query-partials/tagsPostFields.js similarity index 100% rename from lib/wordpress/_partials/tagsPostFields.js rename to lib/wordpress/_query-partials/tagsPostFields.js diff --git a/lib/wordpress/users/mutationLoginUser.js b/lib/wordpress/auth/mutationLoginUser.js similarity index 100% rename from lib/wordpress/users/mutationLoginUser.js rename to lib/wordpress/auth/mutationLoginUser.js diff --git a/lib/wordpress/users/mutationRefreshAuthToken.js b/lib/wordpress/auth/mutationRefreshAuthToken.js similarity index 100% rename from lib/wordpress/users/mutationRefreshAuthToken.js rename to lib/wordpress/auth/mutationRefreshAuthToken.js diff --git a/lib/wordpress/users/mutationRegisterUser.js b/lib/wordpress/auth/mutationRegisterUser.js similarity index 100% rename from lib/wordpress/users/mutationRegisterUser.js rename to lib/wordpress/auth/mutationRegisterUser.js diff --git a/lib/wordpress/categories/queryPostsByCategory.js b/lib/wordpress/categories/queryPostsByCategory.js index 7acc76a3e..89b830e6d 100644 --- a/lib/wordpress/categories/queryPostsByCategory.js +++ b/lib/wordpress/categories/queryPostsByCategory.js @@ -2,8 +2,8 @@ import { archivePostFragment, archivePosts } from '@/lib/wordpress/posts/queryPostsArchive' -import defaultPageData from '@/lib/wordpress/_partials/defaultPageData' -import seoPostFields from '@/lib/wordpress/_partials/seoPostFields' +import defaultPageData from '@/lib/wordpress/_query-partials/defaultPageData' +import seoPostFields from '@/lib/wordpress/_query-partials/seoPostFields' import {gql} from '@apollo/client' // Query: retrieve posts category archive. diff --git a/lib/wordpress/comments/mutationInsertComment.js b/lib/wordpress/comments/mutationInsertComment.js index 64e3fcb40..d7d32a248 100644 --- a/lib/wordpress/comments/mutationInsertComment.js +++ b/lib/wordpress/comments/mutationInsertComment.js @@ -1,4 +1,4 @@ -import commentsFields from '@/lib/wordpress/_partials/commentsFields' +import commentsFields from '@/lib/wordpress/_query-partials/commentsFields' import {gql} from '@apollo/client' // Mutation: Add a comment to the given post. diff --git a/lib/wordpress/comments/queryCommentsByPostId.js b/lib/wordpress/comments/queryCommentsByPostId.js index 123fcc012..7562814cc 100644 --- a/lib/wordpress/comments/queryCommentsByPostId.js +++ b/lib/wordpress/comments/queryCommentsByPostId.js @@ -1,5 +1,5 @@ -import archivePageInfo from '@/lib/wordpress/_partials/archivePageInfo' -import commentsFields from '@/lib/wordpress/_partials/commentsFields' +import archivePageInfo from '@/lib/wordpress/_query-partials/archivePageInfo' +import commentsFields from '@/lib/wordpress/_query-partials/commentsFields' import {gql} from '@apollo/client' // Query: retrieve comments by post databaseId. diff --git a/lib/wordpress/_global/queryDefaultPageData.js b/lib/wordpress/pages/queryDefaultPageData.js similarity index 73% rename from lib/wordpress/_global/queryDefaultPageData.js rename to lib/wordpress/pages/queryDefaultPageData.js index cf6af2f4e..690f6d3de 100644 --- a/lib/wordpress/_global/queryDefaultPageData.js +++ b/lib/wordpress/pages/queryDefaultPageData.js @@ -1,4 +1,4 @@ -import defaultPageData from '@/lib/wordpress/_partials/defaultPageData' +import defaultPageData from '@/lib/wordpress/_query-partials/defaultPageData' import {gql} from '@apollo/client' // Query: retrieve default SEO and other page data. diff --git a/lib/wordpress/pages/queryError404Page.js b/lib/wordpress/pages/queryError404Page.js index 37c500f4e..eed353eef 100644 --- a/lib/wordpress/pages/queryError404Page.js +++ b/lib/wordpress/pages/queryError404Page.js @@ -1,4 +1,4 @@ -import defaultPageData from '@/lib/wordpress/_partials/defaultPageData' +import defaultPageData from '@/lib/wordpress/_query-partials/defaultPageData' import {gql} from '@apollo/client' import {singlePageFragment} from './queryPageById' diff --git a/lib/wordpress/pages/queryPageById.js b/lib/wordpress/pages/queryPageById.js index 798195675..2cda657aa 100644 --- a/lib/wordpress/pages/queryPageById.js +++ b/lib/wordpress/pages/queryPageById.js @@ -1,8 +1,8 @@ -import authorPostFields from '@/lib/wordpress/_partials/authorPostFields' -import defaultPageData from '@/lib/wordpress/_partials/defaultPageData' -import featuredImagePostFields from '@/lib/wordpress/_partials/featuredImagePostFields' -import globalPostFields from '@/lib/wordpress/_partials/globalPostFields' -import seoPostFields from '@/lib/wordpress/_partials/seoPostFields' +import authorPostFields from '@/lib/wordpress/_query-partials/authorPostFields' +import defaultPageData from '@/lib/wordpress/_query-partials/defaultPageData' +import featuredImagePostFields from '@/lib/wordpress/_query-partials/featuredImagePostFields' +import globalPostFields from '@/lib/wordpress/_query-partials/globalPostFields' +import seoPostFields from '@/lib/wordpress/_query-partials/seoPostFields' import {gql} from '@apollo/client' // Fragment: retrieve single page fields. diff --git a/lib/wordpress/posts/queryPostById.js b/lib/wordpress/posts/queryPostById.js index 283ce0fe7..22515209f 100644 --- a/lib/wordpress/posts/queryPostById.js +++ b/lib/wordpress/posts/queryPostById.js @@ -1,11 +1,11 @@ -import authorPostFields from '@/lib/wordpress/_partials/authorPostFields' -import categoriesPostFields from '@/lib/wordpress/_partials/categoriesPostFields' -import commentsPostFields from '@/lib/wordpress/_partials/commentsPostFields' -import defaultPageData from '@/lib/wordpress/_partials/defaultPageData' -import featuredImagePostFields from '@/lib/wordpress/_partials/featuredImagePostFields' -import globalPostFields from '@/lib/wordpress/_partials/globalPostFields' -import seoPostFields from '@/lib/wordpress/_partials/seoPostFields' -import tagsPostFields from '@/lib/wordpress/_partials/tagsPostFields' +import authorPostFields from '@/lib/wordpress/_query-partials/authorPostFields' +import categoriesPostFields from '@/lib/wordpress/_query-partials/categoriesPostFields' +import commentsPostFields from '@/lib/wordpress/_query-partials/commentsPostFields' +import defaultPageData from '@/lib/wordpress/_query-partials/defaultPageData' +import featuredImagePostFields from '@/lib/wordpress/_query-partials/featuredImagePostFields' +import globalPostFields from '@/lib/wordpress/_query-partials/globalPostFields' +import seoPostFields from '@/lib/wordpress/_query-partials/seoPostFields' +import tagsPostFields from '@/lib/wordpress/_query-partials/tagsPostFields' import {gql} from '@apollo/client' // Fragment: retrieve single post fields. diff --git a/lib/wordpress/posts/queryPostsArchive.js b/lib/wordpress/posts/queryPostsArchive.js index f005df9a6..fa381d802 100644 --- a/lib/wordpress/posts/queryPostsArchive.js +++ b/lib/wordpress/posts/queryPostsArchive.js @@ -1,8 +1,8 @@ -import archivePageInfo from '@/lib/wordpress/_partials/archivePageInfo' -import defaultPageData from '@/lib/wordpress/_partials/defaultPageData' -import featuredImagePostFields from '@/lib/wordpress/_partials/featuredImagePostFields' -import globalPostFields from '@/lib/wordpress/_partials/globalPostFields' -import seoPostFields from '@/lib/wordpress/_partials/seoPostFields' +import archivePageInfo from '@/lib/wordpress/_query-partials/archivePageInfo' +import defaultPageData from '@/lib/wordpress/_query-partials/defaultPageData' +import featuredImagePostFields from '@/lib/wordpress/_query-partials/featuredImagePostFields' +import globalPostFields from '@/lib/wordpress/_query-partials/globalPostFields' +import seoPostFields from '@/lib/wordpress/_query-partials/seoPostFields' import {gql} from '@apollo/client' // Fragment: retrieve archive post fields. diff --git a/lib/wordpress/tags/queryPostsByTag.js b/lib/wordpress/tags/queryPostsByTag.js index 223e258de..ea0a8575d 100644 --- a/lib/wordpress/tags/queryPostsByTag.js +++ b/lib/wordpress/tags/queryPostsByTag.js @@ -2,8 +2,8 @@ import { archivePostFragment, archivePosts } from '@/lib/wordpress/posts/queryPostsArchive' -import defaultPageData from '@/lib/wordpress/_partials/defaultPageData' -import seoPostFields from '@/lib/wordpress/_partials/seoPostFields' +import defaultPageData from '@/lib/wordpress/_query-partials/defaultPageData' +import seoPostFields from '@/lib/wordpress/_query-partials/seoPostFields' import {gql} from '@apollo/client' // Query: retrieve posts tag archive. diff --git a/lib/wordpress/teams/queryTeamById.js b/lib/wordpress/teams/queryTeamById.js index db1d8ebf2..1c861a8d8 100644 --- a/lib/wordpress/teams/queryTeamById.js +++ b/lib/wordpress/teams/queryTeamById.js @@ -1,8 +1,8 @@ -import authorPostFields from '@/lib/wordpress/_partials/authorPostFields' -import defaultPageData from '@/lib/wordpress/_partials/defaultPageData' -import featuredImagePostFields from '@/lib/wordpress/_partials/featuredImagePostFields' -import globalPostFields from '@/lib/wordpress/_partials/globalPostFields' -import seoPostFields from '@/lib/wordpress/_partials/seoPostFields' +import authorPostFields from '@/lib/wordpress/_query-partials/authorPostFields' +import defaultPageData from '@/lib/wordpress/_query-partials/defaultPageData' +import featuredImagePostFields from '@/lib/wordpress/_query-partials/featuredImagePostFields' +import globalPostFields from '@/lib/wordpress/_query-partials/globalPostFields' +import seoPostFields from '@/lib/wordpress/_query-partials/seoPostFields' import {gql} from '@apollo/client' // Fragment: retrieve single team member fields. diff --git a/lib/wordpress/teams/queryTeamsArchive.js b/lib/wordpress/teams/queryTeamsArchive.js index 013522f42..c919d57ad 100644 --- a/lib/wordpress/teams/queryTeamsArchive.js +++ b/lib/wordpress/teams/queryTeamsArchive.js @@ -1,7 +1,7 @@ -import archiveData from '@/lib/wordpress/_partials/archiveData' -import defaultPageData from '@/lib/wordpress/_partials/defaultPageData' -import featuredImagePostFields from '@/lib/wordpress/_partials/featuredImagePostFields' -import globalPostFields from '@/lib/wordpress/_partials/globalPostFields' +import archiveData from '@/lib/wordpress/_query-partials/archiveData' +import defaultPageData from '@/lib/wordpress/_query-partials/defaultPageData' +import featuredImagePostFields from '@/lib/wordpress/_query-partials/featuredImagePostFields' +import globalPostFields from '@/lib/wordpress/_query-partials/globalPostFields' import {gql} from '@apollo/client' // Fragment: retrieve archive team fields. diff --git a/next.config.js b/next.config.js index 2e14ee762..e9130b8a9 100644 --- a/next.config.js +++ b/next.config.js @@ -1,5 +1,9 @@ module.exports = { images: { domains: process.env.NEXT_PUBLIC_IMAGE_DOMAINS.split(', ') + }, + i18n: { + locales: ['en-US'], + defaultLocale: 'en-US' } } diff --git a/pages/404.js b/pages/404.js index dcade54d7..9399151ae 100644 --- a/pages/404.js +++ b/pages/404.js @@ -1,7 +1,7 @@ import Container from '@/components/atoms/Container' import Layout from '@/components/common/Layout' import getPagePropTypes from '@/functions/getPagePropTypes' -import getPostTypeStaticProps from '@/lib/wordpress/_global/getPostTypeStaticProps' +import getPostTypeStaticProps from '@/functions/wordpress/postTypes/getPostTypeStaticProps' import Page from './[...slug]' // Define route post type. diff --git a/pages/[...slug].js b/pages/[...slug].js index 3efdc44e2..4694d0709 100644 --- a/pages/[...slug].js +++ b/pages/[...slug].js @@ -3,8 +3,8 @@ import RichText from '@/components/atoms/RichText' import Layout from '@/components/common/Layout' import Blocks from '@/components/molecules/Blocks' import getPagePropTypes from '@/functions/getPagePropTypes' -import getPostTypeStaticPaths from '@/lib/wordpress/_global/getPostTypeStaticPaths' -import getPostTypeStaticProps from '@/lib/wordpress/_global/getPostTypeStaticProps' +import getPostTypeStaticPaths from '@/functions/wordpress/postTypes/getPostTypeStaticPaths' +import getPostTypeStaticProps from '@/functions/wordpress/postTypes/getPostTypeStaticProps' // Define route post type. const postType = 'page' diff --git a/pages/_document.js b/pages/_document.js deleted file mode 100644 index cef5846d4..000000000 --- a/pages/_document.js +++ /dev/null @@ -1,15 +0,0 @@ -import Document, {Head, Main, NextScript, Html} from 'next/document' - -export default class MyDocument extends Document { - render() { - return ( - -
- -