Skip to content

Commit ca31156

Browse files
committed
refactor: various improvements
1 parent 14bd284 commit ca31156

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+950
-1227
lines changed

.eslintrc.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@
1414
"no-underscore-dangle": [
1515
"error",
1616
{
17-
"allow": ["__SMOOTH_ERROR__", "__APOLLO_STATE__", "__schema"]
17+
"allow": [
18+
"__SMOOTH_ERROR__",
19+
"__APOLLO_STATE__",
20+
"__schema",
21+
"__smooth_pages",
22+
"__smooth_blocks"
23+
]
1824
}
1925
],
2026
"react/jsx-filename-extension": ["error", { "extensions": [".js"] }],

examples/wordpress/.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
/wordpress/wp-content/plugins/smooth-js
33
/wordpress/wp-content/themes/smooth-js
44
/wordpress/wp-content/themes/twenty*
5-
/wordpress/wp-content/themes/akismet
6-
/wordpress/wp-content/themes/hello.php
5+
/wordpress/wp-content/plugins/akismet
6+
/wordpress/wp-content/plugins/hello.php

examples/wordpress/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
"graphql-tag": "^2.10.0",
55
"react": "^16.7.0",
66
"react-dom": "^16.7.0",
7-
"smooth-backend-wordpress": "../../packages/smooth-backend-wordpress",
8-
"smooth-core": "../../packages/smooth-core",
9-
"smooth-dev-cli": "../../packages/smooth-dev-cli"
7+
"smooth-backend-wordpress": "^0.1.1-alpha.2",
8+
"smooth-core": "^0.1.1-alpha.2"
109
}
1110
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React from 'react'
2+
import gql from 'graphql-tag'
3+
4+
export const blockFragment = gql`
5+
fragment SimpleBlockProps on SimpleBlock {
6+
text
7+
}
8+
`
9+
10+
export default function SimpleBlock({ text }) {
11+
return <div>{text}</div>
12+
}

examples/wordpress/src/contents/Book.js renamed to examples/wordpress/src/pages/books.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react'
22
import gql from 'graphql-tag'
33

44
export const contentFragment = gql`
5-
fragment BookFragment on Book {
5+
fragment BookProps on Book {
66
name
77
}
88
`

examples/wordpress/src/pages/foo$.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default () => 'hello'

examples/wordpress/src/contents/Page.js renamed to examples/wordpress/src/pages/index.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import React from 'react'
22
import gql from 'graphql-tag'
3+
import { BlockFragment, Blocks } from 'smooth-core/blocks'
34

45
export const contentFragment = gql`
5-
fragment PageFragment on Page {
6+
fragment PageProps on Page {
67
title
78
date
89
dateTime
@@ -21,23 +22,24 @@ export const contentFragment = gql`
2122
}
2223
name
2324
}
25+
link {
26+
url
27+
}
28+
blocks {
29+
...BlockFragment
30+
}
2431
}
32+
33+
${BlockFragment}
2534
`
2635

27-
export default function Page({
28-
title,
29-
book,
30-
specificBook,
31-
allBooks,
32-
...props
33-
}) {
34-
console.log(props)
36+
export default function Page({ title, book, specificBook, allBooks, blocks }) {
3537
return (
3638
<div>
3739
<h2>Title</h2>
3840
<div>{title}</div>
3941
<h2>ACF book</h2>
40-
<div>{book.name}</div>
42+
<div>{book && book.name}</div>
4143
<h2>Specific book</h2>
4244
<div>{specificBook && specificBook.name}</div>
4345
<h2>All books</h2>
@@ -46,6 +48,7 @@ export default function Page({
4648
<li key={b.metadata.id}>{b.name}</li>
4749
))}
4850
</ul>
51+
<Blocks blocks={blocks} />
4952
</div>
5053
)
5154
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import gql from 'graphql-tag'
2+
3+
export const typeDefs = gql`
4+
type SimpleBlock @block {
5+
text: String @field
6+
}
7+
`
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import gql from 'graphql-tag'
22

33
export const typeDefs = gql`
4-
type Book @model {
4+
type Book @content {
55
name: String @field
66
}
77
`

examples/wordpress/src/schemas/models/Page.js renamed to examples/wordpress/src/schemas/contents/Page.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import gql from 'graphql-tag'
22

33
export const typeDefs = gql`
4-
type Page @model {
4+
type Page @content {
55
title: String @field
66
book: Book @field
77
specificBook: Book
88
allBooks: [Book]
99
date: Date @field
1010
dateTime: DateTime @field
11+
link: Link @field
12+
blocks: [Block] @field
1113
}
1214
`
1315

0 commit comments

Comments
 (0)