From 2544d5ef544a4784da4284d52095525723abcd87 Mon Sep 17 00:00:00 2001 From: Mathias Biilmann Christensen Date: Tue, 21 Feb 2017 15:31:05 -0800 Subject: Add preview template for product page --- src/js/cms-preview-templates/products.js | 112 +++++++++++++++++++++++++++++++ src/js/cms.js | 2 + 2 files changed, 114 insertions(+) create mode 100644 src/js/cms-preview-templates/products.js (limited to 'src/js') diff --git a/src/js/cms-preview-templates/products.js b/src/js/cms-preview-templates/products.js new file mode 100644 index 0000000..0934c1b --- /dev/null +++ b/src/js/cms-preview-templates/products.js @@ -0,0 +1,112 @@ +import React from "react"; +import format from "date-fns/format"; + +export default class PostPreview extends React.Component { + render() { + const {entry, getAsset, widgetFor} = this.props; + let image = getAsset(entry.getIn(["data", "image"])); + + // Bit of a nasty hack to make relative paths work as expected as a background image here + if (image && !image.fileObj) { + image = window.parent.location.protocol + "//" + window.parent.location.host + image; + } + + return
+
+
+
+
+

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

+
+
+
+
+
+
+ +
+
+

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

+

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

+ +
+ {(entry.getIn(["data","intro", "blurbs"]) || []).map((blurb, index) =>
+ +

{blurb.get("text")}

+
)} +
+
+
+ +
+
+

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

+

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

+
+
+ +
+ +
+
+ +
+ +
+ +
+ +
+ +
+
+
+ +
+ {(entry.getIn(['data', 'testimonials']) || []).map((testimonial, index) =>
+
+

“{testimonial.get('quote')}”

+ {testimonial.get('author')} +
+
)} +
+ + + +
+
+ +

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

+

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

+ +
+ {(entry.getIn(['data', 'pricing', 'plans']) || []).map((plan, index) =>
+
+ +

{plan.get('plan')}

+ +

+ ${plan.get('price')} +

+ +

{plan.get('description')}}

+ +
    + {(plan.get('items') || []).map((item, index) =>
  • +

    {item}

    +
  • )} +
+ +
+ +
)} +
+
+
+
; + } +} diff --git a/src/js/cms.js b/src/js/cms.js index d0781af..289b26a 100644 --- a/src/js/cms.js +++ b/src/js/cms.js @@ -1,5 +1,7 @@ import CMS from "netlify-cms"; import PostPreview from "./cms-preview-templates/post"; +import ProductsPreview from "./cms-preview-templates/products"; CMS.registerPreviewStyle("/css/main.css"); CMS.registerPreviewTemplate("post", PostPreview); +CMS.registerPreviewTemplate("products", ProductsPreview); -- cgit v1.3