Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync canary -> main #1599

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
fcc6d37
Fix Faust.js WordPress Plugin Preview (#1568)
josephfusco Sep 13, 2023
38ea99f
Version Packages (#1567)
github-actions[bot] Sep 13, 2023
ee8c08e
Feat: (block-editor-utils) Add RangeField (#1575)
theodesp Sep 14, 2023
ae69cfb
Merl 1153 faustwp block editor block controls implement checkbox cont…
TeresaGobble Sep 14, 2023
55cf810
MERL-1211: app router config settings (#1577)
matthewguywright Sep 15, 2023
77c5d4f
Reduce App Router bundle size (#1576)
blakewilson Sep 19, 2023
507cc4e
Make use of deep paths more clear in app router package (#1581)
blakewilson Sep 19, 2023
b3c0faf
Create readme for experimental app router package (#1583)
blakewilson Sep 20, 2023
ff91901
Updated changeset wording for apollo client fix (#1584)
blakewilson Sep 20, 2023
6b48533
Version Packages (#1578)
github-actions[bot] Sep 20, 2023
9528e0d
Add dev deps for app router example (#1586)
blakewilson Sep 20, 2023
6ae2a43
App router example improvements (#1588)
blakewilson Sep 22, 2023
9a84eb4
Allow health checks to be skipped via CLI (#1591)
Sep 28, 2023
426463c
Nojira remove stats (#1595)
ChrisWiegman Oct 4, 2023
4c4e600
✨ Block Support Example (#1565)
josephfusco Oct 4, 2023
b406ab1
chore(deps): Bump postcss from 8.4.21 to 8.4.31 in /internal/faustjs.…
dependabot[bot] Oct 4, 2023
cb0212d
chore(deps): Bump postcss in /internal/legacy.faustjs.org (#1597)
dependabot[bot] Oct 4, 2023
94b1551
Version Packages (#1592)
github-actions[bot] Oct 4, 2023
d09584b
chore: update package-lock.json (#1604)
mindctrl Oct 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .changeset/dry-toys-speak.md

This file was deleted.

23 changes: 0 additions & 23 deletions .changeset/gold-bags-flow.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/good-coats-give.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/heavy-geese-give.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/many-houses-push.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/quick-nails-listen.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/shiny-steaks-cough.md

This file was deleted.

5 changes: 4 additions & 1 deletion .github/workflows/nextjs-bundle-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
34 changes: 0 additions & 34 deletions examples/next/app-router/app/[postSlug]/page.tsx

This file was deleted.

3 changes: 3 additions & 0 deletions examples/next/app-router/app/[slug]/hasPreviewProps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function hasPreviewProps(props: any) {
return props?.searchParams?.preview === 'true' && !!props?.searchParams?.p;
}
53 changes: 53 additions & 0 deletions examples/next/app-router/app/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { getAuthClient, getClient } from '@faustwp/experimental-app-router';
import { gql } from '@apollo/client';
import { hasPreviewProps } from './hasPreviewProps';
import { PleaseLogin } from '@/components/please-login';

export default async function Page(props) {
const slug = props.params.slug;
const isPreview = hasPreviewProps(props);

let client = isPreview ? await getAuthClient() : await getClient();

if (!client) {
return <PleaseLogin />;
}

/**
* There is currently a bug in WPGraphQL where you can not query for previews
* using the contentNode type. This bug will need to be resolved for preview
* functionality in the below query to work properly. For now, it returns
* the production ready data for the given contentNode regardless if
* asPreview is true or false.
*
* @see https://github.com/wp-graphql/wp-graphql/issues/1673
*/
const { data } = await client.query({
query: gql`
query GetContentNode($uri: ID!, $asPreview: Boolean!) {
contentNode(id: $uri, idType: URI, asPreview: $asPreview) {
... on NodeWithTitle {
title
}
... on NodeWithContentEditor {
content
}
date
}
}
`,
variables: {
uri: slug,
asPreview: isPreview,
},
});

return (
<main>
<h2>{data?.contentNode?.title}</h2>
<div
dangerouslySetInnerHTML={{ __html: data?.contentNode?.content ?? '' }}
/>
</main>
);
}
1 change: 1 addition & 0 deletions examples/next/app-router/app/api/faust/[route]/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { faustRouteHandler } from '@faustwp/experimental-app-router';
import '@/faust.config.js';

const { GET, POST } = faustRouteHandler;

Expand Down
13 changes: 1 addition & 12 deletions examples/next/app-router/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
import { gql } from '@apollo/client';
import { getClient } from '@faustwp/experimental-app-router';
import Link from 'next/link';
/**
* For now, we will manually call the Faust config as we have not yet determined
* how we want to set the config (Currently in Faust we call it in the [wordPressNode] file).
*
* @todo
*/
import '../faust.config.js';

export const metadata = {
title: 'Create Next App',
description: 'Generated by create next app',
};
import '@/faust.config.js';

export default async function RootLayout({ children }) {
const client = await getClient();
Expand Down
3 changes: 1 addition & 2 deletions examples/next/app-router/app/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@ export default async function Page() {
*/
console.error(res.error);
} else {
redirect('/gated-content');
redirect('/my-account');
}
}

return (
<>
<h2>Login</h2>

{/* @ts-ignore */}
<form action={loginAction}>
<fieldset>
<label htmlFor="usernameEmail">Username or Email</label>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { PleaseLogin } from '@/components/please-login';
import { gql } from '@apollo/client';
import { getAuthClient } from '@faustwp/experimental-app-router';
import { getAuthClient, onLogout } from '@faustwp/experimental-app-router';

export default async function Page() {
const client = await getAuthClient();

if (!client) {
return <>You must be authenticated</>;
return <PleaseLogin />;
}

const { data } = await client.query({
Expand All @@ -28,11 +29,16 @@ export default async function Page() {
<>
<h2>Welcome {data.viewer.name}</h2>

<h3>My Posts</h3>
<ul>
{data.viewer.posts.nodes.map((post) => (
<li key={post.id}>{post.title}</li>
))}
</ul>

<form action={onLogout}>
<button type="submit">Logout</button>
</form>
</>
);
}
10 changes: 10 additions & 0 deletions examples/next/app-router/components/please-login.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Link from 'next/link';

export function PleaseLogin() {
return (
<>
You must be authenticated! Please <Link href={`/login`}>log in</Link>{' '}
first.
</>
);
}
2 changes: 1 addition & 1 deletion examples/next/app-router/faust.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { setConfig } from '@faustwp/core/dist/cjs/config/index.js';
import { setConfig } from '@faustwp/core/dist/mjs/config/index.js';
import possibleTypes from './possibleTypes.json';

/** @type {import('@faustwp/core').FaustConfig} */
Expand Down
11 changes: 8 additions & 3 deletions examples/next/app-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
},
"dependencies": {
"@apollo/client": "^3.8.0",
"@faustwp/cli": "1.1.1",
"@faustwp/core": "1.1.2",
"@faustwp/experimental-app-router": "^0.0.3",
"@apollo/experimental-nextjs-app-support": "^0.4.1",
"@faustwp/cli": "1.1.4",
"@faustwp/core": "1.1.2",
"@faustwp/experimental-app-router": "^0.1.0",
"graphql": "^16.7.1",
"next": "^13.4.20-canary.18",
"react": "^18.2.0",
Expand All @@ -23,5 +23,10 @@
"engines": {
"node": ">=16",
"npm": ">=8"
},
"devDependencies": {
"@types/node": "^20.6.3",
"@types/react": "^18.2.22",
"typescript": "^5.2.2"
}
}
3 changes: 3 additions & 0 deletions examples/next/app-router/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"paths": {
"@/*": ["./*"]
},
"plugins": [
{
"name": "next"
Expand Down
5 changes: 5 additions & 0 deletions examples/next/block-support/.env.local.sample
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
2 changes: 2 additions & 0 deletions examples/next/block-support/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
possibleTypes.json
globalStylesheet.css
3 changes: 3 additions & 0 deletions examples/next/block-support/README.md
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.
12 changes: 12 additions & 0 deletions examples/next/block-support/faust.config.js
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,
});
18 changes: 18 additions & 0 deletions examples/next/block-support/next.config.js
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',
},
});
30 changes: 30 additions & 0 deletions examples/next/block-support/package.json
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"
}
}
16 changes: 16 additions & 0 deletions examples/next/block-support/pages/[...wordpressNode].js
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',
};
}
Loading
Loading