diff --git a/website/.babelrc b/website/.babelrc new file mode 100644 index 00000000..3d0574a6 --- /dev/null +++ b/website/.babelrc @@ -0,0 +1,46 @@ +{ + presets: [ + [ + "@babel/preset-env", + { + loose: true, + modules: false, + useBuiltIns: "usage", + shippedProposals: true, + targets: { + browsers: [">0.25%", "not dead"], + }, + }, + ], + [ + "@babel/preset-react", + { + useBuiltIns: true, + pragma: "React.createElement", + }, + ], + ], + plugins: [ + ["prismjs", { + "languages": ["javascript", "css", "markup", "yaml", "json"], + "plugins": ["line-numbers"], + "theme": "tomorrow", + "css": true, + }], + [ + "@babel/plugin-proposal-class-properties", + { + loose: true, + }, + ], + "@babel/plugin-syntax-dynamic-import", + "babel-plugin-macros", + [ + "@babel/plugin-transform-runtime", + { + helpers: true, + regenerator: true, + }, + ], + ], +} diff --git a/website/content/docs/widgets/index.md b/website/content/docs/widgets.md similarity index 100% rename from website/content/docs/widgets/index.md rename to website/content/docs/widgets.md diff --git a/website/content/docs/widgets/boolean.md b/website/content/docs/widgets/boolean.md index 6065277f..0f7cbbb2 100644 --- a/website/content/docs/widgets/boolean.md +++ b/website/content/docs/widgets/boolean.md @@ -1,6 +1,6 @@ --- +title: boolean label: "Boolean" -target: boolean --- The boolean widget translates a toggle switch input to a true/false value. diff --git a/website/content/docs/widgets/date.md b/website/content/docs/widgets/date.md index 8d0a0c21..c133828e 100644 --- a/website/content/docs/widgets/date.md +++ b/website/content/docs/widgets/date.md @@ -1,6 +1,6 @@ --- +title: date label: "Date" -target: date --- The date widget translates a date picker input to a date string. For saving date and time together, use the datetime widget. diff --git a/website/content/docs/widgets/datetime.md b/website/content/docs/widgets/datetime.md index dec92641..7f9ab787 100644 --- a/website/content/docs/widgets/datetime.md +++ b/website/content/docs/widgets/datetime.md @@ -1,6 +1,6 @@ --- +title: datetime label: "DateTime" -target: datetime --- The datetime widget translates a datetime picker to a datetime string. For saving the date only, use the date widget. diff --git a/website/content/docs/widgets/file.md b/website/content/docs/widgets/file.md index 71b1df18..52ac4605 100644 --- a/website/content/docs/widgets/file.md +++ b/website/content/docs/widgets/file.md @@ -1,6 +1,6 @@ --- label: "File" -target: file +title: file --- The file widget allows editors to upload a file or select an existing one from the media library. The path to the file will be saved to the field as a string. diff --git a/website/content/docs/widgets/hidden.md b/website/content/docs/widgets/hidden.md index 4f4c0129..3fe738b1 100644 --- a/website/content/docs/widgets/hidden.md +++ b/website/content/docs/widgets/hidden.md @@ -1,6 +1,6 @@ --- label: "Hidden" -target: hidden +title: hidden --- Hidden widgets do not display in the UI. In folder collections that allow users to create new items, you will often want to set a default for hidden fields, so they will be set without requiring an input. diff --git a/website/content/docs/widgets/image.md b/website/content/docs/widgets/image.md index c3c915d6..ba8d020e 100644 --- a/website/content/docs/widgets/image.md +++ b/website/content/docs/widgets/image.md @@ -1,6 +1,6 @@ --- label: "Image" -target: image +title: image --- The image widget allows editors to upload an image or select an existing one from the media library. The path to the image file will be saved to the field as a string. diff --git a/website/content/docs/widgets/list.md b/website/content/docs/widgets/list.md index 500a4da9..10d9fe0a 100644 --- a/website/content/docs/widgets/list.md +++ b/website/content/docs/widgets/list.md @@ -1,6 +1,6 @@ --- label: "List" -target: list +title: list --- The list widget allows you to create a repeatable item in the UI which saves as a list of widget values. map a user-provided string with a comma delimiter into a list. You can choose any widget as a child of a list widget—even other lists. diff --git a/website/content/docs/widgets/markdown.md b/website/content/docs/widgets/markdown.md index 1bd2155c..6fd27de6 100644 --- a/website/content/docs/widgets/markdown.md +++ b/website/content/docs/widgets/markdown.md @@ -1,6 +1,6 @@ --- label: "Markdown" -target: markdown +title: markdown --- The markdown widget provides a full fledged text editor - which is based on [slate](https://github.com/ianstormtaylor/slate) - that allows users to format text with features such as headings and blockquotes. Users are also allowed to write in markdown by simply flipping a switch. diff --git a/website/content/docs/widgets/number.md b/website/content/docs/widgets/number.md index 7436b007..5b9f31ee 100644 --- a/website/content/docs/widgets/number.md +++ b/website/content/docs/widgets/number.md @@ -1,6 +1,6 @@ --- label: "Number" -target: number +title: number --- The number widget uses an HTML number input, saving the value as a string, integer, or floating point number. diff --git a/website/content/docs/widgets/object.md b/website/content/docs/widgets/object.md index bfef0453..2b5fb325 100644 --- a/website/content/docs/widgets/object.md +++ b/website/content/docs/widgets/object.md @@ -1,6 +1,6 @@ --- label: "Object" -target: object +title: object --- The object widget allows you to group multiple widgets together, nested under a single field. You can choose any widget as a child of an object widget—even other objects. diff --git a/website/content/docs/widgets/relation.md b/website/content/docs/widgets/relation.md index 20fe303d..784a9705 100644 --- a/website/content/docs/widgets/relation.md +++ b/website/content/docs/widgets/relation.md @@ -1,6 +1,6 @@ --- label: "Relation" -target: relation +title: relation --- The relation widget allows you to reference items from another collection. It provides a search input with a list of entries from the collection you're referencing, and the list automatically updates with matched entries based on what you've typed. diff --git a/website/content/docs/widgets/select.md b/website/content/docs/widgets/select.md index 208d1257..8a31b796 100644 --- a/website/content/docs/widgets/select.md +++ b/website/content/docs/widgets/select.md @@ -1,6 +1,6 @@ --- label: "Select" -target: select +title: select --- The select widget allows you to pick a single string value from a dropdown menu. diff --git a/website/content/docs/widgets/string.md b/website/content/docs/widgets/string.md index dd47838f..fdffbfd4 100644 --- a/website/content/docs/widgets/string.md +++ b/website/content/docs/widgets/string.md @@ -1,6 +1,6 @@ --- label: "String" -target: string +title: string --- The string widget translates a basic text input to a string value. For larger textarea inputs, use the text widget. diff --git a/website/content/docs/widgets/text.md b/website/content/docs/widgets/text.md index fc89707a..46f287e5 100644 --- a/website/content/docs/widgets/text.md +++ b/website/content/docs/widgets/text.md @@ -1,6 +1,6 @@ --- label: "Text" -target: text +title: text --- The text widget takes a multiline text field and saves it as a string. For shorter text inputs, use the string widget. diff --git a/website/gatsby-config.js b/website/gatsby-config.js index cd93cd12..1c560143 100644 --- a/website/gatsby-config.js +++ b/website/gatsby-config.js @@ -53,7 +53,12 @@ module.exports = { // prettier-ignore plugins: [ 'gatsby-remark-autolink-headers', - 'gatsby-remark-prismjs' + { + resolve: 'gatsby-remark-prismjs', + options: { + noInlineHighlight: true, + }, + }, ] }, }, diff --git a/website/package.json b/website/package.json index 7908bedc..5655832b 100755 --- a/website/package.json +++ b/website/package.json @@ -45,6 +45,7 @@ "smooth-scroll": "^14.2.0" }, "devDependencies": { + "babel-plugin-prismjs": "^1.0.2", "eslint": "^3.1.1", "eslint-plugin-import": "^1.11.1" }, diff --git a/website/src/cms/cms.js b/website/src/cms/cms.js index e464386e..cb8333d9 100644 --- a/website/src/cms/cms.js +++ b/website/src/cms/cms.js @@ -1,16 +1,45 @@ import React from 'react'; import CMS from 'netlify-cms'; import dayjs from 'dayjs'; +import Prism from 'prismjs'; import { BlogPostTemplate } from '../templates/blog-post'; import { DocsTemplate } from '../templates/doc-page'; +import WidgetDoc from '../components/widget-doc'; import Release from '../components/release'; import WhatsNew from '../components/whats-new'; import Notification from '../components/notification'; -import '../css/lib/prism.css'; import '../css/imports/docs.css'; import '../css/imports/whatsnew.css'; import '../css/imports/header.css'; +const withHighlight = WrappedComponent => + class Highlight extends React.Component { + constructor(props) { + super(props); + this.ref = React.createRef(); + } + + highlight() { + Prism.highlightAllUnder(this.ref.current); + } + + componentDidMount() { + this.highlight(); + } + + componentDidUpdate() { + this.highlight(); + } + + render() { + return ( +