Skip to content

Commit db6908f

Browse files
Fix tutorial code typo (#2119)
Co-authored-by: Alex Moon <[email protected]>
1 parent f15d320 commit db6908f

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

docs/tutorial/learn-faust/index.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
title: "Learn Faust.js"
3-
description: "Tutorial to learn about the core features of Faust.js."
2+
title: 'Learn Faust.js'
3+
description: 'Tutorial to learn about the core features of Faust.js.'
44
---
55

66
This tutorial introduces you to the core features of Faust.js. You'll begin with a pre-configured Next.js project and learn how to implement these features yourself:
@@ -98,7 +98,7 @@ By referencing the template hierarchy image above, you can see that we can targe
9898
Copy the `gql` import and the `SingleTemplate` component from `wp-templates/single.js` and paste them into `wp-templates/page.js`. Rename the `SingleTemplate` component to `PageTemplate`. Our new page template should now look like this:
9999

100100
```jsx title="wp-templates/page.js"
101-
import { gql } from "@apollo/client";
101+
import { gql } from '@apollo/client';
102102

103103
export default function PageTemplate(props) {
104104
const { title, content } = props.data.page;
@@ -117,7 +117,7 @@ You can see that the `PageTemplate` component receives the props passed into it,
117117
Next, copy the `SingleTemplate.query` and `SingleTemplate.variables` assignments from `wp-templates/single.js` and paste them into `wp-templates/page.js`. rename them to `PageTemplate.query` and `PageTemplate.variables`. The new page template should now look like this:
118118

119119
```jsx title="wp-templates/page.js"
120-
import { gql } from "@apollo/client";
120+
import { gql } from '@apollo/client';
121121

122122
export default function PageTemplate(props) {
123123
const { title, content } = props.data.page;
@@ -153,8 +153,8 @@ The `PageTemplate.variables` function takes the `uri` for the current page and m
153153
The last step is to make Faust aware of our new template. To do this, open `wp-templates/index.js` and add these lines:
154154
155155
```js
156-
import SingleTemplate from "./single";
157-
import PageTemplate from "./page"; // [!code ++]
156+
import SingleTemplate from './single';
157+
import PageTemplate from './page'; // [!code ++]
158158
159159
const templates = {
160160
single: SingleTemplate,
@@ -198,9 +198,9 @@ This tells React to render a "Loading" message if the component is still loading
198198
Update the `Component.variables` function to return a new `asPreview` variable that is set to the value of `ctx?.asPreview`:
199199
200200
```jsx title="src/wp-templates/single.js"
201-
SingleTemplate.variables = ({ databaseId }, ctx) => {
201+
SingleTemplate.variables = (seedQuery, ctx) => {
202202
return {
203-
databaseId,
203+
uri: seedQuery?.uri,
204204
asPreview: ctx?.asPreview, // [!code ++]
205205
};
206206
};
@@ -222,7 +222,7 @@ SingleTemplate.query = gql`
222222
Your `single` template file should now look like this:
223223
224224
```jsx title="src/wp-templates/single.js"
225-
import { gql } from "@apollo/client";
225+
import { gql } from '@apollo/client';
226226

227227
export default function SingleTemplate(props) {
228228
const { title, content } = props.data.post;
@@ -320,7 +320,7 @@ Finally, replace the `<div dangerouslySetInnerHTML={{ __html: content }} />` lin
320320
```jsx title="src/wp-templates/single.js"
321321
<div>
322322
{editorBlocks.map((block, index) => {
323-
if (block.name === "core/paragraph") {
323+
if (block.name === 'core/paragraph') {
324324
return (
325325
<div
326326
key={index}
@@ -355,7 +355,7 @@ export default function SingleTemplate(props) {
355355
<div>
356356
{editorBlocks.map((block, index) => {
357357
console.log(block);
358-
if (block.name === "core/paragraph") {
358+
if (block.name === 'core/paragraph') {
359359
return (
360360
<div
361361
key={index}
@@ -396,8 +396,7 @@ Reload the http://localhost:3000/blog/hello-world/ page in your frontend app and
396396
padding-right: var(--wp--preset--spacing--40);
397397
padding-bottom: var(--wp--preset--spacing--20);
398398
padding-left: var(--wp--preset--spacing--40);
399-
"
400-
>
399+
">
401400
Welcome to WordPress. This is your first post. Edit or delete it, then start
402401
writing!
403402
</p>

0 commit comments

Comments
 (0)