diff --git a/.github/workflows/audit-dependencies.yml b/.github/workflows/audit-dependencies.yml new file mode 100644 index 000000000..4c1abea8b --- /dev/null +++ b/.github/workflows/audit-dependencies.yml @@ -0,0 +1,12 @@ +name: Audit Dependencies + +on: pull_request + +jobs: + audit_depedencies: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Audit for vulnerabilities + run: npx audit-ci@^6 --config ./audit-ci.jsonc diff --git a/audit-ci.jsonc b/audit-ci.jsonc new file mode 100644 index 000000000..861713ff4 --- /dev/null +++ b/audit-ci.jsonc @@ -0,0 +1,5 @@ +{ + "$schema": "https://github.com/IBM/audit-ci/raw/main/docs/schema.json", + "moderate": true, + "allowlist": [] +} diff --git a/examples/next/faustwp-getting-started/package.json b/examples/next/faustwp-getting-started/package.json index c8e43b0dc..fc447f4f9 100644 --- a/examples/next/faustwp-getting-started/package.json +++ b/examples/next/faustwp-getting-started/package.json @@ -10,7 +10,7 @@ }, "dependencies": { "@apollo/client": "^3.6.6", - "@faustwp/cli": "0.1.3", + "@faustwp/cli": "0.1.4", "@faustwp/core": "0.1.3", "@wordpress/base-styles": "^4.7.0", "@wordpress/block-library": "^7.13.0", diff --git a/internal/faustjs.org/blog/2021-12-03-upgrading-to-faustwp.md b/internal/faustjs.org/blog/2021-12-03-upgrading-to-faustwp.md new file mode 100644 index 000000000..aef8d05f6 --- /dev/null +++ b/internal/faustjs.org/blog/2021-12-03-upgrading-to-faustwp.md @@ -0,0 +1,36 @@ +--- +title: Upgrading to FaustWP +description: All you need to know about upgrading to FaustWP. +slug: upgrading-to-faustwp +hide_table_of_contents: true +--- + +The WP Engine Headless (or WPE Headless) plugin has been renamed to FaustWP starting with version 0.7.0. Along with the rename, distribution of the plugin has moved off of WP Engine servers and into the official wordpress.org plugin repository. In order to continue receiving plugin updates and remain compatible with future versions of Faust.js NPM packages, site owners will need to do the following: + +1. Log in to your WordPress admin dashboard. +2. Go to “Plugins -> Add New” in the admin sidebar. +3. In the top right corner, enter "FaustWP" in the search box. +4. Click the “Install Now” button. +5. Once the installation is complete, click “Activate”. + +Activating FaustWP will automatically deactivate WP Engine Headless if it is installed and active on your site. **All plugin settings will be preserved, including your secret key.** You can now remove the old, deactivated WP Engine Headless plugin: + +1. Go to "Plugins -> Installed Plugins" in the admin sidebar. +2. Verify that FaustWP is installed and active. +3. Verify that WP Engine Headless is inactive. +4. Delete WP Engine Headless. + +We have done our best to ensure a seamless upgrade experience, but we encourage users to review the [plugin changelog](https://faustjs.org/docs/changelog/faustwp) to evaluate any impacts these changes might have in their own applications. + +## Package Updates + +Version 0.7.0 of FaustWP is best suited for use with `@faustjs/core` version 0.14.0 or greater. As noted in the [changelog](https://faustjs.org/docs/changelog/core) for version 0.14.0: + +> The FaustWP plugin has deprecated the REST endpoint that `@faustjs/core` uses for authorization. Both the plugin and the `@faustjs/core` package will continue to work with the deprecated endpoint until it is removed in a future version. Make sure to always update your FaustWP plugin and `@faustjs` packages together to avoid any issues that may arise from incompatible versions. + +We recommend updating all of your Faust.js packages after installing the FaustWP plugin. + +### Changelogs +- [@faustjs/core](https://faustjs.org/docs/changelog/core) +- [@faustjs/next](https://faustjs.org/docs/changelog/next) +- [@faustjs/react](https://faustjs.org/docs/changelog/react) diff --git a/internal/faustjs.org/blog/2022-07-06-the-future-of-faust.md b/internal/faustjs.org/blog/2022-07-06-the-future-of-faust.md new file mode 100644 index 000000000..7cc274da4 --- /dev/null +++ b/internal/faustjs.org/blog/2022-07-06-the-future-of-faust.md @@ -0,0 +1,38 @@ +--- +title: The Future of Faust.js +description: An update on Faust.js, where it is and where it is going +slug: the-future-of-faust +hide_table_of_contents: true +--- + +We launched this blog 7 months ago with a goal of keeping you informed of what is going on in the development of Faust.js as well as to help you get started using the framework in your own projects. To date, we simply have not prioritized keeping up here on the blog and it is time for that to change. + + + +Today we want to talk about where Faust.js is and where we're working on taking it in the future. It will be the first of many regular posts designed to tell the story of Faust.js and how it affects developers of all backgrounds. + +## Where Faust.js is Today + +First and foremost, the development of Faust.js is alive and well. When the last post was written in December we were a rather unorthodox team of two engineers working on understanding what Faust.js should be. + +Today the Faust.js team, known internally as Team Merlin, is made of of five engineers and an engineering manager and [we're still looking for one more staff/lead engineer to join our team](https://wpengine.wd1.myworkdayjobs.com/en-US/WP_Engine/job/Software-Engineer-IV--ATLAS---Themes-_JR100226). + +While we've expanded, we've moved much of our development process out of GitHub projects and into company tools that allow us to be more in tune with the needs of the organization and [Atlas](https://wpengine.com/atlas/) as well as allows us to more easily communicate the story of Faust.js to stakeholders throughout the company. + +Today we're revisiting this blog primarily as a way to update you on what we're doing now that we're currently not working in public. From this point forward we'll be updating the blog at least once every two weeks with the current accomplishments and next steps on our journey to ensure Faust.js is the leading framework for folks looking to develop headless sites with WordPress. + +## Where Faust.js is Going + +As [WP Engine](https://wpengine.com) has made a significant investment in the future of Faust.js by increasing the team working on it, it's time to talk to where we're currently spending our time. + +When Faust.js was first conceived a decision was made to go with [GQty](https://gqty.dev) as our data library as we thought it would be the simplest way for users to pull data from WordPress using [WPGraphQL](https://www.wpgraphql.com). While we largely were able to prove it was indeed simple, that simplicity came with complications. GQty proved a difficult choice for users to scale with as it over-abstracted enough of the data layer that modifying how a user was getting data from WordPress quickly became a difficult process. + +Today we're working on removing the limits imposed by choosing GQty by replacing it with the popular [Apollo library](https://www.apollographql.com). This will allow users to get what they need from WordPress in whatever way they need it. Users won't be constrained on the queries they run and will be able to more easily modify a default query to fit any use case imaginable. You can expect to see our work on this feature available in the 3rd quarter of 2022. + +As part of replacing GQty with Apollo, another shift in Faust.js since our last writing is that we've realized our target audience is not so much JavaScript developers forced to use WordPress but is, in fact, WordPress developers pivoting to headless sites. While the difference might sound trivial, the shift comes with a change of expectations that lead to numerous features in development. For instance, in the 3rd quarter of 2022 we also hope to release a template hierarchy feature that utilizes WordPress' core routing system, popularly known as [permalinks](https://wordpress.org/support/article/using-permalinks/), to power a developer experience that better utilizes the existing development skills of WordPress developers and agencies. + +While our audience might not be what we originally thought it was, that isn't to say we're not working on cutting edge features for JavaScript developers as well. From the ability to share components between your front end and WordPress' Block Editor to authentication and even advanced ways to handle use cases such as A/B testing and more there is a lot planned in our backlog and we can't wait to start rolling it out to you over the coming months. + +## Check Back Often For Updates From Our Latest Sprint + +Faust.js has a bright future and we look forward to sharing it with you. Check back here roughly every two weeks for news on where we're at and what we're working on and, as always, you can ask the team questions in our [GitHub issues](https://github.com/wpengine/faustjs) or on [our Discord server](https://developers.wpengine.com). We're looking forward to powering your project. diff --git a/internal/faustjs.org/blog/2022-07-20-sprint-14-update.md b/internal/faustjs.org/blog/2022-07-20-sprint-14-update.md new file mode 100644 index 000000000..f3642aaa7 --- /dev/null +++ b/internal/faustjs.org/blog/2022-07-20-sprint-14-update.md @@ -0,0 +1,30 @@ +--- +title: Sprint 14 Update +description: Updates from the teams work on Sprint 14 +slug: sprint-14-update +hide_table_of_contents: true +--- + +Yesterday, July 19th, the team completed Sprint 14, which is simply our 14th [sprint](https://www.educba.com/what-is-agile-sprint/) of the year. This was one of more productive sprints, in terms of implementation, so far this year. We managed to release a new version of both the Faust.js library as well as the Faust WordPress plugin, we welcomed two new developers to the team and we worked hard to implement a way to help us better understand how folks are using the framework. Here's how it all breaks down: + +## Faust.js 0.15.7 and Faust WP 0.7.10 + +The Faust WordPress plugin was updated to version 0.7.10 last week and all Faust JavaScript libraries were updated to version 0.15.7. These new versions didn't bring about any new features but they did solve some issues folks were seeing as well as updated some of the dependencies Faust relies on. You can see a full list of all the changes we made in our [release notes](https://github.com/wpengine/faustjs/releases). + +## Welcome new developers + +In addition to new releases, our team also welcomed two new developers to the team bringing our total to 5 full-time developers focused solely on Faust. You'll see their contributions in our [GitHub repo](https://github.com/wpengine/faustjs/) and they will help us bring the next evolution of Faust into your hands as quickly as possible. + +We're not done here, though. We still have one more position open on our team for a staff developer. If you're interested in helping take Faust to the next level, [apply now](https://wpengine.wd1.myworkdayjobs.com/en-US/WP_Engine/job/Software-Engineer-IV--ATLAS---Themes-_JR100226) and let's talk. + +## New telemetry in Faust.js + +The big goal of Faust.js was in implementing some basic telemetry into Faust so that our teams and stakeholders have some measure on how the product is actually being used. Note that this telemetry, while code complete, has not launched in a release yet. + +To implement the telemetry we're using [Google Analytics](https://marketingplatform.google.com/about/analytics/), a common analytics partner in WP Engine products, to collect data on version information and other build parameters solely from the JavaScript builds completed with Faust. **All analytics are opt-in only** so new users, once launched, will see a prompt asking you if you're willing to login. This can safely be bypassed, for those interested in doing so, without sending us any data. While we'd love to see you participate in helping us collect build data, and hope you'll do so, failing to opt-in means nothing at all will be transmitted to Google or elsewhere. + +You can expect to see this in a new release in the coming months as we first finish a comprehensive privacy policy for the feature. + +## What's next + +In Sprint 15, which started yesterday, the team is focusing on implementing content previews in the next version of Faust as well as reducing some technical debt that has lead to issues on our GitHub repo. Expect to see a new, faster, release as a result at some point in the next two weeks. diff --git a/internal/faustjs.org/blog/2022-08-03-sprint-15-update.md b/internal/faustjs.org/blog/2022-08-03-sprint-15-update.md new file mode 100644 index 000000000..6f2eaff9b --- /dev/null +++ b/internal/faustjs.org/blog/2022-08-03-sprint-15-update.md @@ -0,0 +1,20 @@ +--- +title: Sprint 15 Update +description: Updates from the teams work on Sprint 15 +slug: sprint-15-update +hide_table_of_contents: true +--- + +Yesterday the team working on Faust finished Sprint 15 and started work on our next Sprint, 16, which we will be in for the next two weeks. The theme of the sprint was to finish porting the post previews feature to the new version of Faust as well as to address as many [GitHub issues](https://github.com/wpengine/faustjs/issues) as we could. + +## What we accomplished + +Unfortunately we haven't yet finished the new preview feature as complexities of integrating the feature with the new Apollo library slowed the work down more than we would have liked. We should be able to complete it in the coming days but it was not completed as part of the sprint as we would have liked. + +We did, however, catch up on our backlog of issues as planned. This included reducing the client bundle size and upgrading to GQty 2.3.0. We hope this work will make life a bit easier for folks currently using Faust in production. + +## What's next + +Next up we're focusing solely on finishing out "plugin" system for Faust. This is a series of hooks that will allow folks to build on Faust for their own projects. Maybe you want to add in a feature or swap out something we're doing? No problem. Just like WordPress plugins you'll be able to extend Faust to fit your needs and, if you're so inclined, the needs of the community in general. + +While the plugin system is our primary goal for these two weeks we're also still finishing up post previews and working to ensure we can get some basic telemetry data on how folks are using the framework. The latter is being done in GA4 but, due to changes in GA4, will require a bit more work for us to be able to implement it. On the positive side this will make analytics even more private due to a proxy that can mask IP address and other data. On the downside, building that proxy will mean more work for the team in the coming days. It will be worth it, however, as it can help us build the features you need in the future. diff --git a/internal/faustjs.org/blog/2022-08-16-sprint-16-update.md b/internal/faustjs.org/blog/2022-08-16-sprint-16-update.md new file mode 100644 index 000000000..629f8dc02 --- /dev/null +++ b/internal/faustjs.org/blog/2022-08-16-sprint-16-update.md @@ -0,0 +1,22 @@ +--- +title: Sprint 16 Update +description: Updates from the teams work on Sprint 16 +slug: sprint-16-update +hide_table_of_contents: true +--- + +Hello folks! I’m Terri, one of the new software engineers working on the team developing Faust. I’ll be supplying the update on the team’s progress the last two weeks on sprint 16, as well as a quick peek at what we're working on for the remainder of August. + +## What we accomplished + +Yesterday, August 16th, the plugin system code was completed for the new version of Faust. The goal of this new plugin system is to allow developers to provide easy-to-implement solutions for themselves and other users. A plugin for this new version of Faust is a simple class with a constructor for options, and an “apply” method. This method has a function as an argument called `callHook`, which is a callback function to apply logic to certain types of hooks. For example, a developer may want to alter what data is fetched in the seed query, or what templates get resolved in the template resolver. Each of these actions now have a corresponding “hook” to which custom functionality can be applied. + +In addition to this, plugins in the new system now have `@wordpress/hooks` behind an experimental flag, as well as tests that ensure that a developer’s experimental plugins have their apply methods called while those that don’t have an apply method fail silently when specified in the `experimentalPlugins` config property. Testing also now ensures that the possible lack of the `experimentalPlugins` property does not introduce any adverse effects, too, allowing developers to tinker with building plugins with less implementation. + +Beyond the plugin system for the new version of Faust, we also completed an architecture document for a service to handle GA4’s new requirements with telemetry, ensuring that the team has a plan for keeping data anonymous and building a reliable reporting system. We implemented post previews and authorization for previews, too, so folks can examine posts while in the block editor. + +## What's next + +The team is now closing in on a fix for the breaking changes introduced when Next.js took middleware out of beta. The handleSitemapRequests function used in conjunction with Next.js 12.2 will once again allow developers to easily proxy their WordPress sitemap to their headless frontend once these code changes are approved and merged. + +In Sprint 17, we are also working on planning out our approach for implementing support for Next.js file-based pages. Our current data fetching conventions and abstractions work well inside the template hierarchy system, but we want to support Next.js based pages too, while maintaining the same level of functionality. Having this flexibility will help developers create pages outside of the template hierarchy without needing to create a page for every route, putting a wider range of options on the table. \ No newline at end of file diff --git a/internal/faustjs.org/blog/2022-08-31-sprint-17-update.md b/internal/faustjs.org/blog/2022-08-31-sprint-17-update.md new file mode 100644 index 000000000..f3b285ee3 --- /dev/null +++ b/internal/faustjs.org/blog/2022-08-31-sprint-17-update.md @@ -0,0 +1,24 @@ +--- +title: Sprint 17 Update +description: Updates from the team's work on Sprint 17 +slug: sprint-17-update +hide_table_of_contents: true +--- + +We finished Sprint 17 yesterday, our 17th 2-week Sprint of the year. Our current focus has been two-fold: first, to release a new version of Faust using Apollo as our GraphQL library and, second, to build a plan for how to best integrate Gutenberg (the block editor) into a headless site with the minimum amount of developer friction. As far as progress on both those endeavors is concerned, the Sprint was a success. + +## What we accomplished + +One of our more important features in Faust has been the support of Sitemaps as implemented by plugins such as [Yoast SEO](https://wordpress.org/plugins/wordpress-seo/) and others. While we've had the feature for a while, Next.js 12.2 [changed their middleware implementation rather significantly](https://nextjs.org/blog/next-12-2) leaving the feature broken for our users. We now have a fix in place that avoids using Next's middleware and hope to have it in your hands in the coming weeks. + +In addition to updating our sitemap feature, the team has also been learning Gutenberg development to better understand WordPress development as a whole. Most of our backgrounds are either in classic WordPress or in JavaScript, so Gutenberg, at least at the level we need to understand it, has been a learning experience for everyone this quarter. With the conclusion of Sprint 17 we feel we have enough experience with it to finally start looking at how we can use it to make headless development better. For example, what if you could re-use your components in both the editor and on your headless front-end? There are many questions and many avenues to pursue and, over the coming weeks, we'll be putting together a plan to do so. To me, personally, this is one of the most exciting possibilities for headless WordPress. Unlocking the potential of Gutenberg for headless sites will all for use and re-use of content on a scale that just isn't possible in classic WordPress and the potential is amazing. + +Finally, we also worked to scrub a number of bugs in the Sprint including upgrading dependencies and plenty of others. Look for the results in our next release coming soon. + +## What's next + +Our next Sprint will be focused on two things. First, better content previews for the next version of Faust. The new version will enable a whole new ability to easily develop headless WordPress sites, including its own plugin system and the ability to utilize a template system very similar to WordPress' own [template hierarchy](https://developer.wordpress.org/themes/basics/template-hierarchy/). Now we need to update our content previews to take advantage of it. + +Second, we're moving beyond learning Gutenberg development ourselves and will be spending time this upcoming Sprint developing a high-level plan for how to best utilize it in headless WordPress development. Expect to see the results of these plans starting in the 4th quarter of 2022. + +Finally, we'll be focusing heavily on documentation and other tasks to make sure you'll be able to hit the ground running when we re-release Faust at the end of September. We can't wait to show you what we've been working on here! diff --git a/internal/faustjs.org/blog/2022-09-14-sprint-18-update.md b/internal/faustjs.org/blog/2022-09-14-sprint-18-update.md new file mode 100644 index 000000000..43f880df4 --- /dev/null +++ b/internal/faustjs.org/blog/2022-09-14-sprint-18-update.md @@ -0,0 +1,18 @@ +--- +title: Sprint 18 Update +description: Updates from the team's work on Sprint 18 +slug: sprint-18-update +hide_table_of_contents: true +--- + +We're 1/2 way through September and nearly finished with the first version of something completely new. This past Sprint was focused on getting the next major version of Faust ready so that we can get it in your hands by the end of this month. We're super excited about it. It's going to change everything! + +## What we accomplished + +The final feature of the next version of Faust was completed, post previews. This leaves us at a "code complete" point for the new version which will be ready later this month. It has all the same features as Faust currently does including authentication and post previews but adds some major new capabilities including a template system that mimics WordPress' [template hierarchy](https://developer.wordpress.org/themes/basics/template-hierarchy/) and replaces GQty with the more capable [Apollo](https://www.apollographql.com) library to ensure your Faust-powered site can be as powerful as you need it to be. + +## What's next + +Sprint 19 is all about preparing for the release of the next version of Faust. The team will be splitting the code into a new repository, preparing a new site and setting up to launch the code with a brand new name. + +Why a new name? The new version we're finishing up isn't just big, it's huge and a new name helps reflect that change. In addition, it helps us make sure we can continue to more easily support your existing sites already on Faust. We're excited about the change and, once we can show you more, I think you will be too. diff --git a/internal/faustjs.org/blog/2022-09-30-sprint-19-update.md b/internal/faustjs.org/blog/2022-09-30-sprint-19-update.md new file mode 100644 index 000000000..16475295d --- /dev/null +++ b/internal/faustjs.org/blog/2022-09-30-sprint-19-update.md @@ -0,0 +1,22 @@ +--- +title: Sprint 19 Update +description: Updates from the team's work on Sprint 19 +slug: sprint-19-update +hide_table_of_contents: true +--- + +This week the team finished Sprint 19, our latest 2 weeks of work, which was focused on polishing the new version of Faust and preparing to release it to you. We've been focusing on what to call the project, how to make sure those of you using existing Faust can continue to do so while needed as well as preparing plans for post-launch features and work that we want to focus on all while taking some time off and dodging hurricanes (you're reading this late as we're a fully-remote team and I am based in Sarasota, FL which was just hit by Hurricane Ian this week). + +## What we accomplished + +Most of our work was spent deciding how to best handle a new library that is vastly different than Faust has been built in the past. The syntax and other uses of moving from GQty to Apollo alone make things quite differently than it had been before. As a result we're working on solutions to ensure the new version is a separate install than what you've used in the past. This ensures, with a 4th quarter launch before the holidays, that your existing projects are safe and supported going forward. If you have, for example, "*" in your package.json for Faust (not a solution we recommend but, we realize, something a lot of people do), if we weren't careful that could break what you have. That won't be the case with the new version. Instead we're working on migration guides, package organization and more to ensure existing users are safe and supported and can migrate to the new library as needed. + +## What's next + +Sprint 20 is focused on preparing that new release. We want to have the new Faust into your hands in the next couple of weeks and that is what we're currently working on. This includes setting up new packages, finishing testing, prepping documentation and more. We've also cleaned up our backlog and will be working on filling out future epics to ensure work on new features, such as full support for Gutenberg and the Block Editor that go beyond anything you've seen yet in headless WordPress, can kick off in the coming weeks. + +Next week, on 1 October to be specific, we're also happy to announce we have an official lead developer on the team that builds Faust. If you're interacted with our support on Discord or elsewhere you've probably come across Blake Wilson. He's one of the original Faust developers and was instrumental both in the current version and the new version we're about to release. I'm happy to announce he's been promoted to Senior Software Engineer here at WP Engine and will officially be taking over the team lead spot for Faust as well. + +It's an exciting time for Faust and the team building it. Personally it took me a long time to understand the value of headless WordPress. Once I came to Atlas I could see the value but the tools were still too immature to really unlock its full potential. With the new version of Faust the rocket has lifted off and I am super excited that we're finally bringing you a full framework that can grow with your projects and with WordPress itself all while making headless WordPress development as easy and powerful as WordPress heavyweights like Genesis have done for the WordPress framework over the past decade. + +Let's do this! diff --git a/internal/faustjs.org/blog/2022-10-12-sprint-20-update.md b/internal/faustjs.org/blog/2022-10-12-sprint-20-update.md new file mode 100644 index 000000000..8331c3ce9 --- /dev/null +++ b/internal/faustjs.org/blog/2022-10-12-sprint-20-update.md @@ -0,0 +1,38 @@ +--- +title: Sprint 20 Update +description: Updates from the team's work on Sprint 20 +slug: sprint-20-update +hide_table_of_contents: true +--- + +It's alive! + +After a lot of work we're happy to announce that the new code for Faust is available on npm. You can find the core package [here](https://www.npmjs.com/package/@faustwp/core) and our new CLI package [here](https://www.npmjs.com/package/@faustwp/cli). + + + +While these are ready to use, please note we're putting the final polish on an updated documentation site so most of it, for now, is very much for those of you who really like to fiddle. + +Also note that this is a new npm organization. This means that your existing code will not auto-update. This new code is a major departure from how we had built Faust and, as a result, it will take some work to migrate your existing implementations. + +## What we accomplished + +This past sprint was all about getting the new version of Faust online. Until two weeks ago we had been engaged in a project to rename the framework but that was scrapped, for a few reasons, at the last minute leaving us scrambling a bit to launch the code with the Faust brand in such a way as to not risk anyone's site who might be using "*" or similar in their package.json. + +So what does new Faust have that makes it so different? + +First, it's built using [Apollo](https://www.apollographql.com) instead of GQty. This makes the whole project much more scalable and suitable for larger sites but also requires a lot of your existing Faust code to require migration to the new style which uses a different syntax and whole methodology for delivering your data. + +Next, Faust now makes all the issues we saw in trying to figure out routing between WordPress and Next.js much easier. We've even added a Next version of the [WordPress template hierarchy](https://developer.wordpress.org/themes/basics/template-hierarchy/) which makes creating the right template as simple as creating a single JavaScript file. + +Of course, if the theme of a switch to Apollo is scalability, we didn't want to just stop here. Faust now has a plugin system allowing you to build on top of Faust like you might have done with WordPress or any other modern system. + +Finally, Faust still has all the major features, including authentication and content previews, that you've come to rely on. Now they're all just more robust and more capable of handling the requirements of any WordPress site, even the most complicated sites. + +What we haven't finished yet, as I mentioned above, is all the documentation. Expect to see new and updated documentation available here in the coming weeks. + +## What's next + +Now that the code is live we're going to spend a sprint or more focusing on documentation and cleanup. Like any software product, Faust has been thoroughly tested but a larger user base will surely find bugs and we'll be watching for them and ready to fix them. + +Once we have our documentation in a better place we'll be pivoting to better supporting Gutenberg and the Block Editor. Imagine a whole block library built in and for headless. That's what we're working on for our next major feature. You'll be able to use the full power of the Block Editor in the WordPress Dashboard as well as be able to import existing front-end components as new blocks easily with only minimal conversion. It's going to be a huge gamechanger for headless WordPress and we can't wait to show it to you! diff --git a/internal/faustjs.org/blog/2022-10-26-sprint-21-update.md b/internal/faustjs.org/blog/2022-10-26-sprint-21-update.md new file mode 100644 index 000000000..4d50ff5ca --- /dev/null +++ b/internal/faustjs.org/blog/2022-10-26-sprint-21-update.md @@ -0,0 +1,24 @@ +--- +title: Sprint 21 Update +description: Updates from the team's work on Sprint 21 +slug: sprint-21-update +hide_table_of_contents: true +--- + +Documentation, documentation, documentation. + +The theme of our last sprint was documentation and it showed. We're super close to launching new documentation for new Faust. You'll see the updates on [https://faustjs.org] in the coming weeks. + + + +## What we accomplished + +We worked hard this sprint to rewrite the Faust documentation to work with the new version of Faust. It's been a long process but we're confident that we're on the verge of a much more robust documentation site which will make working with Faust even easier. + +As part of the upcoming documentation change I did want to call out that, as the older version of Faust isn't going anywhere, neither is its documentation. Faustjs.org will be updated for new Faust and the existing documentation will be moved to a legacy domain to ensure its continued availability for any projects you may have in flight. + +In addition to documentation we also released new versions of the npm packages with minor bugfixes and a small change that significantly reduced the bundle size of the application generated during a build. You can see the full change log for the latest versions [here](https://github.com/wpengine/faustjs/releases). + +## What's next + +Next we're going to be putting the final touches on the new documentation so we can launch the site and start work to update the Blueprints to work with new Faust. Together this will make getting started on Faust much easier and we think you'll agree that new Faust is something special indeed. diff --git a/internal/faustjs.org/docs/authentication.mdx b/internal/faustjs.org/docs/authentication.mdx new file mode 100644 index 000000000..31febbfb0 --- /dev/null +++ b/internal/faustjs.org/docs/authentication.mdx @@ -0,0 +1,7 @@ +--- +slug: auth +title: Authentication +description: Use Faust.js' built-in authentication strategies to authenticate users from your WordPress backend +--- + +### This document is in progress. Check back soon for content! \ No newline at end of file diff --git a/internal/faustjs.org/docs/faq.mdx b/internal/faustjs.org/docs/faq.mdx new file mode 100644 index 000000000..e2efb9f06 --- /dev/null +++ b/internal/faustjs.org/docs/faq.mdx @@ -0,0 +1,23 @@ +--- +slug: faq +title: FAQ +description: Frequently Asked Questions +--- + +## Frequently Asked Questions + +### If I need more support, where should I ask questions? + +Use one of the channels below to contact the Faust team for support. + +[GitHub](https://github.com/wpengine/faustjs) - Faust GitHub documentation and codebase. + +[Discord](https://discord.gg/J2khkF9XYK) - Interactive chat support on Discord. + +### Where can I find more information about development and future features for the WordPress plugin? + +Great question! The development team posts weekly summaries of sprints related to Faust, [here](https://faustjs.org/blog). + +### Why the name “Faust”? + +Johann Faust was a German printer and was instrumental in the invention of the printing press, along with his partner Johann Gutenberg. In the same way the printing press democratized the spread of information, the mission of Faust.js is to support and further the vision of WordPress to democratize publishing on the web. diff --git a/internal/faustjs.org/docs/faustwp/seed-query.mdx b/internal/faustjs.org/docs/faustwp/seed-query.mdx index 887ff8ee1..84900f65b 100644 --- a/internal/faustjs.org/docs/faustwp/seed-query.mdx +++ b/internal/faustjs.org/docs/faustwp/seed-query.mdx @@ -6,7 +6,7 @@ description: This section describes the FaustWP Seed Query. The Seed Query is a request that is fired when a user is trying to visit a URL which requests data from WP for the given URL. With this data we are able to get a list of possible templates for the given route. -### What is it used for? +### What Is It Used For? The Seed Query is used for resolving templates in the Faust template hierarchy. diff --git a/internal/faustjs.org/docs/faustwp/settings.mdx b/internal/faustjs.org/docs/faustwp/settings.mdx index 66cddf68d..510ec1f58 100644 --- a/internal/faustjs.org/docs/faustwp/settings.mdx +++ b/internal/faustjs.org/docs/faustwp/settings.mdx @@ -12,7 +12,7 @@ allows you to customize the behavior of the plugin by configuring certain featur The following options are available to enable/disabled based on your requirements: -### Disabling WordPress theme admin pages +### Disabling WordPress Theme Admin Pages This option is controlled by the `Disable WordPress theme admin pages` checkbox. When enabled it removes certain wp-admin menu items that aren't supported in a headless environment. @@ -28,7 +28,7 @@ It will also remove any features that require the `Customizer` which means that If you still want to have access to those pages then, you can disable this setting. -### Enabling Post and Category URL rewrites +### Enabling Post and Category URL Rewrites This option is controlled by the `Enable Post and Category URL rewrites` checkbox. When enabled it will perform domain replacement of all terms, post, preview, category links from your `WordPress URL` into your headless `Front-end site URL` by using @@ -44,7 +44,7 @@ will prevent the original content links from pointing to the headless url. > **NOTE:** It is recommended to keep this setting enabled so that all links will be properly served by the headless site. -### Enabling public route redirects +### Enabling Public Route Redirects This option is controlled by the `Enable public route redirects` checkbox. When enabled it will redirect any public API requests to your `WordPress URL` into your headless `Front-end site URL` by using @@ -58,7 +58,7 @@ then if you visit any page on your `WordPress URL` will be redirected to the hea If you don't want this redirect to happen then you can disable this option which allows you to access the original WP site. -### Using the WordPress domain for media URLs in post content +### Using the WordPress Domain for Media URLs in Post Content This option is controlled by the `Use the WordPress domain for media URLs in post content` checkbox and is disabled by default. When enabled it will perform a `src` and `srcset` replacement of all media urls of the sites post/page content using diff --git a/internal/faustjs.org/docs/getting-started.mdx b/internal/faustjs.org/docs/getting-started.mdx index dcbe41b3b..86159b093 100644 --- a/internal/faustjs.org/docs/getting-started.mdx +++ b/internal/faustjs.org/docs/getting-started.mdx @@ -43,7 +43,7 @@ You can now visit [http://localhost:3000](http://localhost:3000) to see your new Currently, the posts and pages you see are coming from our WordPress site at [https://faustexample.wpengine.com](https://faustexample.wpengine.com). In the next step, we'll show you how to hook up your own WordPress site. -## Connecting your WordPress site +## Connecting Your WordPress Site The example app above loads WordPress content from the demo site at [https://faustexample.wpengine.com](https://faustexample.wpengine.com). diff --git a/internal/faustjs.org/docs/migrationPath/overview.mdx b/internal/faustjs.org/docs/migrationPath/overview.mdx index 17912509d..a7c54667c 100644 --- a/internal/faustjs.org/docs/migrationPath/overview.mdx +++ b/internal/faustjs.org/docs/migrationPath/overview.mdx @@ -1,4 +1,7 @@ --- slug: /migrationPath/overview -title: Migrate from old version of Faust.js ( < v1.0.0 ) to Faust ( > v1.0.0 ) +title: Migration from Legacy Faust --- +Migrate from old version of Faust.js to new Faust + +### This document is in progress. Check back soon for content! \ No newline at end of file diff --git a/internal/faustjs.org/docs/next/guides/post-page-previews.mdx b/internal/faustjs.org/docs/next/guides/post-page-previews.mdx index 7e2557765..f4ef1754f 100644 --- a/internal/faustjs.org/docs/next/guides/post-page-previews.mdx +++ b/internal/faustjs.org/docs/next/guides/post-page-previews.mdx @@ -12,14 +12,14 @@ Your headless secret is a value that authenticates requests to WordPress. This s ### Copy your Headless Secret -Find your Headless Secret in **WP-Admin -> Settings -> Faust**. Copy this value: +Find your Headless Secret in `WP-Admin` -> `Settings` -> `Faust`. Copy this value: The Faust plugin admin interface with a red rectangle around the Secret Key field -### Add your Headless Secret to your `.env.local` File +### Add Your Headless Secret to Your `.env.local` File Add the `FAUSTWP_SECRET_KEY` key to your `.env.local` file with the headless secret as the value. Your `.env.local` file should already have a value for `NEXT_PUBLIC_WORDPRESS_URL`. The file should look something like this: @@ -31,7 +31,7 @@ NEXT_PUBLIC_WORDPRESS_URL=http://localhost:8080 FAUSTWP_SECRET_KEY=xxxx ``` -### Ensure you've created your `faust.config.js` file and are importing it in your `_app.js` +### Create Your `faust.config.js` File Import It In `_app.js` Like the [`next/getting-started`](https://github.com/wpengine/faustjs/tree/main/examples/next/faustwp-getting-started) Faust example, your [`faust.config.js`](https://github.com/wpengine/faustjs/blob/main/examples/next/faustwp-getting-started/faust.config.js) file. @@ -66,7 +66,7 @@ import { apiRouter } from '@faustwp/core'; export default apiRouter; ``` -## Create your Preview Page +## Create Your Preview Page With your headless secret set and the `authorizeHandler` ready to handle requests, you can now create a Next.js [page](https://nextjs.org/docs/basic-features/pages) for previews. Create a file at `pages/preview.js` with the following: @@ -127,7 +127,7 @@ if (props.loading) { If you don't handle the loading state you may find that the post/page data will be undefined. -### What happens if you don't use on the `asPreview` property? +### Is the `asPreview` Property Necessary? If you wish to disable post/page previews for a particular template hierarchy page you can simply ignore the `asPreview` parameter. @@ -135,16 +135,16 @@ If you wish to disable post/page previews for a particular template hierarchy pa Start by logging into your WordPress Admin. For this example, we'll create a new post. -So far, I've added a title and a simple line of text for the content. To view this post as a preview on your front end, click the **Preview** link (1). From there, click, **Preview in new tab** (2): +So far, I've added a title and a simple line of text for the content. To view this post as a preview on your front end, click the `Preview` link (1). From there, click, `Preview in new tab` (2): WordPress post page using the Gutenberg editor with a red arrow to the preview and preview in new tab dropdowns -Notice the **Publish** button is also visible, meaning that you still need to publish the post. Therefore you can now view the post on the frontend without being authenticated. +Notice the `Publish` button is also visible, meaning that you still need to publish the post. Therefore you can now view the post on the frontend without being authenticated. -Clicking on **Preview in new tab** should take you to your post preview page with the current preview content: +Clicking on `Preview in new tab` should take you to your post preview page with the current preview content: - Built on top of Next.js and React to take advantage of state-of-the-art - frontend tools - - ), - link: '/docs/next/getting-started', - }, - { - title: 'GraphQL', + title: 'Apollo', description: ( <> - Use GQty to fetch data from the WordPress GraphQL API without writing - GraphQL queries. + Flexibly perform declarative queries to manipulate and structure data + using Apollo. ), - link: '/docs/next/guides/fetching-data', + link: '/blog/the-future-of-faust#where-faustjs-is-going', }, { title: 'Previews', description: ( <> - Preview your posts and pages before publishing and rewrite WordPress + Preview posts and pages before publishing and rewrite WordPress preview URLs to your frontend. ), link: '/docs/next/guides/post-page-previews', }, - { - title: 'SSG and SSR', - description: ( - <> - Easily render pages on the server, or generate static pages at - build-time. - - ), - link: '/docs/next/guides/ssr-ssg', - }, - { - title: 'React Hooks', - description: ( - <>Fetch posts, categories, pages, and more using standard URL params. - ), - link: '/docs/next/reference/hooks', - }, { title: 'WP Template Hierarchy', description: ( <>Use chained requests, resolve custom post type templates, and more. ), - link: '', + link: '/docs/templates', }, { - title: 'Plugin System', + title: 'Seed Query', description: ( - <>Use plugins to add quick and flexible functionality to your product. + <> + Use a seed query to obtain a list of possible templates for any given + route. + ), - link: '', + link: '/docs/faustwp/seed-query', }, { - title: 'Custom Post Types', + title: 'Next.js', description: ( <> - Add custom post types to your WordPress site and easily fetch them from - your frontend. + Build a static site with WordPress data outside the template hierarchy with Next.js file based pages. ), - link: '/docs/next/guides/custom-post-types', + link: '/docs/next/reference/getNextStaticProps', }, ]; diff --git a/internal/faustjs.org/src/components/GetStarted/HomepageGetStarted.js b/internal/faustjs.org/src/components/GetStarted/HomepageGetStarted.js index e10c4c2b1..b23ba54d6 100644 --- a/internal/faustjs.org/src/components/GetStarted/HomepageGetStarted.js +++ b/internal/faustjs.org/src/components/GetStarted/HomepageGetStarted.js @@ -30,7 +30,7 @@ export default function HomepageGetStarted() {
+ to="/docs/getting-started"> Get Started
diff --git a/internal/legacy.faustjs.org/docusaurus.config.js b/internal/legacy.faustjs.org/docusaurus.config.js index 3cace0d22..736d3cbf9 100644 --- a/internal/legacy.faustjs.org/docusaurus.config.js +++ b/internal/legacy.faustjs.org/docusaurus.config.js @@ -16,6 +16,7 @@ module.exports = { favicon: 'img/favicon.ico', organizationName: 'wpengine', // Usually your GitHub org/user name. projectName: 'faustjs', // Usually your repo name. + noIndex: process.env.SITE_NO_INDEX ?? false, themeConfig: { algolia: { // If Algolia did not provide you any appId, use 'BH4D9OD16A' @@ -26,14 +27,14 @@ module.exports = { indexName: 'faustjs', }, - // announcementBar: { - // id: 'depreciation_notice', - // content: - // '⭐️ This version of Faust.js is being deprecated. Visit the new version at faustjs.org ⭐️', - // backgroundColor: '#7e5cef', - // textColor: '#FFF', - // isCloseable: false, - // }, + announcementBar: { + id: 'depreciation_notice', + content: + '⭐️ This version of Faust.js is being deprecated. Visit the new version at faustjs.org ⭐️', + backgroundColor: '#7e5cef', + textColor: '#FFF', + isCloseable: false, + }, navbar: { title: 'Faust.js™', // logo: { diff --git a/internal/legacy.faustjs.org/versioned_docs/version-development/changelog/core.mdx b/internal/legacy.faustjs.org/versioned_docs/version-development/changelog/core.mdx new file mode 100644 index 000000000..004b69397 --- /dev/null +++ b/internal/legacy.faustjs.org/versioned_docs/version-development/changelog/core.mdx @@ -0,0 +1,16 @@ +--- +slug: ./core +title: Changelog for @faustjs/core +description: A central place for Faust.js changelogs +--- + +import Changelog, { toc as ChangelogTOC } from '@site/.changelogs/core.md'; + + + +export const toc = (() => { + return ChangelogTOC.map((item) => { + item.children = []; + return item; + }); +})(); diff --git a/internal/legacy.faustjs.org/versioned_docs/version-development/changelog/faustwp.mdx b/internal/legacy.faustjs.org/versioned_docs/version-development/changelog/faustwp.mdx new file mode 100644 index 000000000..05cadb0d2 --- /dev/null +++ b/internal/legacy.faustjs.org/versioned_docs/version-development/changelog/faustwp.mdx @@ -0,0 +1,16 @@ +--- +slug: ./faustwp +title: Changelog for FaustWP +description: A central place for Faust.js changelogs +--- + +import Changelog, { toc as ChangelogTOC } from '@site/.changelogs/faustwp.md'; + + + +export const toc = (() => { + return ChangelogTOC.map((item) => { + item.children = []; + return item; + }); +})(); diff --git a/internal/legacy.faustjs.org/versioned_docs/version-development/changelog/next.mdx b/internal/legacy.faustjs.org/versioned_docs/version-development/changelog/next.mdx new file mode 100644 index 000000000..59aa6f352 --- /dev/null +++ b/internal/legacy.faustjs.org/versioned_docs/version-development/changelog/next.mdx @@ -0,0 +1,16 @@ +--- +slug: ./next +title: Changelog for @faustjs/next +description: A central place for Faust.js changelogs +--- + +import Changelog, { toc as ChangelogTOC } from '@site/.changelogs/next.md'; + + + +export const toc = (() => { + return ChangelogTOC.map((item) => { + item.children = []; + return item; + }); +})(); diff --git a/internal/legacy.faustjs.org/versioned_docs/version-development/changelog/react.mdx b/internal/legacy.faustjs.org/versioned_docs/version-development/changelog/react.mdx new file mode 100644 index 000000000..941556667 --- /dev/null +++ b/internal/legacy.faustjs.org/versioned_docs/version-development/changelog/react.mdx @@ -0,0 +1,16 @@ +--- +slug: ./react +title: Changelog for @faustjs/react +description: A central place for Faust.js changelogs +--- + +import Changelog, { toc as ChangelogTOC } from '@site/.changelogs/react.md'; + + + +export const toc = (() => { + return ChangelogTOC.map((item) => { + item.children = []; + return item; + }); +})(); diff --git a/internal/legacy.faustjs.org/versioned_docs/version-development/core/reference/config.mdx b/internal/legacy.faustjs.org/versioned_docs/version-development/core/reference/config.mdx new file mode 100644 index 000000000..a370769d7 --- /dev/null +++ b/internal/legacy.faustjs.org/versioned_docs/version-development/core/reference/config.mdx @@ -0,0 +1,102 @@ +--- +slug: /core/reference/config +title: Faust.js core package config +description: Faust.js provides a default configuration object for your site. +--- + +Faust.js provides a default configuration object for your site. +This object uses as a parameter when exporting the result of the +`coreConfig` in `faust.config.js`: + +```tsx +import { config as coreConfig } from '@faustjs/core'; + +if (!process.env.NEXT_PUBLIC_WORDPRESS_URL) { + console.error( + 'You must provide a NEXT_PUBLIC_WORDPRESS_URL environment variable, did you forget to load your .env.local file?', + ); +} + +/** + * @type {import("@faustjs/core").Config} + */ +export default coreConfig({ + wpUrl: process.env.NEXT_PUBLIC_WORDPRESS_URL, + apiClientSecret: process.env.FAUSTWP_SECRET_KEY, +}); +``` + +## Config + +The Config object has the following properties: + +### `wpUrl` + +type: `string` + +Required: `true` + +This is your WordPress URL. This is typically defined in your `.env` file as `NEXT_PUBLIC_WORDPRESS_URL`. + +### `apiClientSecret` + +type: `string` + +Required: `true` + +This is your Headless Secret key that can be retrieved from the FaustWP settings Dashboard. This is typically defined in your `.env` file as `FAUSTWP_SECRET_KEY`. + +### `gqlUrl` + +type: `string` + +Required: `false` + +This is the value to the URL pathname of your GraphQL endpoint. This defaults to [wpurl](#wpurl) + `/graphql`. + +### `apiBasePath` + +type: `string` + +Required: `false` + +This is the value of the base API path of your endpoints for this application. This defaults to `/api/faust`. + +### `authType` + +type: `redirect | local` + +Required: `false` + +This is the value of the type of authentication you want to use. It can have two possible values: `redirect` or `local`. +When `redirect` is set, the user being redirected to WordPress to authenticate. When `local` is set, +the user initiating a login request from the Next.js application, uses the `useLogin` returns an authorization code used to request a refresh and access token. +You can read more about the authentication strategies in the [auth guide](http://localhost:3000/docs/next/guides/auth) section of the docs. + +This defaults to `redirect`. + +### `loginPagePath` + +type: `string` + +Required: `false` + +This is the relative URL path of your frontend login page. This defaults to `/login`. + +### `disableLogging` + +type: `boolean` + +Required: `false` + +Set this value to `true` if you want to disable internal `console.log` statements. This defaults to `false`. + +### `applyRequestContext` + +type: `(url: string, init: RequestInit): Promise | RequestContext` + +Required: `false` + +Deprecated: `true` + +This property is not used anymore and has no effect. You should use this function in [getClient](/docs/next/guides/modifying-the-graphql-request) instead. This will be removed in subsequent versions of Faust.js. diff --git a/internal/legacy.faustjs.org/versioned_docs/version-development/faustwp/settings.mdx b/internal/legacy.faustjs.org/versioned_docs/version-development/faustwp/settings.mdx new file mode 100644 index 000000000..9f398ee07 --- /dev/null +++ b/internal/legacy.faustjs.org/versioned_docs/version-development/faustwp/settings.mdx @@ -0,0 +1,84 @@ +--- +slug: /faustwp/settings +title: FaustWP Plugin Headless Settings +description: This section describes the various WP Plugin Headless Settings. +--- + +The `Headless` page of the FaustWP Plugin (located within the WP Admin `Settings` Sidebar) +allows you to customize the behavior of the plugin by configuring certain features. We explain those features in detail: + + +## Features Explained + +The following options are available to enable/disabled based on your requirements: + +### Disabling WordPress theme admin pages + +This option is controlled by the `Disable WordPress theme admin pages` checkbox. +When enabled it removes certain wp-admin menu items that aren't supported in a headless environment. +For example, it will remove the following menu items: + +* `Appearance > Themes` +* `Appearance > Theme Editor` +* `Appearance > Widgets` +* `Appearance > Customize` + +It will also remove any features that require the `Customizer` which means that the +`Appearance` tab will only contain the menu options. + +If you still want to have access to those pages then, you can disable this setting. + +### Enabling Post and Category URL rewrites + +This option is controlled by the `Enable Post and Category URL rewrites` checkbox. When enabled it will +perform domain replacement of all terms, post, preview, category links from your `WordPress URL` into your headless `Front-end site URL` by using +relevant `link` filters. + +For example if your WP `WordPress URL` is `http://example.com` and your `Front-end site URL` is `http://headless.com` +then it will replace all post/page/category links to point to the headless `Front-end site URL`: + +`http://example.com/posts/category/recipes/` -> `http://headless.com/posts/category/recipes/` + +If you don't want this replacement to happen then you can disable this option which +will prevent the original content links from pointing to the headless url. + +> **NOTE:** It is recommended to keep this setting enabled so that all links will be properly served by the headless site. + +### Enabling public route redirects + +This option is controlled by the `Enable public route redirects` checkbox. When enabled it will +redirect any public API requests to your `WordPress URL` into your headless `Front-end site URL` by using +the [template_redirect](https://developer.wordpress.org/reference/hooks/template_redirect/) filter. + +For example if your WP `WordPress URL` is `http://example.com` and your `Front-end site URL` is `http://headless.com` +then if you visit any page on your `WordPress URL` will be redirected to the headless `Front-end site URL` passing any query params as well: + +`http://example.com/posts/welcome-to-the-gutenberg-editor/` -> `http://headless.com/posts/welcome-to-the-gutenberg-editor` + +If you don't want this redirect to happen then you can disable this option which allows you to access the original WP site. + + +### Using the WordPress domain for media URLs in post content + +This option is controlled by the `Use the WordPress domain for media URLs in post content` checkbox and is disabled by default. +When enabled it will perform a `src` and `srcset` replacement of all media urls of the sites post/page content using +the [the_content](https://developer.wordpress.org/reference/hooks/the_content/) filter to point back to the `WordPress URL` domain. + +For example, if your WP `WordPress URL` is `http://example.com` and your `Front-end site URL` is `http://headless.com` +then any images served from headless `Front-end site URL` will be rewritten to point to the `WordPress URL`: + +`http://headless.com/wp-content/uploads/2020/07/bird.png` -> `http://example.com/wp-content/uploads/2020/07/bird.png` + +This happens when a user migrates a classical WP site a root domain of `example.com` to `headless.com` +(to allow their headless front-end to be served from `example.com` and pull data from the WP instance that was moved to `headless.com`) +then all media URLs in post content will be wrong. + +If for example you uploaded images to the post content their image srcs will still point to `example.com/wp-content/uploads/2020/07/bird.png`, +resulting in a `404` because the WP instance no longer lives at `example.com`. + +You can enable this option to allow having the media content served by the classical +WP site a root domain and when you switch the live domain to headless, +you should disable the option to replace those links worrying about missing media. + +> **NOTE:** When moving your site to a new domain it is recommended to perform a search/replace on your website’s database. +This is to ensure all hard-coded references of the old domain in your database point to your live production domain instead. [Read more about search/replace](https://wpengine.com/support/move-domain-new-environment/#Optional_Perform_a_search_and_replace) diff --git a/internal/legacy.faustjs.org/versioned_docs/version-development/going-to-production/deployment.mdx b/internal/legacy.faustjs.org/versioned_docs/version-development/going-to-production/deployment.mdx new file mode 100644 index 000000000..5a7986675 --- /dev/null +++ b/internal/legacy.faustjs.org/versioned_docs/version-development/going-to-production/deployment.mdx @@ -0,0 +1,46 @@ +--- +slug: /going-to-production/deployment +title: Deploy Your Faust.js App +--- + +## Picking The Right Node.js Version + +Faust.js supports Node.js v14.x and v16.x. Please make sure you are using a Node.js version that is compatible when deploying to avoid unexpected errors. + +## Building Your App + +Faust.js is build on top of [Next.js](https://nextjs.org/), so the build process is identical. Take a look at the [Next.js Build API](https://nextjs.org/docs/deployment#nextjs-build-api) for info relating to how Next.js generates an optimized production build. + +## Deploying To Atlas + +Atlas is the most effortless way to deploy a Faust.js app. Connect your GitHub repo and Atlas will automatically build and deploy your Faust.js project on each push. Some of the benefits you get out of the box are: + +- Automatic installation of required plugins ([FaustWP](https://wordpress.org/plugins/faustwp/), [WPGraphQL](https://wordpress.org/plugins/wp-graphql/), etc.) +- Automatic setup of Faust.js environment variables +- Automatic configuration of FaustWP headless settings +- WordPress and your headless app live in the same place +- Automatic rebuilds on code changes +- Support for [custom domains](https://wpengine.com/support/add-domain-in-user-portal/) + +[Deploy your Faust.js app and try Atlas for free!](https://wpengine.com/atlas/#form) + +## Self Hosted + +You can also self host Faust.js apps on any hosting provider that supports Node.js. + +To self host your Faust.js app, you will need to first build the app, then start it. Make sure you have the `next build` and `next start` scripts specified in your `package.json` file: + +```json title="package.json" +{ + "scripts": { + "build": "next build", + "start": "next start" + } +} +``` + +Then, from the Node.js server run `npm run build` to build the app and `npm run start` to start it. + +## Related + +- [Next.js: Deployment](https://nextjs.org/docs/deployment) diff --git a/internal/legacy.faustjs.org/versioned_docs/version-development/going-to-production/optimizations.mdx b/internal/legacy.faustjs.org/versioned_docs/version-development/going-to-production/optimizations.mdx new file mode 100644 index 000000000..a110de4be --- /dev/null +++ b/internal/legacy.faustjs.org/versioned_docs/version-development/going-to-production/optimizations.mdx @@ -0,0 +1,55 @@ +--- +slug: /going-to-production/optimizations +title: Production Optimizations +--- + +Below you'll find some recommendations for optimizing your Faust.js app for production. + +- [Atlas Specific Optimizations](/docs/going-to-production/optimizations#atlas-specific-optimizations) +- [Use Static Site Generation (SSG) When Possible](/docs/going-to-production/optimizations#use-static-site-generation-ssg-when-possible) +- [Ensure Data Selections Are Placed Outside Conditionals](/docs/going-to-production/optimizations#ensure-data-selections-are-placed-outside-conditionals) +- [Next.js Production Optimizations](/docs/going-to-production/optimizations#nextjs-production-optimizations) + +## Atlas Specific Optimizations + +Atlas is the most effortless way to deploy a Faust.js app. Below are some recommendations for optimizing your app for production. + +### Disable Next.js Compression + +Compression is already handled for you in Atlas, so disabling it in your Faust.js app will offload the responsibility from the Node.js process. + +```js title="next.config.js" +const { withFaust } = require('@faustjs/next'); + +/** + * @type {import('next').NextConfig} + **/ +module.exports = withFaust({ + compress: false, +}); +``` + +## Use Static Site Generation (SSG) When Possible + +Static Site Generation (SSG) is a Next.js concept that generates a static HTML page for each page in your app that uses `getStaticProps`. This is incredibly efficient as you are not making wasteful requests to the WordPress GraphQL API, as your pages are already cached. Pairing SSG with Incremental Static Regeneration (ISR) will cause your pages to be regenerated in the background after a certain amount of time. [By default, Faust.js will revalidate your pages every 15 minutes.](/docs/next/guides/ssr-ssg#setting-up-incremental-static-regeneration-isr) + +Learn more: + +- [Next.js: Static Site Generation (SSG)](https://nextjs.org/docs/basic-features/data-fetching/get-static-props) +- [Next.js: Incremental Static Regeneration (ISR)](https://nextjs.org/docs/basic-features/data-fetching/incremental-static-regeneration) + +## Ensure Data Selections Are Placed Outside Conditionals + +Faust.js uses [GQty](https://gqty.dev/) as it's GraphQL client. GQty works by using [proxies](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) to determine what data selections you access from the `client`, and from there, constructs a GraphQL query. + +You should ensure that your data selections are all performed outside of conditionals (`if`, `switch`, etc. statements) so that GQty can detect them sever side. Data selections made inside of conditionals result in some GraphQL requests cascading to the client. This is appropriate when you need to fetch data specifically on the client side, but often times you wan't this data to be fetched server side where it can be cached. + +Refer to this GQty troubleshooting guide for ensuring that your data selections are outside of conditionals: + +- [GQty Troubleshooting: Data Selections & Conditionals](https://gqty.dev/docs/react/troubleshooting#data-selections--conditionals) + +## Next.js Production Optimizations + +Next.js has a "Going to Production" guide that goes into further detail on the optimizations you can make for your Faust.js app built on top of Next.js: + +- [Next.js: Going to Production](https://nextjs.org/docs/going-to-production#loading-performance) diff --git a/internal/legacy.faustjs.org/versioned_docs/version-development/gqty-intro.mdx b/internal/legacy.faustjs.org/versioned_docs/version-development/gqty-intro.mdx new file mode 100644 index 000000000..9b6ba1b8b --- /dev/null +++ b/internal/legacy.faustjs.org/versioned_docs/version-development/gqty-intro.mdx @@ -0,0 +1,81 @@ +--- +slug: /gqty-intro +title: Introduction to GQty +description: Introduction to GQty in Faust.js +--- + +Faust.js uses GQty under the hood for its GraphQL client. + +GQty is a new approach to a GraphQL client. Instead of defining queries by hand, GQty generates queries for you at runtime based on the data your app consumes. Take the following example: + +Your app consumes the `title` and `description` from `generalSettings`: + +```tsx title="Your App" +import { client } from 'client' + +export default function App() { + const query = client.useQuery() + + return( +

{query.generalSettings.title}

+

{query.generalSettings.description}

+ ) +} +``` + +The following query is automatically generated and requested for you: + +```graphql +query { + generalSettings { + title + description + } +} +``` + +## React Hooks + +GQty has React Hooks for fetching data, mutations, subscriptions, and more: + +- [useQuery](https://gqty.dev/docs/react/fetching-data#usequery) +- [usePaginatedQuery](https://gqty.dev/docs/react/fetching-data#usepaginatedquery) +- [useTransactionQuery](https://gqty.dev/docs/react/fetching-data#usetransactionquery) +- [useLazyQuery](https://gqty.dev/docs/react/fetching-data#uselazyquery) +- [useRefetch](https://gqty.dev/docs/react/fetching-data#userefetch) +- [useMutation](https://gqty.dev/docs/react/mutations#usemutation) +- [useSubscription](https://gqty.dev/docs/react/subscriptions#usesubscription) + +Faust.js exports these hooks from the `client`. You can use them in your React components like so: + +```tsx +import { client } from 'client'; + +export default function App() { + const { + useQuery, + usePaginatedQuery, + useTransactionQuery, + useLazyQuery, + useRefetch, + useMutation, + useSubscription, + } = client; + + return( + ... + ) +} +``` + +## Further Reading + +We recommend reading the ["What Is & Why"](https://gqty.dev/docs/intro) and ["How It Works"](https://gqty.dev/docs/intro/how-it-works) docs to get a better picture of how GQty works. + +Additionally, the following docs may be helpful: + +- [Features](https://gqty.dev/docs/intro/features) +- [Fetching Data in React](https://gqty.dev/docs/react/fetching-data) +- [React Suspense & Usage Without](https://gqty.dev/docs/react/suspense) +- [Helper Functions](https://gqty.dev/docs/client/helper-functions) +- [Troubleshooting](https://gqty.dev/docs/react/troubleshooting) diff --git a/internal/legacy.faustjs.org/versioned_docs/version-development/next/getting-started.mdx b/internal/legacy.faustjs.org/versioned_docs/version-development/next/getting-started.mdx new file mode 100644 index 000000000..b23b466e0 --- /dev/null +++ b/internal/legacy.faustjs.org/versioned_docs/version-development/next/getting-started.mdx @@ -0,0 +1,100 @@ +--- +slug: /next/getting-started +title: Getting Started with Next.js +--- + +# Getting Started with Next.js + +## Quick Start + +Please install our Next.js Getting Started example using the following command: + +### On MacOS, Linux, or WSL (bash): + +```bash +npx create-next-app \ + -e https://github.com/wpengine/faustjs/tree/main \ + --example-path examples/next/getting-started \ + --use-npm \ + my-app +cd my-app +``` + +### On Windows with [Powershell Core](https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-windows?view=powershell-7.1): + +```ps +npx create-next-app ` + -e https://github.com/wpengine/faustjs/tree/main ` + --example-path examples/next/getting-started ` + --use-npm ` + my-app && cd my-app +``` + +> NOTE: If you are on Windows, we suggest using [Powershell Core](https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-windows?view=powershell-7.1) and [Windows Terminal](https://www.microsoft.com/en-us/p/windows-terminal/9n0dx20hk701). + +Now, copy the sample environment template: + +```bash +cp .env.local.sample .env.local +``` + +Finally, run the dev server: + +```bash +npm run dev +``` + +You can now visit [http://localhost:3000](http://localhost:3000) to see the example site! + +

+

+ +Currently, the posts and pages you see are coming from our WordPress site at [https://headlessfw.wpengine.com](https://headlessfw.wpengine.com). In the next step, we'll show you how to hook up your own WordPress site. + +## Connecting your WordPress site + +The example app above loads WordPress content from the demo site at [https://headlessfw.wpengine.com](https://headlessfw.wpengine.com). + +To point it to a different WordPress site, first, [make sure you have setup the necessary WordPress plugins.](../tutorial/setup-faustjs#installing-plugins-on-wordpress) + +Once the necessary plugins have been installed, open the `.env.local` file you created earlier, it should look something like this: + +```bash +# Your WordPress site URL +NEXT_PUBLIC_WORDPRESS_URL=https://headlessfw.wpengine.com + +# Plugin secret found in WordPress Settings->Headless +FAUSTWP_SECRET_KEY=YOUR_PLUGIN_SECRET +``` + +Update the `NEXT_PUBLIC_WORDPRESS_URL` value with your WordPress site URL (be sure to include `http://` or `https://`). + +Additionally, update the `FAUSTWP_SECRET_KEY` value with the secret key found in Settings → Headless in your WordPress admin area to support previews. + +The FaustWP WordPress admin interface with a red rectangle around the Secret Key field + +## Setting Your Permalinks + +Finally, set your permalinks to the following structure in WP Admin -> Settings -> Permalinks: + +``` +/posts/%postname%/ +``` + +WordPress Admin Settings Page for Permalinks + +You can learn more about modifying your permalink structure by viewing the [Permalinks Guide](/docs/next/guides/permalinks). diff --git a/internal/legacy.faustjs.org/versioned_docs/version-development/next/guides/authentication.mdx b/internal/legacy.faustjs.org/versioned_docs/version-development/next/guides/authentication.mdx new file mode 100644 index 000000000..8c782e107 --- /dev/null +++ b/internal/legacy.faustjs.org/versioned_docs/version-development/next/guides/authentication.mdx @@ -0,0 +1,248 @@ +--- +slug: /next/guides/auth +title: Authentication +description: Use Faust.js' built-in authentication strategies to authenticate users from your WordPress backend +--- + +import BaseUrlNotice from '@site/src/mdx/base-url-notice.mdx'; + + + +Authentication can be a cumbersome process when building headless WordPress sites. Thankfully, Faust.js takes care of all your authentication needs in your Next.js application. + +## How It Works + +**TL;DR**: Authentication in Faust.js can happen in five main steps: + +1. User initiates request to authenticate data. +2. Faust.js facilitates the request for an authorization code from the FaustWP plugin. This code is a short-lived token used to request a refresh and access token. +3. Faust.js facilitates a refresh and access token request from the FaustWP plugin using the authorization code. +4. Faust.js stores the refresh token in a secure, HTTP-only cookie. The token refresh requests a new access token when the current one expires +5. Faust.js stores the access token in memory that you can use in subsequent authenticated requests. + +## Initial Setup + +Before you get started with implementing an authentication strategy, you'll need to setup the API Router. You can do this by creating a file, `src/pages/api/faust/[[...route]].ts`, with the following code: + +```ts title=src/pages/api/faust/[[...route]].ts +import 'faust.config'; +import { apiRouter } from '@faustjs/core/api'; + +export default apiRouter; +``` + +## Strategies + +There are two authentication strategies available in Faust.js: `redirect` and `local`. + +### Redirect Based Authentication + + + Diagram of the redirect based authentication flow + + +Redirect-based authentication is the default strategy in Faust.js. This strategy involves the user being redirected to WordPress to authenticate. Once the user has shown, the user redirects back to the Next.js application with an authorization code you can then use to request a refresh and access token, thus completing the login process. + +This strategy is excellent for use cases where your authenticated users are admins/editors/etc. and do not necessarily need a "white label" login/register experience. Typically, you would use the redirect strategy if your primary reason for authentication is previewing. + +Since Redirect based authentication is the default authentication method, there is no configuration needed on your end to use it. It comes out of the box, and you'll see it in action when using previews or the [`useAuth`](/docs/next/reference/hooks/useAuth) hook. + +### Local Based Authentication + + + Diagram of the local based authentication flow + + +Local Based Authentication is the second strategy available in Faust.js. This strategy involves the user initiating a login request from the Next.js application via the `useLogin` hook. Upon successful login, `useLogin` returns an authorization code used to request a refresh and access token, thus completing the login process. + +This strategy is excellent for use cases where you want to support a more "white label" login/register experience. This strategy routes un-authenticated requests to your specified Next.js login page. In addition, users who wish to login/register will not have to interact with WordPress or the WordPress backend at all, giving you the flexibility to implement and fine-tune your user flow. + +To use this strategy, you'll need to configure your `faust.config.js` file to use the `local` authentication strategy, in addition to the route of your Next.js login page. Take the following `faust.config.js` file, for example: + +```TSX title=faust.config.js {15,16} +import { config as coreConfig } from '@faustjs/core'; + +if (!process.env.NEXT_PUBLIC_WORDPRESS_URL) { + console.error( + 'You must provide a NEXT_PUBLIC_WORDPRESS_URL environment variable, did you forget to load your .env.local file?', + ); +} + +/** + * @type {import("@faustjs/core").Config} + */ +export default coreConfig({ + wpUrl: process.env.NEXT_PUBLIC_WORDPRESS_URL, + apiClientSecret: process.env.FAUSTWP_SECRET_KEY, + authType: 'local', + loginPagePath: '/login', +}); +``` + +We define the `authType` to `local` to indicate to the Faust.js config that we use the `local` strategy for authentication. We also describe the `loginPagePath` to `/login` to mark the route of the Next.js login page. This strategy redirects unauthenticated requests to the `/login` route in your Next.js application. + +In your `login.tsx` page, you could take advantage of the `useLogin` hook to initiate a login request to the WordPress backend: + +```tsx title=pages/login.tsx {9,18} +import { client } from 'client'; +import { useState } from 'react'; + +export default function Login() { + const { useLogin } = client.auth; + const [usernameEmail, setUserNameEmail] = useState(''); + const [password, setPassword] = useState(''); + + const { login, isLoading, data, error } = useLogin(); + + const errorMessage = data?.error || error?.message; + + return ( +
{ + e.preventDefault(); + + login(usernameEmail, password); + }} + > +
+
+ +
+
+ setUserNameEmail(e.target.value)} + id="usernameEmail" + /> +
+ +
+ +
+
+ setPassword(e.target.value)} + id="password" + /> +
+ +
+ +
+
+ + {errorMessage ?

Error: {errorMessage}

: null} +
+ ); +} +``` + +The `useLogin` hook exports an object with the following properties: + +- `login`: a function that initiates a request to the WordPress backend for an authorization code that accepts two arguments: `usernameEmail`, which is either the user's username or email as a string, and `password` as a string. +- `isLoading`: a boolean that indicates whether the login request is in progress. +- `data`: the response data from the login request. +- `error`: the error from the login request. + +For a more detailed explanation of the `useLogin` hook, see the [`useLogin` hook docs](/docs/next/reference/hooks/useLogin) . + +Upon successful login, a secure, HTTP only cookie stores a refresh token and the access token in memory for subsequent authenticated requests. You can confirm a login request succeeded by checking for the `code` property in the `data` object. + +Additionally, if the login page URL contains a `redirect_uri` query parameter, it will redirect the user to the specified URL upon successful login. + +Finally, you can create a `logout.tsx` page to handle logout requests. This is done by using the `useLogout` hook: + +```tsx title="src/pages/logout.tsx" +import { client } from 'client'; +import { useRouter } from 'next/router'; +import { useEffect } from 'react'; +export default function Logout() { + const router = useRouter(); + const { isLoggedOut, logout } = client.auth.useLogout(); + useEffect(() => { + if (isLoggedOut !== undefined) { + return; + } + + // Initiate the logout process. + // This could also be called on a button click, for example, in a nav menu. + logout(); + }, [isLoggedOut, logout]); + + useEffect(() => { + if (isLoggedOut) { + // The user was successfully logged out. Redirect them. + router.push('/'); + } + }, [router, isLoggedOut]); + return <>Logging out...; +} +``` + +The `useLogout` hook exports an object with the following properties: + +- `logout`: a function that initiates a request to the logout middleware to remove the refresh token from the cookie. +- `isLoading`: a boolean that indicates whether the logout request is in progress. +- `isLoggedOut`: a boolean that indicates whether the logout request was successful. + +