Skip to content

Commit 5451cd3

Browse files
committed
feat(wordpress): add defaultLanguage option
1 parent f046a67 commit 5451cd3

File tree

23 files changed

+542
-524
lines changed

23 files changed

+542
-524
lines changed

.eslintrc.json

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
{
22
"root": true,
3-
"parser": "babel-eslint",
4-
"extends": ["airbnb", "prettier"],
5-
"env": {
6-
"jest": true,
7-
"browser": false
8-
},
3+
"extends": ["smooth", "smooth/project", "smooth/react"],
94
"rules": {
10-
"no-restricted-syntax": "off",
11-
"no-nested-ternary": "off",
12-
"no-plusplus": "off",
13-
"no-param-reassign": "off",
145
"no-underscore-dangle": [
156
"error",
167
{
@@ -23,20 +14,11 @@
2314
]
2415
}
2516
],
26-
"react/jsx-filename-extension": ["error", { "extensions": [".js"] }],
27-
"react/jsx-wrap-multilines": "off",
28-
"react/no-unused-state": "off",
29-
"react/destructuring-assignment": "off",
30-
"react/prop-types": "off",
31-
"react/no-array-index-key": "off",
32-
"react/no-danger": "off",
33-
"import/prefer-default-export": "off",
3417
"import/no-unresolved": [
3518
"error",
3619
{
3720
"ignore": ["__smooth"]
3821
}
39-
],
40-
"jsx-a11y/html-has-lang": "off"
22+
]
4123
}
4224
}

