diff --git a/.github/workflows/nextjs-bundle-analysis.yml b/.github/workflows/nextjs-bundle-analysis.yml
index dd46bd502..3bf05b303 100644
--- a/.github/workflows/nextjs-bundle-analysis.yml
+++ b/.github/workflows/nextjs-bundle-analysis.yml
@@ -21,7 +21,10 @@ jobs:
analyze:
strategy:
matrix:
- next-dir: ['examples/next/faustwp-getting-started']
+ next-dir: [
+ 'examples/next/faustwp-getting-started',
+ 'examples/next/block-support'
+ ]
runs-on: ubuntu-latest
steps:
diff --git a/examples/next/block-support/.env.local.sample b/examples/next/block-support/.env.local.sample
new file mode 100644
index 000000000..dc631ae73
--- /dev/null
+++ b/examples/next/block-support/.env.local.sample
@@ -0,0 +1,5 @@
+# Your WordPress site URL
+NEXT_PUBLIC_WORDPRESS_URL=https://faustexample.wpengine.com
+
+# Plugin secret found in WordPress Settings->Faust
+# FAUST_SECRET_KEY=YOUR_PLUGIN_SECRET
diff --git a/examples/next/block-support/.gitignore b/examples/next/block-support/.gitignore
new file mode 100644
index 000000000..52236bdd5
--- /dev/null
+++ b/examples/next/block-support/.gitignore
@@ -0,0 +1,2 @@
+possibleTypes.json
+globalStylesheet.css
diff --git a/examples/next/block-support/README.md b/examples/next/block-support/README.md
new file mode 100644
index 000000000..02038a0ef
--- /dev/null
+++ b/examples/next/block-support/README.md
@@ -0,0 +1,3 @@
+# @faustwp/block-support-example
+
+Example showcasing Faust.js block editor support.
diff --git a/examples/next/block-support/faust.config.js b/examples/next/block-support/faust.config.js
new file mode 100644
index 000000000..c6478a6d6
--- /dev/null
+++ b/examples/next/block-support/faust.config.js
@@ -0,0 +1,12 @@
+import { setConfig } from '@faustwp/core';
+import templates from './wp-templates';
+import possibleTypes from './possibleTypes.json';
+
+/**
+ * @type {import('@faustwp/core').FaustConfig}
+ **/
+export default setConfig({
+ templates,
+ experimentalPlugins: [],
+ possibleTypes,
+});
diff --git a/examples/next/block-support/next.config.js b/examples/next/block-support/next.config.js
new file mode 100644
index 000000000..671f1eca0
--- /dev/null
+++ b/examples/next/block-support/next.config.js
@@ -0,0 +1,18 @@
+const { withFaust, getWpHostname } = require('@faustwp/core');
+
+/**
+ * @type {import('next').NextConfig}
+ **/
+module.exports = withFaust({
+ reactStrictMode: true,
+ sassOptions: {
+ includePaths: ['node_modules'],
+ },
+ images: {
+ domains: [getWpHostname()],
+ },
+ i18n: {
+ locales: ['en'],
+ defaultLocale: 'en',
+ },
+});
diff --git a/examples/next/block-support/package.json b/examples/next/block-support/package.json
new file mode 100644
index 000000000..1104ac5df
--- /dev/null
+++ b/examples/next/block-support/package.json
@@ -0,0 +1,30 @@
+{
+ "name": "@faustwp/block-support-example",
+ "private": true,
+ "version": "0.1.0",
+ "scripts": {
+ "predev": "faust generatePossibleTypes && faust generateGlobalStylesheet",
+ "prebuild": "faust generatePossibleTypes && faust generateGlobalStylesheet",
+ "dev": "faust dev",
+ "build": "faust build",
+ "start": "faust start"
+ },
+ "dependencies": {
+ "@apollo/client": "^3.6.6",
+ "@faustwp/blocks": "2.0.0",
+ "@faustwp/cli": "1.0.1",
+ "@faustwp/core": "1.1.0",
+ "@wordpress/base-styles": "^4.26.0",
+ "@wordpress/block-library": "^7.19.0",
+ "classnames": "^2.3.1",
+ "graphql": "^16.6.0",
+ "next": "^12.1.6",
+ "react": "^17.0.2",
+ "react-dom": "^17.0.2",
+ "sass": "^1.54.9"
+ },
+ "engines": {
+ "node": ">=16",
+ "npm": ">=8"
+ }
+}
diff --git a/examples/next/block-support/pages/[...wordpressNode].js b/examples/next/block-support/pages/[...wordpressNode].js
new file mode 100644
index 000000000..fe51bbcc9
--- /dev/null
+++ b/examples/next/block-support/pages/[...wordpressNode].js
@@ -0,0 +1,16 @@
+import { getWordPressProps, WordPressTemplate } from '@faustwp/core';
+
+export default function Page(props) {
+ return ;
+}
+
+export function getStaticProps(ctx) {
+ return getWordPressProps({ ctx });
+}
+
+export async function getStaticPaths() {
+ return {
+ paths: [],
+ fallback: 'blocking',
+ };
+}
diff --git a/examples/next/block-support/pages/_app.js b/examples/next/block-support/pages/_app.js
new file mode 100644
index 000000000..e427cb2df
--- /dev/null
+++ b/examples/next/block-support/pages/_app.js
@@ -0,0 +1,24 @@
+import '../faust.config';
+import React from 'react';
+import { useRouter } from 'next/router';
+import { WordPressBlocksProvider, fromThemeJson } from '@faustwp/blocks';
+import { FaustProvider } from '@faustwp/core';
+import blocks from '../wp-blocks';
+// import '../styles/blocks.scss'; // <-- Import block styles from WordPress.
+import '../globalStylesheet.css'; // <-- Generated by @faustwp/cli
+
+export default function MyApp({ Component, pageProps }) {
+ const router = useRouter();
+
+ return (
+
+
+
+
+
+ );
+}
diff --git a/examples/next/block-support/pages/api/faust/[[...route]].js b/examples/next/block-support/pages/api/faust/[[...route]].js
new file mode 100644
index 000000000..e73fd7919
--- /dev/null
+++ b/examples/next/block-support/pages/api/faust/[[...route]].js
@@ -0,0 +1,4 @@
+import '../../../faust.config';
+import { apiRouter } from '@faustwp/core';
+
+export default apiRouter;
diff --git a/examples/next/block-support/pages/index.js b/examples/next/block-support/pages/index.js
new file mode 100644
index 000000000..37681a6cd
--- /dev/null
+++ b/examples/next/block-support/pages/index.js
@@ -0,0 +1,9 @@
+import { getWordPressProps, WordPressTemplate } from '@faustwp/core';
+
+export default function Page(props) {
+ return ;
+}
+
+export function getStaticProps(ctx) {
+ return getWordPressProps({ ctx });
+}
diff --git a/examples/next/block-support/pages/preview.js b/examples/next/block-support/pages/preview.js
new file mode 100644
index 000000000..a4b886e8e
--- /dev/null
+++ b/examples/next/block-support/pages/preview.js
@@ -0,0 +1,5 @@
+import { WordPressTemplate } from '@faustwp/core';
+
+export default function Preview(props) {
+ return ;
+}
diff --git a/examples/next/block-support/styles/blocks.scss b/examples/next/block-support/styles/blocks.scss
new file mode 100644
index 000000000..2625e002c
--- /dev/null
+++ b/examples/next/block-support/styles/blocks.scss
@@ -0,0 +1,13 @@
+// WordPress block styles.
+
+@use 'sass:math';
+
+@import '@wordpress/base-styles/mixins';
+@import '@wordpress/base-styles/colors.native';
+@import '@wordpress/base-styles/z-index';
+@import '@wordpress/base-styles/default-custom-properties';
+@import '@wordpress/base-styles/colors';
+@import '@wordpress/base-styles/variables';
+@import '@wordpress/base-styles/breakpoints';
+@import '@wordpress/block-library/src/style';
+@import '@wordpress/block-library/src/theme';
diff --git a/examples/next/block-support/wp-blocks/index.js b/examples/next/block-support/wp-blocks/index.js
new file mode 100644
index 000000000..7219764ea
--- /dev/null
+++ b/examples/next/block-support/wp-blocks/index.js
@@ -0,0 +1,15 @@
+import { CoreBlocks } from '@faustwp/blocks';
+
+export default {
+ CoreParagraph: CoreBlocks.CoreParagraph,
+ CoreColumns: CoreBlocks.CoreColumns,
+ CoreColumn: CoreBlocks.CoreColumn,
+ CoreCode: CoreBlocks.CoreCode,
+ CoreQuote: CoreBlocks.CoreQuote,
+ CoreImage: CoreBlocks.CoreImage,
+ CoreSeparator: CoreBlocks.CoreSeparator,
+ CoreList: CoreBlocks.CoreList,
+ CoreButton: CoreBlocks.CoreButton,
+ CoreButtons: CoreBlocks.CoreButtons,
+ CoreHeading: CoreBlocks.CoreHeading,
+};
diff --git a/examples/next/block-support/wp-templates/front-page.js b/examples/next/block-support/wp-templates/front-page.js
new file mode 100644
index 000000000..21ae05bc8
--- /dev/null
+++ b/examples/next/block-support/wp-templates/front-page.js
@@ -0,0 +1,69 @@
+import { gql } from '@apollo/client';
+import { flatListToHierarchical } from '@faustwp/core';
+import { WordPressBlocksViewer } from '@faustwp/blocks';
+import blocks from '../wp-blocks';
+
+export default function Component({ loading, data }) {
+ // Loading state for previews.
+ if (loading) {
+ return <>Loading...>;
+ }
+
+ const { title, editorBlocks } = data?.page ?? { title: '' };
+ const blockList = flatListToHierarchical(editorBlocks, { childrenKey: 'innerBlocks' });
+
+ return (
+
+
{title}
+
+
+ );
+}
+
+Component.query = gql`
+ ${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}
+ query GetPage(
+ $databaseId: ID!
+ $asPreview: Boolean = false
+ ) {
+ page(id: $databaseId, idType: DATABASE_ID, asPreview: $asPreview) {
+ title
+ content
+ editorBlocks(flat: false) {
+ name
+ __typename
+ 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}
+ }
+ }
+ }
+`;
+
+Component.variables = ({ databaseId }, ctx) => {
+ return {
+ databaseId,
+ asPreview: ctx?.asPreview,
+ };
+};
diff --git a/examples/next/block-support/wp-templates/index.js b/examples/next/block-support/wp-templates/index.js
new file mode 100644
index 000000000..091c6443d
--- /dev/null
+++ b/examples/next/block-support/wp-templates/index.js
@@ -0,0 +1,5 @@
+import frontPage from './front-page';
+
+export default {
+ 'front-page': frontPage,
+};
diff --git a/package-lock.json b/package-lock.json
index b33286cc7..7e9215525 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -41,6 +41,7 @@
"examples/next/getting-started",
"examples/next/faustwp-getting-started",
"examples/next/app-router",
+ "examples/next/block-support",
"plugins/faustwp"
]
}
@@ -309,6 +310,137 @@
"node": ">=14.17"
}
},
+ "examples/next/block-support": {
+ "version": "0.1.0",
+ "dependencies": {
+ "@apollo/client": "^3.6.6",
+ "@faustwp/blocks": "2.0.0",
+ "@faustwp/cli": "1.0.1",
+ "@faustwp/core": "1.1.0",
+ "@wordpress/base-styles": "^4.26.0",
+ "@wordpress/block-library": "^7.19.0",
+ "classnames": "^2.3.1",
+ "graphql": "^16.6.0",
+ "next": "^12.1.6",
+ "react": "^17.0.2",
+ "react-dom": "^17.0.2",
+ "sass": "^1.54.9"
+ },
+ "engines": {
+ "node": ">=16",
+ "npm": ">=8"
+ }
+ },
+ "examples/next/block-support/node_modules/@faustwp/cli": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/@faustwp/cli/-/cli-1.0.1.tgz",
+ "integrity": "sha512-dAbl0ru11OYMrDSjViz2wrw8fZEVoO+OW0uRqHGGrhNoyMHoGClGdSw8gz3hnbAKDk/2GZDp6aauaG7igcsQjw==",
+ "dependencies": {
+ "chalk": "^4.1.2",
+ "configstore": "^6.0.0",
+ "dotenv-flow": "^3.2.0",
+ "isomorphic-fetch": "^3.0.0",
+ "lodash": "^4.17.21",
+ "uuid": "8.3.2"
+ },
+ "bin": {
+ "faust": "dist/index.js"
+ },
+ "engines": {
+ "node": ">=16",
+ "npm": ">=8"
+ }
+ },
+ "examples/next/block-support/node_modules/@faustwp/core": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@faustwp/core/-/core-1.1.0.tgz",
+ "integrity": "sha512-cC9/TCT5rMf1HRibbXyg6DixscDS9khn852Humk37f4PW3V+XX4G3q51lc8uJnMnTpW8tWhyuqe7onkhYB/tgw==",
+ "dependencies": {
+ "@wordpress/hooks": "^3.14.0",
+ "chalk": "^4.1.2",
+ "classnames": "^2.3.2",
+ "cookie": "^0.5.0",
+ "deepmerge": "^4.2.2",
+ "fast-xml-parser": "^4.2.5",
+ "isomorphic-fetch": "^3.0.0",
+ "js-sha256": "^0.9.0",
+ "lodash": "^4.17.21"
+ },
+ "engines": {
+ "node": ">=16",
+ "npm": ">=8"
+ },
+ "peerDependencies": {
+ "@apollo/client": ">=3.6.6",
+ "next": ">=12.1.6",
+ "react": ">=17.0.2",
+ "react-dom": ">=17.0.2"
+ }
+ },
+ "examples/next/block-support/node_modules/ansi-styles": {
+ "version": "4.3.0",
+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
+ "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
+ "dependencies": {
+ "color-convert": "^2.0.1"
+ },
+ "engines": {
+ "node": ">=8"
+ },
+ "funding": {
+ "url": "https://github.com/chalk/ansi-styles?sponsor=1"
+ }
+ },
+ "examples/next/block-support/node_modules/chalk": {
+ "version": "4.1.2",
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
+ "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
+ "dependencies": {
+ "ansi-styles": "^4.1.0",
+ "supports-color": "^7.1.0"
+ },
+ "engines": {
+ "node": ">=10"
+ },
+ "funding": {
+ "url": "https://github.com/chalk/chalk?sponsor=1"
+ }
+ },
+ "examples/next/block-support/node_modules/color-convert": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
+ "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
+ "dependencies": {
+ "color-name": "~1.1.4"
+ },
+ "engines": {
+ "node": ">=7.0.0"
+ }
+ },
+ "examples/next/block-support/node_modules/color-name": {
+ "version": "1.1.4",
+ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
+ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
+ },
+ "examples/next/block-support/node_modules/has-flag": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
+ "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "examples/next/block-support/node_modules/supports-color": {
+ "version": "7.2.0",
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
+ "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
+ "dependencies": {
+ "has-flag": "^4.0.0"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
"examples/next/faustwp-getting-started": {
"name": "@faustwp/getting-started-example",
"version": "0.1.0",
@@ -1373,6 +1505,10 @@
"resolved": "packages/block-editor-utils",
"link": true
},
+ "node_modules/@faustwp/block-support-example": {
+ "resolved": "examples/next/block-support",
+ "link": true
+ },
"node_modules/@faustwp/blocks": {
"resolved": "packages/blocks",
"link": true
@@ -21617,6 +21753,66 @@
"plugins/faustwp": {
"name": "@faustwp/wordpress-plugin",
"version": "1.0.4"
+ },
+ "packages/experimental-app-router/node_modules/@next/swc-android-arm-eabi": {
+ "version": "12.3.0",
+ "resolved": "https://registry.npmjs.org/@next/swc-android-arm-eabi/-/swc-android-arm-eabi-12.3.0.tgz",
+ "integrity": "sha512-/PuirPnAKsYBw93w/7Q9hqy+KGOU9mjYprZ/faxMUJh/dc6v3rYLxkZKNG9nFPIW4QKNTCnhP40xF9hLnxO+xg==",
+ "cpu": [
+ "arm"
+ ],
+ "optional": true,
+ "os": [
+ "android"
+ ],
+ "engines": {
+ "node": ">= 10"
+ }
+ },
+ "packages/experimental-app-router/node_modules/@next/swc-android-arm64": {
+ "version": "12.3.0",
+ "resolved": "https://registry.npmjs.org/@next/swc-android-arm64/-/swc-android-arm64-12.3.0.tgz",
+ "integrity": "sha512-OaI+FhAM6P9B6Ybwbn0Zl8YwWido0lLwhDBi9WiYCh4RQmIXAyVIoIJPHo4fP05+mXaJ/k1trvDvuURvHOq2qw==",
+ "cpu": [
+ "arm64"
+ ],
+ "optional": true,
+ "os": [
+ "android"
+ ],
+ "engines": {
+ "node": ">= 10"
+ }
+ },
+ "packages/experimental-app-router/node_modules/@next/swc-freebsd-x64": {
+ "version": "12.3.0",
+ "resolved": "https://registry.npmjs.org/@next/swc-freebsd-x64/-/swc-freebsd-x64-12.3.0.tgz",
+ "integrity": "sha512-xAlruUREij/bFa+qsE1tmsP28t7vz02N4ZDHt2lh3uJUniE0Ne9idyIDLc1Ed0IF2RjfgOp4ZVunuS3OM0sngw==",
+ "cpu": [
+ "x64"
+ ],
+ "optional": true,
+ "os": [
+ "freebsd"
+ ],
+ "engines": {
+ "node": ">= 10"
+ }
+ },
+ "packages/experimental-app-router/node_modules/@next/swc-linux-arm-gnueabihf": {
+ "version": "12.3.0",
+ "resolved": "https://registry.npmjs.org/@next/swc-linux-arm-gnueabihf/-/swc-linux-arm-gnueabihf-12.3.0.tgz",
+ "integrity": "sha512-jin2S4VT/cugc2dSZEUIabhYDJNgrUh7fufbdsaAezgcQzqfdfJqfxl4E9GuafzB4cbRPTaqA0V5uqbp0IyGkQ==",
+ "cpu": [
+ "arm"
+ ],
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">= 10"
+ }
}
}
}
diff --git a/package.json b/package.json
index 3ae0eb2f5..3db3e55db 100644
--- a/package.json
+++ b/package.json
@@ -18,6 +18,7 @@
"examples/next/getting-started",
"examples/next/faustwp-getting-started",
"examples/next/app-router",
+ "examples/next/block-support",
"plugins/faustwp"
]
},