-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add new block-support example project Signed-off-by: Joe Fusco <[email protected]> * Auto analyze new project Signed-off-by: Joe Fusco <[email protected]> * Update dependencies Signed-off-by: Joe Fusco <[email protected]> * Remove hardcoded theme.json Signed-off-by: Joe Fusco <[email protected]> * Ignore globalStylesheet.css Signed-off-by: Joe Fusco <[email protected]> * Reduce example to just block things Signed-off-by: Joe Fusco <[email protected]> * Add newline to EOF Signed-off-by: Joe Fusco <[email protected]> * Reduce example Signed-off-by: Joe Fusco <[email protected]> * Update lockfile after merge Signed-off-by: Joe Fusco <[email protected]> * Constrain layout using existing core class Signed-off-by: Joe Fusco <[email protected]> * Not being used Signed-off-by: Joe Fusco <[email protected]> * Irrelevant comment Signed-off-by: Joe Fusco <[email protected]> * Resolve merge conflicts Signed-off-by: Joe Fusco <[email protected]> --------- Signed-off-by: Joe Fusco <[email protected]>
- Loading branch information
1 parent
426463c
commit 4c4e600
Showing
18 changed files
with
431 additions
and
1 deletion.
There are no files selected for viewing
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
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,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 |
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,2 @@ | ||
possibleTypes.json | ||
globalStylesheet.css |
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,3 @@ | ||
# @faustwp/block-support-example | ||
|
||
Example showcasing Faust.js block editor support. |
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 @@ | ||
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, | ||
}); |
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,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', | ||
}, | ||
}); |
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 @@ | ||
{ | ||
"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" | ||
} | ||
} |
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,16 @@ | ||
import { getWordPressProps, WordPressTemplate } from '@faustwp/core'; | ||
|
||
export default function Page(props) { | ||
return <WordPressTemplate {...props} />; | ||
} | ||
|
||
export function getStaticProps(ctx) { | ||
return getWordPressProps({ ctx }); | ||
} | ||
|
||
export async function getStaticPaths() { | ||
return { | ||
paths: [], | ||
fallback: 'blocking', | ||
}; | ||
} |
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,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 ( | ||
<FaustProvider pageProps={pageProps}> | ||
<WordPressBlocksProvider | ||
config={{ | ||
blocks, | ||
theme: null, | ||
}}> | ||
<Component {...pageProps} key={router.asPath} /> | ||
</WordPressBlocksProvider> | ||
</FaustProvider> | ||
); | ||
} |
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,4 @@ | ||
import '../../../faust.config'; | ||
import { apiRouter } from '@faustwp/core'; | ||
|
||
export default apiRouter; |
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 @@ | ||
import { getWordPressProps, WordPressTemplate } from '@faustwp/core'; | ||
|
||
export default function Page(props) { | ||
return <WordPressTemplate {...props} />; | ||
} | ||
|
||
export function getStaticProps(ctx) { | ||
return getWordPressProps({ ctx }); | ||
} |
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,5 @@ | ||
import { WordPressTemplate } from '@faustwp/core'; | ||
|
||
export default function Preview(props) { | ||
return <WordPressTemplate {...props} />; | ||
} |
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,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'; |
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,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, | ||
}; |
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,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 ( | ||
<div className='is-layout-constrained'> | ||
<h1>{title}</h1> | ||
<WordPressBlocksViewer blocks={blockList} /> | ||
</div> | ||
); | ||
} | ||
|
||
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, | ||
}; | ||
}; |
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,5 @@ | ||
import frontPage from './front-page'; | ||
|
||
export default { | ||
'front-page': frontPage, | ||
}; |
Oops, something went wrong.