package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
},
1616
"devDependencies": {
1717
"@babel/cli": "^7.2.3",
18-
"@babel/core": "^7.3.3",
19-
"@babel/plugin-proposal-class-properties": "^7.3.3",
20-
"@babel/preset-env": "^7.3.1",
18+
"@babel/core": "^7.3.4",
19+
"@babel/plugin-proposal-class-properties": "^7.3.4",
20+
"@babel/preset-env": "^7.3.4",
2121
"@babel/preset-react": "^7.0.0",
2222
"@loadable/babel-plugin": "^5.6.0",
2323
"babel-core": "^7.0.0-bridge.0",
@@ -26,14 +26,16 @@
2626
"conventional-github-releaser": "^3.1.2",
2727
"cross-env": "^5.2.0",
2828
"doctoc": "^1.4.0",
29-
"eslint": "^5.14.1",
29+
"eslint": "^5.15.0",
3030
"eslint-config-airbnb": "^17.1.0",
31-
"eslint-config-prettier": "^4.0.0",
31+
"eslint-config-prettier": "^4.1.0",
32+
"eslint-config-smooth": "^2.0.0",
3233
"eslint-plugin-import": "^2.16.0",
3334
"eslint-plugin-jsx-a11y": "^6.2.1",
3435
"eslint-plugin-react": "^7.12.4",
36+
"eslint-plugin-react-hooks": "^1.4.0",
3537
"jest": "^24.1.0",
36-
"lerna": "^3.13.0",
38+
"lerna": "^3.13.1",
3739
"prettier": "^1.16.4",
3840
"react": "^16.8.3",
3941
"react-dom": "^16.8.3",

packages/smooth-backend-wordpress/src/acf/api.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ function paramsSerializer(params) {
1313
return qs.stringify(params, { arrayFormat: 'indices' })
1414
}
1515

16-
export function createClient(baseUrl) {
16+
export function createClient({ baseUrl, defaultLanguage }) {
1717
return {
1818
async getContents({ type, slug, lang, query }) {
1919
type = type.toLowerCase()
20-
const params = getParams({ lang, type, query })
20+
const params = getParams({ lang: lang || defaultLanguage, type, query })
2121

2222
if (slug) {
2323
params.slug = slug
@@ -40,7 +40,7 @@ export function createClient(baseUrl) {
4040
return results[0] || null
4141
},
4242
async getContentPreview({ lang, id }) {
43-
const params = getParams({ lang })
43+
const params = getParams({ lang: lang || defaultLanguage })
4444
const { data } = await axios.get(
4545
`${baseUrl}/wp-json/presspack/v1/preview/${id}/`,
4646
{ params },

packages/smooth-backend-wordpress/src/acf/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ export async function onBuild({ schemaDefinition, options, types: gqlTypes }) {
2727
}
2828

2929
export async function getContent({ request, options }) {
30-
const apiClient = createClient(options.baseUrl)
30+
const apiClient = createClient(options)
3131
return apiClient.getContent(request)
3232
}
3333

3434
export async function getContents({ request, options }) {
35-
const apiClient = createClient(options.baseUrl)
35+
const apiClient = createClient(options)
3636
return apiClient.getContents(request)
3737
}

packages/smooth-backend-wordpress/src/acf/resolvers/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function createResolvers({
2424
schemaDefinition,
2525
config,
2626
}) {
27-
const apiClient = createClient(options.baseUrl)
27+
const apiClient = createClient(options)
2828
const { typeDefs } = schemaDefinition
2929
const blockDefinitions = typeDefs.definitions.filter(
3030
typeDefinition =>

packages/smooth-dev-cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"react-dom": ">=16.3.0"
3333
},
3434
"dependencies": {
35-
"@babel/runtime": "^7.3.1",
35+
"@babel/runtime": "^7.3.4",
3636
"chokidar": "^2.1.2",
3737
"configstore": "^4.0.0",
3838
"fs-extra": "^7.0.1",

packages/smooth/package.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,28 @@
3333
"react-dom": ">=16.8.0"
3434
},
3535
"dependencies": {
36-
"@babel/core": "^7.3.3",
37-
"@babel/plugin-proposal-class-properties": "^7.3.3",
38-
"@babel/plugin-transform-runtime": "^7.2.0",
36+
"@babel/core": "^7.3.4",
37+
"@babel/plugin-proposal-class-properties": "^7.3.4",
38+
"@babel/plugin-transform-runtime": "^7.3.4",
3939
"@babel/polyfill": "^7.2.5",
40-
"@babel/preset-env": "^7.3.1",
40+
"@babel/preset-env": "^7.3.4",
4141
"@babel/preset-react": "^7.0.0",
4242
"@babel/register": "^7.0.0",
43-
"@babel/runtime": "^7.3.1",
43+
"@babel/runtime": "^7.3.4",
4444
"@emotion/core": "^10.0.7",
4545
"@loadable/babel-plugin": "^5.6.0",
4646
"@loadable/component": "^5.6.1",
4747
"@loadable/server": "^5.6.1",
4848
"@loadable/webpack-plugin": "^5.5.0",
49-
"apollo-cache-inmemory": "^1.4.3",
50-
"apollo-client": "^2.4.13",
49+
"apollo-cache-inmemory": "^1.5.1",
50+
"apollo-client": "^2.5.1",
5151
"apollo-link": "^1.2.8",
5252
"apollo-link-http": "^1.5.11",
5353
"apollo-link-schema": "^1.1.6",
54-
"apollo-server-express": "^2.4.6",
54+
"apollo-server-express": "^2.4.8",
5555
"axios": "^0.18.0",
5656
"babel-loader": "^8.0.5",
57-
"camelcase": "^5.0.0",
57+
"camelcase": "^5.1.0",
5858
"commander": "^2.19.0",
5959
"cors": "^2.8.5",
6060
"cwd": "^0.10.0",
@@ -70,13 +70,13 @@
7070
"merge-deep": "^3.0.2",
7171
"pluralize": "^7.0.0",
7272
"progress-estimator": "^0.2.2",
73-
"query-string": "^6.2.0",
74-
"react-apollo": "^2.4.1",
73+
"query-string": "^6.3.0",
74+
"react-apollo": "^2.5.1",
7575
"react-helmet": "^5.2.0",
7676
"react-router-dom": "^4.3.1",
7777
"slugify": "^1.3.4",
7878
"tiny-glob": "^0.2.6",
79-
"webpack": "^4.29.5",
79+
"webpack": "^4.29.6",
8080
"webpack-dev-middleware": "^3.6.0",
8181
"webpack-hot-middleware": "^2.24.3",
8282
"webpack-node-externals": "^1.7.2"
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
{
2-
"env": {
3-
"browser": true
4-
}
2+
"extends": ["smooth/browser"]
53
}

packages/smooth/src/config/webpack.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,13 @@ function getTargetConfig(target, { config, dev }) {
7979
},
8080
externals:
8181
target === 'node'
82-
? [nodeExternals({ whitelist: [/^smooth\//] })]
82+
? [
83+
nodeExternals({ whitelist: [/^smooth\//] }),
84+
'graphql/type',
85+
'graphql/language',
86+
'graphql/execution',
87+
'graphql/validation',
88+
]
8389
: undefined,
8490
output: {
8591
path: path.join(config.cachePath, target, 'static'),

packages/smooth/src/content/Query.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function Handler({ children, ...props }) {
7272
if (hiddenRouter && !props.loading) {
7373
hiddenRouter.onPrefetched()
7474
}
75-
}, [props.loading])
75+
}, [props.loading]) // eslint-disable-line react-hooks/exhaustive-deps
7676

7777
if (!props.loading && !props.error && !props.data.contentProps) {
7878
return children({

0 commit comments

Comments
 (0)