Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 15 additions & 0 deletions docs/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ const config = {
showLastUpdateAuthor: true,
editUrl: 'https://github.com/10up/headstartwp/tree/trunk/docs',
sidebarCollapsed: false,
versions: {
current: {
label: 'App Router',
path: 'app-router',
},
'pages-router': {
label: 'Pages Router',
// path: 'pages-router',
},
},
},
],
[
Expand Down Expand Up @@ -123,6 +133,11 @@ const config = {
label: 'API Reference',
docsPluginId: 'docs',
},
{
type: 'docsVersionDropdown',
position: 'left',
dropdownActiveClassDisabled: true,
},
],
},
announcementBar: {
Expand Down
37 changes: 37 additions & 0 deletions docs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
sidebar_label: Quick Setup
slug: /getting-started/quick-setup
sidebar_position: 0
---

# Quick Setup

If you're new to Next.js, we recommend reviewing [Next.js docs](https://nextjs.org/docs/getting-started).

## System Requirements

- Node.js 16 or later
- NPM >= 7
- WordPress >= 5.9 (prior versions might work but haven't been tested).

## Installation

The easiest way to get started with HeadstartWP is by using `create-next-app` with the official starter project.

```bash
npx create-next-app --use-npm -e https://github.com/10up/headstartwp/tree/trunk/projects/wp-nextjs
```
Then run `npm run dev` and open http://localhost:3000 in your browser.

### Environment Variables

By default, the starter project will point to `js1.10up.com`. Either change the
`NEXT_PUBLIC_HEADLESS_WP_URL` variable or create a `.env.local` file to override the default env variables.

If you're developing locally and using HTTPS with WordPress and you don't have valid certs, you will need to add `NODE_TLS_REJECT_UNAUTHORIZED=0` as an env variable

```
NEXT_PUBLIC_HEADLESS_WP_URL=https://wordpress.test
NODE_TLS_REJECT_UNAUTHORIZED=0
```

## Something Missing?

If something is missing in the documentation or if you found some part confusing, please file an [issue](https://github.com/10up/headstartwp/issues) for the documentation repository with your suggestions for improvement.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ The `usePost` hook is one of the framework's data-fetching hooks. As its name su

> Extracting the *slug* from the url **only** works when using the `[...path].js` or `[[...path]].js `catch-all route style.

![SPA Data Fetching](../../static/img/spa-data-fetching-1.gif)
![SPA Data Fetching](../../../static/img/spa-data-fetching-1.gif)

Without server-side data fetching, the experience gets clunky and web vitals are greatly affected as there will be a high CLS. SEO is also affected since there is no content or SEO meta tags until the browser fetches the data.

Expand Down Expand Up @@ -160,7 +160,7 @@ Take some time to review the other routes, did you spot the pattern?

As you might have noticed, the category route is not handling errors and loading states on the client. Therefore it assumes the data will always be pre-fetched on the server. If you remove `getServerSideProps`, you will see the following error.

![data-error](../../static/img/error.png)
![data-error](../../../static/img/error.png)

At 10up, we strongly believe that a great developer experience increases developer productivity! Therefore the framework will try to help you, the developer, as much as it can.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export default async function handler(req, res) {

The framework supports ISR revalidation triggered by WordPress. To enable ISR revalidate, make sure you have the WordPress plugin enabled and activate the option in WordPress settings.

![ISR Option](../../static/img/revalidate-option.png)
![ISR Option](../../../static/img/revalidate-option.png)

Then add the `revalidateHandler` to `src/pages/api/revalidate.js`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ Make sure to set up the path for installing this as a WordPress Plugin:

Go to `Settings -> General` and scroll down until you find the "Headless Frontend URL" and enter the URL for the Headless site.

![Plugin settings](../../static/img/documentation/getting-started/plugin-settings.png)
![Plugin settings](../../../static/img/documentation/getting-started/plugin-settings.png)
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,4 @@ const RNImageBlock = ({ domNode, height, width, src }) => {

The demo app should render something like this

![Blocks App](../../static/img/blocks-app.png)
![Blocks App](../../../static/img/blocks-app.png)
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,6 @@ import {
```

You should see something like this
![Debug Blocks](../../static/img/debug-blocks.png)
![Debug Blocks](../../../static/img/debug-blocks.png)

By inspecting the props you can see you have access to things like block name, className, and even the Gutenberg attributes. You could, in theory, build your implementation for every block without loading any of the default Gutenberg styles, shipping your own component library/design system.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ When using locales make sure to add the locale to `Settings -> General -> Headle

As an example, the first site config in the example above would need the following settings in WordPress.

![Plugin settings Multisite Locale](../../static/img/documentation/wordpress-integration/multisite-locale.png)
![Plugin settings Multisite Locale](../../../static/img/documentation/wordpress-integration/multisite-locale.png)


### Middleware
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ HeadstartWP supports Next.js ISR via the WordPress plugin and via `@10up/next-re
### Plugin setup

HeadstartWP supports On-Demand Revalidation and it requires installing the WordPress Plugin. On-Demand Revalidation is opt-in and must be manually enabled in the plugin's settings (Settings -> General).
![Plugin settings](../../static/img/documentation/getting-started/plugin-settings.png)
![Plugin settings](../../../static/img/documentation/getting-started/plugin-settings.png)

The plugin expects the revalidate endpoint to live at `/api/revalidate`. It is possible to customize this endpoint via the `tenup_headless_isr_revalidate_endpoint`.

Expand Down Expand Up @@ -79,7 +79,7 @@ If you are hosting on Vercel you do not need this package.

Our solution to this problem has been to replace the filesystem cache with a redis cache provider. So whenever Next.js revalidates a page instead of storing the static page in disk, it will write to a shared redis instance that all of the containers would be talking to. The diagram below exemplifies how it works.

![Plugin settings](../../static/img/documentation/wordpress-integration/next-redis-cache-provider.png)
![Plugin settings](../../../static/img/documentation/wordpress-integration/next-redis-cache-provider.png)

To set up `@10up/next-redis-cache-provider` first install it via npm:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ Note that the link is converted to a relative link to remove the WordPress domai

To test this, open a page. Then, check which bucket you’re in

![AB Test bucket](../../static/img/a-b-test-1.png)
![AB Test bucket](../../../static/img/a-b-test-1.png)

In the example above, I was assigned the “mpa” bucket I should see a full page reload when navigating to internal links inside the post content. You can change to the “spa” bucket by modifying the cookie.


![AB Test Link](../../static/img/a-b-testing-link.gif)
![AB Test Link](../../../static/img/a-b-testing-link.gif)
8 changes: 8 additions & 0 deletions docs/versioned_docs/version-pages-router/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
sidebar_position: 0
sidebar_label: Introduction
---

# Introduction

Welcome to HeadstartWP documentation site! If you are new, we highly recommend reading all the way through [Getting Started](/learn/getting-started/quick-setup/) first.
8 changes: 8 additions & 0 deletions docs/versioned_sidebars/version-pages-router-sidebars.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"tutorialSidebar": [
{
"type": "autogenerated",
"dirName": "."
}
]
}
1 change: 1 addition & 0 deletions docs/versions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["pages-router"]
Loading