From 8461fa59db5bee1039574d17682fd70514948e16 Mon Sep 17 00:00:00 2001 From: Benaiah Mischenko Date: Wed, 6 Dec 2017 22:28:54 -0800 Subject: [PATCH] Update formatting script and format CMS JS --- cms/cms.js | 196 ++++++++++++++++++++++++------------------ cms/webpack.config.js | 24 +++--- package.json | 5 +- 3 files changed, 128 insertions(+), 97 deletions(-) diff --git a/cms/cms.js b/cms/cms.js index 9606177..8fe6bcc 100644 --- a/cms/cms.js +++ b/cms/cms.js @@ -1,18 +1,18 @@ -import React from "react"; -import CMS from "netlify-cms"; +import React from 'react' +import CMS from 'netlify-cms' -import Features from 'site/components/Features'; -import Testimonials from 'site/components/Testimonials'; -import Pricing from 'site/components/Pricing'; +import Features from 'site/components/Features' +import Testimonials from 'site/components/Testimonials' +import Pricing from 'site/components/Pricing' -const AboutPagePreview = ({ entry, widgetFor }) => +const AboutPagePreview = ({ entry, widgetFor }) => (

- {entry.getIn(["data", "title"])} + {entry.getIn(['data', 'title'])}

{widgetFor('body')}
@@ -20,119 +20,147 @@ const AboutPagePreview = ({ entry, widgetFor }) =>
+) -const BlogPostPreview = ({ entry, widgetFor }) => +const BlogPostPreview = ({ entry, widgetFor }) => (

- {entry.getIn(["data", "title"])} + {entry.getIn(['data', 'title'])}

-

{entry.getIn(["data", "description"])}

-
{widgetFor("body")}
+

{entry.getIn(['data', 'description'])}

+
{widgetFor('body')}
+) const ProductPagePreview = ({ entry, widgetFor, getAsset }) => { + const entryBlurbs = entry.getIn(['data', 'intro', 'blurbs']) + const blurbs = entryBlurbs ? entryBlurbs.toJS() : [] - const entryBlurbs = entry.getIn(["data", "intro", "blurbs"]); - const blurbs = entryBlurbs ? entryBlurbs.toJS() : []; + const entryTestimonials = entry.getIn(['data', 'testimonials']) + const testimonials = entryTestimonials ? entryTestimonials.toJS() : [] - const entryTestimonials = entry.getIn(["data", "testimonials"]); - const testimonials = entryTestimonials ? entryTestimonials.toJS() : []; + const entryPricingPlans = entry.getIn(['data', 'pricing', 'plans']) + const pricingPlans = entryPricingPlans ? entryPricingPlans.toJS() : [] - const entryPricingPlans = entry.getIn(["data", "pricing", "plans"]); - const pricingPlans = entryPricingPlans ? entryPricingPlans.toJS() : []; - - return
-
-
-
-
-
-
-

+
+
+
+
+
+
- {entry.getIn(["data", "title"])} -

-
-
-
-

{entry.getIn(["data", "heading"])}

-

{entry.getIn(["data", "description"])}

+

+ {entry.getIn(['data', 'title'])} +

-
- -
-
-

{entry.getIn(["data", "main", "heading"])}

-

{entry.getIn(["main", "description"])}

+
+
+

+ {entry.getIn(['data', 'heading'])} +

+

{entry.getIn(['data', 'description'])}

+
-
-
-
-
-
-
- -
+ +
+
+

+ {entry.getIn(['data', 'main', 'heading'])} +

+

{entry.getIn(['main', 'description'])}

+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
-
-
- -
-
+ +
+

+ {entry.getIn(['data', 'pricing', 'heading'])} +

+

+ {entry.getIn(['data', 'pricing', 'description'])} +

+
- -
-

{entry.getIn(["data", "pricing", "heading"])}

-

{entry.getIn(["data", "pricing", "description"])}

-
-
-
+ + ) } - -CMS.registerPreviewStyle("/styles.css"); -CMS.registerPreviewTemplate("about", AboutPagePreview); -CMS.registerPreviewTemplate("products", ProductPagePreview); -CMS.registerPreviewTemplate("blog", BlogPostPreview); +CMS.registerPreviewStyle('/styles.css') +CMS.registerPreviewTemplate('about', AboutPagePreview) +CMS.registerPreviewTemplate('products', ProductPagePreview) +CMS.registerPreviewTemplate('blog', BlogPostPreview) diff --git a/cms/webpack.config.js b/cms/webpack.config.js index c0b28e3..7b34a8a 100644 --- a/cms/webpack.config.js +++ b/cms/webpack.config.js @@ -1,11 +1,11 @@ // This webpack config is used to compile the JS for the CMS -const path = require('path'); +const path = require('path') module.exports = { entry: './cms.js', output: { filename: 'cms.bundle.js', - path: path.resolve(__dirname, '../static/admin/') + path: path.resolve(__dirname, '../static/admin/'), }, module: { rules: [ @@ -13,17 +13,17 @@ module.exports = { test: /\.js$/, exclude: /node_modules/, use: { - loader: "babel-loader", + loader: 'babel-loader', options: { - presets: ["babel-preset-env", "babel-preset-react"] - } - } - } - ] + presets: ['babel-preset-env', 'babel-preset-react'], + }, + }, + }, + ], }, resolve: { alias: { - "site": "../src/" - } - } -}; + site: '../src/', + }, + }, +} diff --git a/package.json b/package.json index 5f4bda1..59dcd8e 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,10 @@ "build:cms": "cd cms && yarn && npm run build", "develop": "gatsby develop", "serve": "gatsby serve", - "format": "prettier --trailing-comma es5 --no-semi --single-quote --write 'src/**/*.js'", + "_format": "prettier --trailing-comma es5 --no-semi --single-quote --write", + "format": "npm run format:src & npm run format:cms", + "format:src": "npm run _format 'src/**/*.js'", + "format:cms": "npm run _format 'cms/**/*.js'", "test": "echo \"Error: no test specified\" && exit 1" }, "devDependencies": {