From ca559ec1399c6bdabdd588287328624bc97da3a1 Mon Sep 17 00:00:00 2001 From: Swieckowski Date: Tue, 30 Jan 2018 15:03:33 -0500 Subject: [PATCH 01/17] frontmatter functions now exported as curried constructors --- src/formats/formats.js | 6 +++--- src/formats/frontmatter.js | 13 ++++++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/formats/formats.js b/src/formats/formats.js index a686364748b6..a58bfc3cfef3 100644 --- a/src/formats/formats.js +++ b/src/formats/formats.js @@ -52,9 +52,9 @@ function formatByName(name) { export function resolveFormat(collectionOrEntity, entry) { // If the format is specified in the collection, use that format. - const format = collectionOrEntity.get('format'); - if (format) { - return formatByName(format); + const formatSpecification = collectionOrEntity.get('format'); + if (formatSpecification) { + return formatByName(formatSpecification); } // If a file already exists, infer the format from its file extension. diff --git a/src/formats/frontmatter.js b/src/formats/frontmatter.js index d6f1bb03d53d..9b0a60695949 100644 --- a/src/formats/frontmatter.js +++ b/src/formats/frontmatter.js @@ -60,12 +60,14 @@ export const getFormatOpts = format => ({ }[format]); class FrontmatterFormatter { - constructor(format) { + constructor(format, customDelimiter) { this.format = getFormatOpts(format); + this.customDelimiter = customDelimiter; } fromFile(content) { const format = this.format || inferFrontmatterFormat(content); + if (this.customDelimiter) this.format.delimiters = this.customDelimiter; const result = matter(content, { engines: parsers, ...format }); return { ...result.data, @@ -78,13 +80,14 @@ class FrontmatterFormatter { // Stringify to YAML if the format was not set const format = this.format || getFormatOpts('yaml'); + if (this.customDelimiter) this.format.delimiters = this.customDelimiter; // `sortedKeys` is not recognized by gray-matter, so it gets passed through to the parser return matter.stringify(body, meta, { engines: parsers, sortedKeys, ...format }); } } -export const FrontmatterInfer = new FrontmatterFormatter(); -export const FrontmatterYAML = new FrontmatterFormatter('yaml'); -export const FrontmatterTOML = new FrontmatterFormatter('toml'); -export const FrontmatterJSON = new FrontmatterFormatter('json'); +export const FrontmatterInfer = customDelimiter => new FrontmatterFormatter(null, customDelimiter); +export const FrontmatterYAML = customDelimiter => new FrontmatterFormatter('yaml', customDelimiter); +export const FrontmatterTOML = customDelimiter => new FrontmatterFormatter('toml', customDelimiter); +export const FrontmatterJSON = customDelimiter => new FrontmatterFormatter('json', customDelimiter); From fe1368c5a759e4a12257d35469ee7788233b184b Mon Sep 17 00:00:00 2001 From: Swieckowski Date: Tue, 30 Jan 2018 15:08:18 -0500 Subject: [PATCH 02/17] changed formats.js to accomodate frontmatter.js changes --- src/formats/formats.js | 28 +++++++++++++++------------- src/formats/frontmatter.js | 8 ++++---- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/formats/formats.js b/src/formats/formats.js index a58bfc3cfef3..ca877b676554 100644 --- a/src/formats/formats.js +++ b/src/formats/formats.js @@ -1,7 +1,7 @@ import yamlFormatter from './yaml'; import tomlFormatter from './toml'; import jsonFormatter from './json'; -import { FrontmatterInfer, FrontmatterJSON, FrontmatterTOML, FrontmatterYAML } from './frontmatter'; +import { frontmatterInfer, frontmatterJSON, frontmatterTOML, frontmatterYAML } from './frontmatter'; export const supportedFormats = [ 'yml', @@ -25,43 +25,45 @@ export const formatToExtension = format => ({ 'yaml-frontmatter': 'md', }[format]); -export function formatByExtension(extension) { +export function formatByExtension(extension, customDelimiter) { return { yml: yamlFormatter, yaml: yamlFormatter, toml: tomlFormatter, json: jsonFormatter, - md: FrontmatterInfer, - markdown: FrontmatterInfer, - html: FrontmatterInfer, + md: frontmatterInfer(customDelimiter), + markdown: frontmatterInfer(customDelimiter), + html: frontmatterInfer(customDelimiter), }[extension]; } -function formatByName(name) { +function formatByName(name, customDelimiter) { return { yml: yamlFormatter, yaml: yamlFormatter, toml: tomlFormatter, json: jsonFormatter, - frontmatter: FrontmatterInfer, - 'json-frontmatter': FrontmatterJSON, - 'toml-frontmatter': FrontmatterTOML, - 'yaml-frontmatter': FrontmatterYAML, + frontmatter: frontmatterInfer(customDelimiter), + 'json-frontmatter': frontmatterJSON(customDelimiter), + 'toml-frontmatter': frontmatterTOML(customDelimiter), + 'yaml-frontmatter': frontmatterYAML(customDelimiter), }[name]; } export function resolveFormat(collectionOrEntity, entry) { + // Check for custom delimiter + const customDelimiter = collectionOrEntity.get('frontmatter_delimiter'); // If the format is specified in the collection, use that format. const formatSpecification = collectionOrEntity.get('format'); if (formatSpecification) { - return formatByName(formatSpecification); + return formatByName(formatSpecification, customDelimiter); } // If a file already exists, infer the format from its file extension. const filePath = entry && entry.path; if (filePath) { const fileExtension = filePath.split('.').pop(); - return formatByExtension(fileExtension); + return formatByExtension(fileExtension, customDelimiter); } // If creating a new file, and an `extension` is specified in the @@ -72,5 +74,5 @@ export function resolveFormat(collectionOrEntity, entry) { } // If no format is specified and it cannot be inferred, return the default. - return formatByName('frontmatter'); + return formatByName('frontmatter', customDelimiter); } diff --git a/src/formats/frontmatter.js b/src/formats/frontmatter.js index 9b0a60695949..1a463e7e181f 100644 --- a/src/formats/frontmatter.js +++ b/src/formats/frontmatter.js @@ -87,7 +87,7 @@ class FrontmatterFormatter { } } -export const FrontmatterInfer = customDelimiter => new FrontmatterFormatter(null, customDelimiter); -export const FrontmatterYAML = customDelimiter => new FrontmatterFormatter('yaml', customDelimiter); -export const FrontmatterTOML = customDelimiter => new FrontmatterFormatter('toml', customDelimiter); -export const FrontmatterJSON = customDelimiter => new FrontmatterFormatter('json', customDelimiter); +export const frontmatterInfer = customDelimiter => new FrontmatterFormatter(null, customDelimiter); +export const frontmatterYAML = customDelimiter => new FrontmatterFormatter('yaml', customDelimiter); +export const frontmatterTOML = customDelimiter => new FrontmatterFormatter('toml', customDelimiter); +export const frontmatterJSON = customDelimiter => new FrontmatterFormatter('json', customDelimiter); From 82ba3f3f1a804b9be8af9ace5362e7e11646c521 Mon Sep 17 00:00:00 2001 From: Swieckowski Date: Tue, 30 Jan 2018 20:49:28 -0500 Subject: [PATCH 03/17] can only use custom delimiters if format is specified --- example/config.yml | 4 +++- src/formats/formats.js | 12 ++++++------ src/formats/frontmatter.js | 3 ++- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/example/config.yml b/example/config.yml index 3a2a746fca0d..da43a6b74d7f 100644 --- a/example/config.yml +++ b/example/config.yml @@ -1,5 +1,6 @@ backend: - name: test-repo + name: github + repo: Swieckowski/testingFrontmatterDelimiters display_url: https://example.com media_folder: "assets/uploads" @@ -11,6 +12,7 @@ collections: # A list of collections the CMS should be able to edit The description is a great place for tone setting, high level information, and editing guidelines that are specific to a collection. folder: "_posts" + frontmatter_delimiter: "www" slug: "{{year}}-{{month}}-{{day}}-{{slug}}" create: true # Allow users to create new documents in this collection fields: # The fields each document in this collection have diff --git a/src/formats/formats.js b/src/formats/formats.js index ca877b676554..2fad08fe4470 100644 --- a/src/formats/formats.js +++ b/src/formats/formats.js @@ -1,7 +1,7 @@ import yamlFormatter from './yaml'; import tomlFormatter from './toml'; import jsonFormatter from './json'; -import { frontmatterInfer, frontmatterJSON, frontmatterTOML, frontmatterYAML } from './frontmatter'; +import { FrontmatterInfer, frontmatterJSON, frontmatterTOML, frontmatterYAML } from './frontmatter'; export const supportedFormats = [ 'yml', @@ -31,9 +31,9 @@ export function formatByExtension(extension, customDelimiter) { yaml: yamlFormatter, toml: tomlFormatter, json: jsonFormatter, - md: frontmatterInfer(customDelimiter), - markdown: frontmatterInfer(customDelimiter), - html: frontmatterInfer(customDelimiter), + md: FrontmatterInfer, + markdown: FrontmatterInfer, + html: FrontmatterInfer, }[extension]; } @@ -43,7 +43,7 @@ function formatByName(name, customDelimiter) { yaml: yamlFormatter, toml: tomlFormatter, json: jsonFormatter, - frontmatter: frontmatterInfer(customDelimiter), + frontmatter: FrontmatterInfer, 'json-frontmatter': frontmatterJSON(customDelimiter), 'toml-frontmatter': frontmatterTOML(customDelimiter), 'yaml-frontmatter': frontmatterYAML(customDelimiter), @@ -70,7 +70,7 @@ export function resolveFormat(collectionOrEntity, entry) { // collection config, infer the format from that extension. const extension = collectionOrEntity.get('extension'); if (extension) { - return formatByExtension(extension); + return formatByExtension(extension, customDelimiter); } // If no format is specified and it cannot be inferred, return the default. diff --git a/src/formats/frontmatter.js b/src/formats/frontmatter.js index 1a463e7e181f..8704edb68e90 100644 --- a/src/formats/frontmatter.js +++ b/src/formats/frontmatter.js @@ -68,6 +68,7 @@ class FrontmatterFormatter { fromFile(content) { const format = this.format || inferFrontmatterFormat(content); if (this.customDelimiter) this.format.delimiters = this.customDelimiter; + console.log("yo", this.customDelimiter) const result = matter(content, { engines: parsers, ...format }); return { ...result.data, @@ -87,7 +88,7 @@ class FrontmatterFormatter { } } -export const frontmatterInfer = customDelimiter => new FrontmatterFormatter(null, customDelimiter); +export const FrontmatterInfer = new FrontmatterFormatter(); export const frontmatterYAML = customDelimiter => new FrontmatterFormatter('yaml', customDelimiter); export const frontmatterTOML = customDelimiter => new FrontmatterFormatter('toml', customDelimiter); export const frontmatterJSON = customDelimiter => new FrontmatterFormatter('json', customDelimiter); From 50a5ed03f39cc9efd242068f80fc06609f6e9e48 Mon Sep 17 00:00:00 2001 From: Swieckowski Date: Tue, 30 Jan 2018 21:18:24 -0500 Subject: [PATCH 04/17] reverting changes --- example/config.yml | 4 +--- src/formats/frontmatter.js | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/example/config.yml b/example/config.yml index da43a6b74d7f..3a2a746fca0d 100644 --- a/example/config.yml +++ b/example/config.yml @@ -1,6 +1,5 @@ backend: - name: github - repo: Swieckowski/testingFrontmatterDelimiters + name: test-repo display_url: https://example.com media_folder: "assets/uploads" @@ -12,7 +11,6 @@ collections: # A list of collections the CMS should be able to edit The description is a great place for tone setting, high level information, and editing guidelines that are specific to a collection. folder: "_posts" - frontmatter_delimiter: "www" slug: "{{year}}-{{month}}-{{day}}-{{slug}}" create: true # Allow users to create new documents in this collection fields: # The fields each document in this collection have diff --git a/src/formats/frontmatter.js b/src/formats/frontmatter.js index 8704edb68e90..804d9ac63f77 100644 --- a/src/formats/frontmatter.js +++ b/src/formats/frontmatter.js @@ -68,7 +68,6 @@ class FrontmatterFormatter { fromFile(content) { const format = this.format || inferFrontmatterFormat(content); if (this.customDelimiter) this.format.delimiters = this.customDelimiter; - console.log("yo", this.customDelimiter) const result = matter(content, { engines: parsers, ...format }); return { ...result.data, From 8a320247ed0df36db88724dd3555e1078ee764f0 Mon Sep 17 00:00:00 2001 From: Swieckowski Date: Tue, 30 Jan 2018 21:52:12 -0500 Subject: [PATCH 05/17] updated tests to reflect changes --- .all-contributorsrc | 9 +++++++++ README.md | 4 ++-- src/formats/__tests__/frontmatter.spec.js | 14 +++++++------- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index e451728b830c..248a3b9b9131 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -709,6 +709,15 @@ "contributions": [ "code" ] + }, + { + "login": "Swieckowski", + "name": "Swieckowski", + "avatar_url": "https://avatars0.githubusercontent.com/u/31023010?v=4", + "profile": "https://www.linkedin.com/in/arthur-swieckowski/", + "contributions": [ + "code" + ] } ] } diff --git a/README.md b/README.md index cb487def859c..78f5839ec205 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Netlify CMS -[![All Contributors](https://img.shields.io/badge/all_contributors-83-orange.svg)](#contributors) +[![All Contributors](https://img.shields.io/badge/all_contributors-84-orange.svg)](#contributors) [![](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/netlify/netlifycms) A CMS for static site generators. Give non-technical users a simple way to edit @@ -60,7 +60,7 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds | [
Etienne Bernard](https://github.com/ebernard)
[📖](https://github.com/netlify/netlify-cms/commits?author=ebernard "Documentation") | [
Eli Williamson](http://eliwilliamson.com)
[💻](https://github.com/netlify/netlify-cms/commits?author=eliwilliamson "Code") [🎨](#design-eliwilliamson "Design") | [
Covington Doan](https://www.covingtondoan.com)
[📖](https://github.com/netlify/netlify-cms/commits?author=covingtondoan "Documentation") | [
Lennart Ziburski](http://lennartziburski.com)
[💻](https://github.com/netlify/netlify-cms/commits?author=ziburski "Code") [🎨](#design-ziburski "Design") [📖](https://github.com/netlify/netlify-cms/commits?author=ziburski "Documentation") | [
Darrel O'Pry](http://darrelopry.com)
[💻](https://github.com/netlify/netlify-cms/commits?author=dopry "Code") [🚇](#infra-dopry "Infrastructure (Hosting, Build-Tools, etc)") [⚠️](https://github.com/netlify/netlify-cms/commits?author=dopry "Tests") | [
Erin Symons](https://github.com/yourfrienderin)
[📖](https://github.com/netlify/netlify-cms/commits?author=yourfrienderin "Documentation") | [
Austin Green](https://github.com/AustinGreen)
[📖](https://github.com/netlify/netlify-cms/commits?author=AustinGreen "Documentation") [💡](#example-AustinGreen "Examples") | | [
Bryan Robinson](http://bryanlrobinson.com)
[📖](https://github.com/netlify/netlify-cms/commits?author=brob "Documentation") | [
Darren](https://github.com/dardub)
[📖](https://github.com/netlify/netlify-cms/commits?author=dardub "Documentation") | [
Richard Pullinger](http://www.richardpullinger.com)
[💻](https://github.com/netlify/netlify-cms/commits?author=rpullinger "Code") | [
Taylor Bryant](https://taylorbryant.blog)
[📖](https://github.com/netlify/netlify-cms/commits?author=taylorbryant "Documentation") | [
kvanerkelens](https://github.com/kvanerkelens)
[📖](https://github.com/netlify/netlify-cms/commits?author=kvanerkelens "Documentation") | [
Patrick Sier](https://patsier.com/)
[💻](https://github.com/netlify/netlify-cms/commits?author=pjsier "Code") | [
Christian Nolte](http://noltech.net)
[💻](https://github.com/netlify/netlify-cms/commits?author=drlogout "Code") | | [
Edward Betts](http://edwardbetts.com/)
[📖](https://github.com/netlify/netlify-cms/commits?author=EdwardBetts "Documentation") | [
Josh Hardman](https://github.com/jhardman0830)
[📖](https://github.com/netlify/netlify-cms/commits?author=jhardman0830 "Documentation") | [
Mantas](https://behance.net/mistermantas)
[📖](https://github.com/netlify/netlify-cms/commits?author=mistermantas "Documentation") | [
Marco Biedermann](https://www.marcobiedermann.com)
[📖](https://github.com/netlify/netlify-cms/commits?author=marcobiedermann "Documentation") | [
Max Stoiber](https://mxstbr.blog/newsletter)
[📖](https://github.com/netlify/netlify-cms/commits?author=mxstbr "Documentation") | [
Vyacheslav Matyukhin](http://berekuk.ru)
[📖](https://github.com/netlify/netlify-cms/commits?author=berekuk "Documentation") | [
jimmaaay](https://jimmythompson.me)
[💻](https://github.com/netlify/netlify-cms/commits?author=jimmaaay "Code") | -| [
Luís Miguel](https://github.com/Quicksaver)
[🐛](https://github.com/netlify/netlify-cms/issues?q=author%3AQuicksaver "Bug reports") [💻](https://github.com/netlify/netlify-cms/commits?author=Quicksaver "Code") | [
Chris Swithinbank](http://chrisswithinbank.net/)
[📖](https://github.com/netlify/netlify-cms/commits?author=delucis "Documentation") | [
remmah](https://github.com/remmah)
[📖](https://github.com/netlify/netlify-cms/commits?author=remmah "Documentation") | [
Sumeet Jain](http://sumeetjain.com)
[📖](https://github.com/netlify/netlify-cms/commits?author=sumeetjain "Documentation") | [
Sagar Khatri](https://github.com/ragasirtahk)
[📖](https://github.com/netlify/netlify-cms/commits?author=ragasirtahk "Documentation") [💡](#example-ragasirtahk "Examples") | [
Kevin Doocey](https://www.dooceykev.in)
[💻](https://github.com/netlify/netlify-cms/commits?author=Doocey "Code") | +| [
Luís Miguel](https://github.com/Quicksaver)
[🐛](https://github.com/netlify/netlify-cms/issues?q=author%3AQuicksaver "Bug reports") [💻](https://github.com/netlify/netlify-cms/commits?author=Quicksaver "Code") | [
Chris Swithinbank](http://chrisswithinbank.net/)
[📖](https://github.com/netlify/netlify-cms/commits?author=delucis "Documentation") | [
remmah](https://github.com/remmah)
[📖](https://github.com/netlify/netlify-cms/commits?author=remmah "Documentation") | [
Sumeet Jain](http://sumeetjain.com)
[📖](https://github.com/netlify/netlify-cms/commits?author=sumeetjain "Documentation") | [
Sagar Khatri](https://github.com/ragasirtahk)
[📖](https://github.com/netlify/netlify-cms/commits?author=ragasirtahk "Documentation") [💡](#example-ragasirtahk "Examples") | [
Kevin Doocey](https://www.dooceykev.in)
[💻](https://github.com/netlify/netlify-cms/commits?author=Doocey "Code") | [
Swieckowski](https://www.linkedin.com/in/arthur-swieckowski/)
[💻](https://github.com/netlify/netlify-cms/commits?author=Swieckowski "Code") | This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome! \ No newline at end of file diff --git a/src/formats/__tests__/frontmatter.spec.js b/src/formats/__tests__/frontmatter.spec.js index 33cc41f7c29c..d40b114af072 100644 --- a/src/formats/__tests__/frontmatter.spec.js +++ b/src/formats/__tests__/frontmatter.spec.js @@ -1,4 +1,4 @@ -import { FrontmatterInfer, FrontmatterJSON, FrontmatterTOML, FrontmatterYAML } from '../frontmatter'; +import { FrontmatterInfer, frontmatterJSON, frontmatterTOML, frontmatterYAML } from '../frontmatter'; jest.mock("../../valueObjects/AssetProxy.js"); @@ -17,7 +17,7 @@ describe('Frontmatter', () => { it('should parse YAML with --- delimiters when it is explicitly set as the format', () => { expect( - FrontmatterYAML.fromFile('---\ntitle: YAML\ndescription: Something longer\n---\nContent') + frontmatterYAML().fromFile('---\ntitle: YAML\ndescription: Something longer\n---\nContent') ).toEqual( { title: 'YAML', @@ -64,7 +64,7 @@ describe('Frontmatter', () => { it('should parse TOML with +++ delimiters when it is explicitly set as the format', () => { expect( - FrontmatterTOML.fromFile('+++\ntitle = "TOML"\ndescription = "Front matter"\n+++\nContent') + frontmatterTOML().fromFile('+++\ntitle = "TOML"\ndescription = "Front matter"\n+++\nContent') ).toEqual( { title: 'TOML', @@ -100,7 +100,7 @@ describe('Frontmatter', () => { it('should parse JSON with { } delimiters when it is explicitly set as the format', () => { expect( - FrontmatterJSON.fromFile('{\n"title": "The Title",\n"description": "Something longer"\n}\nContent') + frontmatterJSON().fromFile('{\n"title": "The Title",\n"description": "Something longer"\n}\nContent') ).toEqual( { title: 'The Title', @@ -158,7 +158,7 @@ describe('Frontmatter', () => { it('should stringify YAML with --- delimiters when it is explicitly set as the format', () => { expect( - FrontmatterYAML.toFile({ body: 'Some content\nOn another line', tags: ['front matter', 'yaml'], title: 'YAML' }) + frontmatterYAML().toFile({ body: 'Some content\nOn another line', tags: ['front matter', 'yaml'], title: 'YAML' }) ).toEqual( [ '---', @@ -175,7 +175,7 @@ describe('Frontmatter', () => { it('should stringify TOML with +++ delimiters when it is explicitly set as the format', () => { expect( - FrontmatterTOML.toFile({ body: 'Some content\nOn another line', tags: ['front matter', 'toml'], title: 'TOML' }) + frontmatterTOML().toFile({ body: 'Some content\nOn another line', tags: ['front matter', 'toml'], title: 'TOML' }) ).toEqual( [ '+++', @@ -190,7 +190,7 @@ describe('Frontmatter', () => { it('should stringify JSON with { } delimiters when it is explicitly set as the format', () => { expect( - FrontmatterJSON.toFile({ body: 'Some content\nOn another line', tags: ['front matter', 'json'], title: 'JSON' }) + frontmatterJSON().toFile({ body: 'Some content\nOn another line', tags: ['front matter', 'json'], title: 'JSON' }) ).toEqual( [ '{', From 1450c8c1558a4d58660a44c98b239cbf52702ccd Mon Sep 17 00:00:00 2001 From: Swieckowski Date: Tue, 30 Jan 2018 22:20:31 -0500 Subject: [PATCH 06/17] created tests for custom delimiters --- src/formats/__tests__/frontmatter.spec.js | 94 +++++++++++++++++++++-- 1 file changed, 87 insertions(+), 7 deletions(-) diff --git a/src/formats/__tests__/frontmatter.spec.js b/src/formats/__tests__/frontmatter.spec.js index d40b114af072..cdf41ba3af6d 100644 --- a/src/formats/__tests__/frontmatter.spec.js +++ b/src/formats/__tests__/frontmatter.spec.js @@ -15,7 +15,7 @@ describe('Frontmatter', () => { ); }); - it('should parse YAML with --- delimiters when it is explicitly set as the format', () => { + it('should parse YAML with --- delimiters when it is explicitly set as the format without a custom delimiter', () => { expect( frontmatterYAML().fromFile('---\ntitle: YAML\ndescription: Something longer\n---\nContent') ).toEqual( @@ -27,6 +27,18 @@ describe('Frontmatter', () => { ); }); + it('should parse YAML with custom delimiters when it is explicitly set as the format with a custom delimiter', () => { + expect( + frontmatterYAML("~~~").fromFile('~~~\ntitle: YAML\ndescription: Something longer\n~~~\nContent') + ).toEqual( + { + title: 'YAML', + description: 'Something longer', + body: 'Content', + } + ); + }); + it('should parse YAML with ---yaml delimiters', () => { expect( FrontmatterInfer.fromFile('---yaml\ntitle: YAML\ndescription: Something longer\n---\nContent') @@ -62,9 +74,9 @@ describe('Frontmatter', () => { ); }); - it('should parse TOML with +++ delimiters when it is explicitly set as the format', () => { + it('should parse TOML with +++ delimiters when it is explicitly set as the format without a custom delimiter', () => { expect( - frontmatterTOML().fromFile('+++\ntitle = "TOML"\ndescription = "Front matter"\n+++\nContent') + frontmatterTOML("~~~").fromFile('~~~\ntitle = "TOML"\ndescription = "Front matter"\n~~~\nContent') ).toEqual( { title: 'TOML', @@ -98,7 +110,7 @@ describe('Frontmatter', () => { ); }); - it('should parse JSON with { } delimiters when it is explicitly set as the format', () => { + it('should parse JSON with { } delimiters when it is explicitly set as the format without a custom delimiter', () => { expect( frontmatterJSON().fromFile('{\n"title": "The Title",\n"description": "Something longer"\n}\nContent') ).toEqual( @@ -110,6 +122,18 @@ describe('Frontmatter', () => { ); }); + it('should parse JSON with { } delimiters when it is explicitly set as the format with a custom delimiter', () => { + expect( + frontmatterJSON("~~~").fromFile('~~~\n"title": "The Title",\n"description": "Something longer"\n~~~\nContent') + ).toEqual( + { + title: 'The Title', + description: 'Something longer', + body: 'Content', + } + ); + }); + it('should parse JSON with ---json delimiters', () => { expect( FrontmatterInfer.fromFile('---json\n{\n"title": "The Title",\n"description": "Something longer"\n}\n---\nContent') @@ -156,7 +180,8 @@ describe('Frontmatter', () => { ); }); - it('should stringify YAML with --- delimiters when it is explicitly set as the format', () => { + it('should stringify YAML with --- delimiters when it is explicitly set as the format without a custom delimiter', + () => { expect( frontmatterYAML().toFile({ body: 'Some content\nOn another line', tags: ['front matter', 'yaml'], title: 'YAML' }) ).toEqual( @@ -173,7 +198,26 @@ describe('Frontmatter', () => { ); }); - it('should stringify TOML with +++ delimiters when it is explicitly set as the format', () => { + it('should stringify YAML with --- delimiters when it is explicitly set as the format with a custom delimiter', + () => { + expect( + frontmatterYAML("~~~").toFile({ body: 'Some content\nOn another line', tags: ['front matter', 'yaml'], title: 'YAML' }) + ).toEqual( + [ + '~~~', + 'tags:', + ' - front matter', + ' - yaml', + 'title: YAML', + '~~~', + 'Some content', + 'On another line\n', + ].join('\n') + ); + }); + + it('should stringify TOML with +++ delimiters when it is explicitly set as the format without a custom delimiter', + () => { expect( frontmatterTOML().toFile({ body: 'Some content\nOn another line', tags: ['front matter', 'toml'], title: 'TOML' }) ).toEqual( @@ -188,7 +232,24 @@ describe('Frontmatter', () => { ); }); - it('should stringify JSON with { } delimiters when it is explicitly set as the format', () => { + it('should stringify TOML with +++ delimiters when it is explicitly set as the format with a custom delimiter', + () => { + expect( + frontmatterTOML("~~~").toFile({ body: 'Some content\nOn another line', tags: ['front matter', 'toml'], title: 'TOML' }) + ).toEqual( + [ + '~~~', + 'tags = ["front matter", "toml"]', + 'title = "TOML"', + '~~~', + 'Some content', + 'On another line\n', + ].join('\n') + ); + }); + + it('should stringify JSON with { } delimiters when it is explicitly set as the format without a custom delimiter', + () => { expect( frontmatterJSON().toFile({ body: 'Some content\nOn another line', tags: ['front matter', 'json'], title: 'JSON' }) ).toEqual( @@ -205,4 +266,23 @@ describe('Frontmatter', () => { ].join('\n') ); }); + + it('should stringify JSON with { } delimiters when it is explicitly set as the format with a custom delimiter', + () => { + expect( + frontmatterJSON("~~~").toFile({ body: 'Some content\nOn another line', tags: ['front matter', 'json'], title: 'JSON' }) + ).toEqual( + [ + '~~~', + '"tags": [', + ' "front matter",', + ' "json"', + ' ],', + ' "title": "JSON"', + '~~~', + 'Some content', + 'On another line\n', + ].join('\n') + ); + }); }); From 67c02fd886c1512b2c5ba0eea44bb7cf3814bea2 Mon Sep 17 00:00:00 2001 From: Swieckowski Date: Tue, 30 Jan 2018 22:36:17 -0500 Subject: [PATCH 07/17] updated docs to reflect addition of custom delimiter configuration --- website/site/content/docs/configuration-options.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/website/site/content/docs/configuration-options.md b/website/site/content/docs/configuration-options.md index 1784d9cffc73..3beb661b57b6 100644 --- a/website/site/content/docs/configuration-options.md +++ b/website/site/content/docs/configuration-options.md @@ -100,7 +100,9 @@ You may also specify a custom `extension` not included in the list above, as lon - `toml-frontmatter`: same as the `frontmatter` format above, except frontmatter will be both parsed and saved only as TOML, followed by unparsed body text - `json-frontmatter`: same as the `frontmatter` format above, except frontmatter will be both parsed and saved as JSON, followed by unparsed body text -The explicit `yaml-frontmatter`, `toml-frontmatter`, and `json-frontmatter` formats above do not currently support custom delimiters. We use `---` for YAML, `+++` for TOML, and `{` `}` for JSON. If a file has frontmatter inside other delimiters it will be included as part of the body text. +The explicit `yaml-frontmatter`, `toml-frontmatter`, and `json-frontmatter` formats support custom delimiters. We use `---` for YAML, `+++` for TOML, and `{` `}` for JSON by default, but you can configure a custom delimiter. +You can configure a custom delimiter with `frontmatter_delimiter`, but it only applies if you have a frontmatter format specified. +If a file has frontmatter inside other delimiters it will be included as part of the body text. ### `slug` From 6ec09aa10f51fd7b58ab870a54c447b0cdcca4c8 Mon Sep 17 00:00:00 2001 From: Swieckowski Date: Tue, 6 Feb 2018 15:46:56 -0500 Subject: [PATCH 08/17] formatByExtension no longer takes custom delimiter --- src/formats/formats.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/formats/formats.js b/src/formats/formats.js index 2fad08fe4470..82314c53f026 100644 --- a/src/formats/formats.js +++ b/src/formats/formats.js @@ -25,7 +25,7 @@ export const formatToExtension = format => ({ 'yaml-frontmatter': 'md', }[format]); -export function formatByExtension(extension, customDelimiter) { +export function formatByExtension(extension) { return { yml: yamlFormatter, yaml: yamlFormatter, @@ -70,7 +70,7 @@ export function resolveFormat(collectionOrEntity, entry) { // collection config, infer the format from that extension. const extension = collectionOrEntity.get('extension'); if (extension) { - return formatByExtension(extension, customDelimiter); + return formatByExtension(extension); } // If no format is specified and it cannot be inferred, return the default. From d56fda811d6fcea5c32049c8988e04b226ac0022 Mon Sep 17 00:00:00 2001 From: Swieckowski Date: Tue, 6 Feb 2018 16:04:02 -0500 Subject: [PATCH 09/17] missed some formatByExtension calls --- src/formats/formats.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/formats/formats.js b/src/formats/formats.js index 82314c53f026..56f085275352 100644 --- a/src/formats/formats.js +++ b/src/formats/formats.js @@ -63,7 +63,7 @@ export function resolveFormat(collectionOrEntity, entry) { const filePath = entry && entry.path; if (filePath) { const fileExtension = filePath.split('.').pop(); - return formatByExtension(fileExtension, customDelimiter); + return formatByExtension(fileExtension); } // If creating a new file, and an `extension` is specified in the From b680d3d4e8138ade4020e661dbe842d075a68a57 Mon Sep 17 00:00:00 2001 From: Swieckowski Date: Thu, 8 Feb 2018 16:47:41 -0500 Subject: [PATCH 10/17] Edited the docs according to suggestions --- website/site/content/docs/configuration-options.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/website/site/content/docs/configuration-options.md b/website/site/content/docs/configuration-options.md index 3beb661b57b6..1e15bf3deada 100644 --- a/website/site/content/docs/configuration-options.md +++ b/website/site/content/docs/configuration-options.md @@ -96,13 +96,10 @@ You may also specify a custom `extension` not included in the list above, as lon - `toml`: parses and saves files as TOML-formatted data files; saves with `toml` extension by default - `json`: parses and saves files as JSON-formatted data files; saves with `json` extension by default - `frontmatter`: parses files and saves files with data frontmatter followed by an unparsed body text (edited using a `body` field); saves with `md` extension by default; default for collections that can't be inferred. Collections with `frontmatter` format (either inferred or explicitly set) can parse files with frontmatter in YAML, TOML, or JSON format. However, they will be saved with YAML frontmatter. -- `yaml-frontmatter`: same as the `frontmatter` format above, except frontmatter will be both parsed and saved only as YAML, followed by unparsed body text -- `toml-frontmatter`: same as the `frontmatter` format above, except frontmatter will be both parsed and saved only as TOML, followed by unparsed body text -- `json-frontmatter`: same as the `frontmatter` format above, except frontmatter will be both parsed and saved as JSON, followed by unparsed body text - -The explicit `yaml-frontmatter`, `toml-frontmatter`, and `json-frontmatter` formats support custom delimiters. We use `---` for YAML, `+++` for TOML, and `{` `}` for JSON by default, but you can configure a custom delimiter. -You can configure a custom delimiter with `frontmatter_delimiter`, but it only applies if you have a frontmatter format specified. -If a file has frontmatter inside other delimiters it will be included as part of the body text. +- `yaml-frontmatter`: same as the `frontmatter` format above, except frontmatter will be both parsed and saved only as YAML, followed by unparsed body text. The default delimiter for this option is `---`. +- `toml-frontmatter`: same as the `frontmatter` format above, except frontmatter will be both parsed and saved only as TOML, followed by unparsed body text. The default delimiter for this option is `+++`. +- `json-frontmatter`: same as the `frontmatter` format above, except frontmatter will be both parsed and saved as JSON, followed by unparsed body text. The default delimiter for this option is `{` `}`. +- `frontmatter_delimiter`: if you have an explicit frontmatter format declared, this option allows you to specify a custom delimiter like `~~~`. ### `slug` From 5ed2040cb27a6abaf5c700cdaaeebce38c58df01 Mon Sep 17 00:00:00 2001 From: Swieckowski Date: Thu, 8 Feb 2018 16:57:23 -0500 Subject: [PATCH 11/17] Throws an error if a custom delimiter is set without declaring frontmatter format --- src/reducers/collections.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/reducers/collections.js b/src/reducers/collections.js index 78a25e3410e5..c65de70729e2 100644 --- a/src/reducers/collections.js +++ b/src/reducers/collections.js @@ -38,6 +38,11 @@ function validateCollection(configCollection) { // Cannot infer format from extension. throw new Error(`Please set a format for collection "${ collectionName }". Supported formats are ${ supportedFormats.join(',') }`); } + if (has(configCollection, 'frontmatter_delimiter') && !has(configCollection, 'format')) { + // Cannot set custom delimiter without explicit format declaration + throw new Error(`Please set a frontmatter format for collection "${ collectionName }". to use a custom delimiter.`); + } + } const selectors = { From 8063b967259b0254d64968fe4f718a36c96aed82 Mon Sep 17 00:00:00 2001 From: Swieckowski Date: Thu, 8 Feb 2018 17:32:59 -0500 Subject: [PATCH 12/17] Throws error if custom delimiter set without explicit and proper frontmatter format being declared --- example/config.yml | 4 +++- src/reducers/collections.js | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/example/config.yml b/example/config.yml index 3a2a746fca0d..20f8474eb6d3 100644 --- a/example/config.yml +++ b/example/config.yml @@ -1,5 +1,6 @@ backend: - name: test-repo + name: github + repo: Swieckowski/testingFrontmatterDelimiters # Path to your Github repository display_url: https://example.com media_folder: "assets/uploads" @@ -11,6 +12,7 @@ collections: # A list of collections the CMS should be able to edit The description is a great place for tone setting, high level information, and editing guidelines that are specific to a collection. folder: "_posts" + frontmatter_delimiter: "what" slug: "{{year}}-{{month}}-{{day}}-{{slug}}" create: true # Allow users to create new documents in this collection fields: # The fields each document in this collection have diff --git a/src/reducers/collections.js b/src/reducers/collections.js index c65de70729e2..e0c545c4260c 100644 --- a/src/reducers/collections.js +++ b/src/reducers/collections.js @@ -38,9 +38,10 @@ function validateCollection(configCollection) { // Cannot infer format from extension. throw new Error(`Please set a format for collection "${ collectionName }". Supported formats are ${ supportedFormats.join(',') }`); } - if (has(configCollection, 'frontmatter_delimiter') && !has(configCollection, 'format')) { - // Cannot set custom delimiter without explicit format declaration - throw new Error(`Please set a frontmatter format for collection "${ collectionName }". to use a custom delimiter.`); + const frontmatterFormats = ['yaml-frontmatter','toml-frontmatter','json-frontmatter'] + if (has(configCollection, 'frontmatter_delimiter') && !frontmatterFormats.includes(get(configCollection, 'format'))) { + // Cannot set custom delimiter without explicit and proper frontmatter format declaration + throw new Error(`Please set a proper frontmatter format for collection "${ collectionName }" to use a custom delimiter. Supported frontmatter formats are yaml-frontmatter, toml-frontmatter, and json-frontmatter.`); } } From b25d11e1489099fcc9f849d82ccb881e16401a21 Mon Sep 17 00:00:00 2001 From: Swieckowski Date: Thu, 8 Feb 2018 17:34:04 -0500 Subject: [PATCH 13/17] example config file set to proper defaults --- example/config.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/example/config.yml b/example/config.yml index 20f8474eb6d3..3a2a746fca0d 100644 --- a/example/config.yml +++ b/example/config.yml @@ -1,6 +1,5 @@ backend: - name: github - repo: Swieckowski/testingFrontmatterDelimiters # Path to your Github repository + name: test-repo display_url: https://example.com media_folder: "assets/uploads" @@ -12,7 +11,6 @@ collections: # A list of collections the CMS should be able to edit The description is a great place for tone setting, high level information, and editing guidelines that are specific to a collection. folder: "_posts" - frontmatter_delimiter: "what" slug: "{{year}}-{{month}}-{{day}}-{{slug}}" create: true # Allow users to create new documents in this collection fields: # The fields each document in this collection have From 64433de723612732c2907cf575f2da9c7f0ad045 Mon Sep 17 00:00:00 2001 From: Swieckowski Date: Thu, 8 Feb 2018 19:29:05 -0500 Subject: [PATCH 14/17] moved frontmatterFormats to formats --- src/formats/formats.js | 2 ++ src/reducers/collections.js | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/formats/formats.js b/src/formats/formats.js index 56f085275352..38be81e89fc8 100644 --- a/src/formats/formats.js +++ b/src/formats/formats.js @@ -3,6 +3,8 @@ import tomlFormatter from './toml'; import jsonFormatter from './json'; import { FrontmatterInfer, frontmatterJSON, frontmatterTOML, frontmatterYAML } from './frontmatter'; +export const frontmatterFormats = ['yaml-frontmatter','toml-frontmatter','json-frontmatter'] + export const supportedFormats = [ 'yml', 'yaml', diff --git a/src/reducers/collections.js b/src/reducers/collections.js index e0c545c4260c..bddf78a713e0 100644 --- a/src/reducers/collections.js +++ b/src/reducers/collections.js @@ -4,7 +4,7 @@ import consoleError from 'Lib/consoleError'; import { CONFIG_SUCCESS } from 'Actions/config'; import { FILES, FOLDER } from 'Constants/collectionTypes'; import { INFERABLE_FIELDS } from 'Constants/fieldInference'; -import { formatByExtension, formatToExtension, supportedFormats } from 'Formats/formats'; +import { formatByExtension, formatToExtension, supportedFormats, frontmatterFormats } from 'Formats/formats'; const collections = (state = null, action) => { const configCollections = action.payload && action.payload.collections; @@ -38,7 +38,6 @@ function validateCollection(configCollection) { // Cannot infer format from extension. throw new Error(`Please set a format for collection "${ collectionName }". Supported formats are ${ supportedFormats.join(',') }`); } - const frontmatterFormats = ['yaml-frontmatter','toml-frontmatter','json-frontmatter'] if (has(configCollection, 'frontmatter_delimiter') && !frontmatterFormats.includes(get(configCollection, 'format'))) { // Cannot set custom delimiter without explicit and proper frontmatter format declaration throw new Error(`Please set a proper frontmatter format for collection "${ collectionName }" to use a custom delimiter. Supported frontmatter formats are yaml-frontmatter, toml-frontmatter, and json-frontmatter.`); From b6072f077194bbf9f70c1563251cd3fa56cffbd3 Mon Sep 17 00:00:00 2001 From: Caleb Date: Thu, 8 Feb 2018 17:40:04 -0700 Subject: [PATCH 15/17] Update .all-contributorsrc --- .all-contributorsrc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index fc7fe830b449..5f1d4c757762 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -718,6 +718,8 @@ "contributions": [ "code" ] + }, + { "login": "pixelastic", "name": "Tim Carry", "avatar_url": "https://avatars2.githubusercontent.com/u/283419?v=4", From e0d53018d86f41a58300a43295af6f00456e0bc9 Mon Sep 17 00:00:00 2001 From: Swieckowski Date: Thu, 8 Feb 2018 19:43:41 -0500 Subject: [PATCH 16/17] updated contributions --- .all-contributorsrc | 4 +++- README.md | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 5f1d4c757762..1ff144fab29e 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -716,7 +716,9 @@ "avatar_url": "https://avatars0.githubusercontent.com/u/31023010?v=4", "profile": "https://www.linkedin.com/in/arthur-swieckowski/", "contributions": [ - "code" + "code", + "doc", + "test" ] }, { diff --git a/README.md b/README.md index c41f484d8fdb..6ace4e1ea8ec 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Netlify CMS -[![All Contributors](https://img.shields.io/badge/all_contributors-86-orange.svg)](#contributors) +[![All Contributors](https://img.shields.io/badge/all_contributors-87-orange.svg)](#contributors) [![Open Source Helpers](https://www.codetriage.com/netlify/netlify-cms/badges/users.svg)](https://www.codetriage.com/netlify/netlify-cms) [![](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/netlify/netlifycms) @@ -61,8 +61,8 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds | [
Etienne Bernard](https://github.com/ebernard)
[📖](https://github.com/netlify/netlify-cms/commits?author=ebernard "Documentation") | [
Eli Williamson](http://eliwilliamson.com)
[💻](https://github.com/netlify/netlify-cms/commits?author=eliwilliamson "Code") [🎨](#design-eliwilliamson "Design") | [
Covington Doan](https://www.covingtondoan.com)
[📖](https://github.com/netlify/netlify-cms/commits?author=covingtondoan "Documentation") | [
Lennart Ziburski](http://lennartziburski.com)
[💻](https://github.com/netlify/netlify-cms/commits?author=ziburski "Code") [🎨](#design-ziburski "Design") [📖](https://github.com/netlify/netlify-cms/commits?author=ziburski "Documentation") | [
Darrel O'Pry](http://darrelopry.com)
[💻](https://github.com/netlify/netlify-cms/commits?author=dopry "Code") [🚇](#infra-dopry "Infrastructure (Hosting, Build-Tools, etc)") [⚠️](https://github.com/netlify/netlify-cms/commits?author=dopry "Tests") | [
Erin Symons](https://github.com/yourfrienderin)
[📖](https://github.com/netlify/netlify-cms/commits?author=yourfrienderin "Documentation") | [
Austin Green](https://github.com/AustinGreen)
[📖](https://github.com/netlify/netlify-cms/commits?author=AustinGreen "Documentation") [💡](#example-AustinGreen "Examples") | | [
Bryan Robinson](http://bryanlrobinson.com)
[📖](https://github.com/netlify/netlify-cms/commits?author=brob "Documentation") | [
Darren](https://github.com/dardub)
[📖](https://github.com/netlify/netlify-cms/commits?author=dardub "Documentation") | [
Richard Pullinger](http://www.richardpullinger.com)
[💻](https://github.com/netlify/netlify-cms/commits?author=rpullinger "Code") | [
Taylor Bryant](https://taylorbryant.blog)
[📖](https://github.com/netlify/netlify-cms/commits?author=taylorbryant "Documentation") | [
kvanerkelens](https://github.com/kvanerkelens)
[📖](https://github.com/netlify/netlify-cms/commits?author=kvanerkelens "Documentation") | [
Patrick Sier](https://patsier.com/)
[💻](https://github.com/netlify/netlify-cms/commits?author=pjsier "Code") | [
Christian Nolte](http://noltech.net)
[💻](https://github.com/netlify/netlify-cms/commits?author=drlogout "Code") | | [
Edward Betts](http://edwardbetts.com/)
[📖](https://github.com/netlify/netlify-cms/commits?author=EdwardBetts "Documentation") | [
Josh Hardman](https://github.com/jhardman0830)
[📖](https://github.com/netlify/netlify-cms/commits?author=jhardman0830 "Documentation") | [
Mantas](https://behance.net/mistermantas)
[📖](https://github.com/netlify/netlify-cms/commits?author=mistermantas "Documentation") | [
Marco Biedermann](https://www.marcobiedermann.com)
[📖](https://github.com/netlify/netlify-cms/commits?author=marcobiedermann "Documentation") | [
Max Stoiber](https://mxstbr.blog/newsletter)
[📖](https://github.com/netlify/netlify-cms/commits?author=mxstbr "Documentation") | [
Vyacheslav Matyukhin](http://berekuk.ru)
[📖](https://github.com/netlify/netlify-cms/commits?author=berekuk "Documentation") | [
jimmaaay](https://jimmythompson.me)
[💻](https://github.com/netlify/netlify-cms/commits?author=jimmaaay "Code") | -| [
Luís Miguel](https://github.com/Quicksaver)
[🐛](https://github.com/netlify/netlify-cms/issues?q=author%3AQuicksaver "Bug reports") [💻](https://github.com/netlify/netlify-cms/commits?author=Quicksaver "Code") | [
Chris Swithinbank](http://chrisswithinbank.net/)
[📖](https://github.com/netlify/netlify-cms/commits?author=delucis "Documentation") | [
remmah](https://github.com/remmah)
[📖](https://github.com/netlify/netlify-cms/commits?author=remmah "Documentation") | [
Sumeet Jain](http://sumeetjain.com)
[📖](https://github.com/netlify/netlify-cms/commits?author=sumeetjain "Documentation") | [
Sagar Khatri](https://github.com/ragasirtahk)
[📖](https://github.com/netlify/netlify-cms/commits?author=ragasirtahk "Documentation") [💡](#example-ragasirtahk "Examples") | [
Kevin Doocey](https://www.dooceykev.in)
[💻](https://github.com/netlify/netlify-cms/commits?author=Doocey "Code") | [
Swieckowski](https://www.linkedin.com/in/arthur-swieckowski/)
[💻](https://github.com/netlify/netlify-cms/commits?author=Swieckowski "Code") | [
Tim Carry](http://www.pixelastic.com/)
[💻](https://github.com/netlify/netlify-cms/commits?author=pixelastic "Code") [🎨](#design-pixelastic "Design") [📖](https://github.com/netlify/netlify-cms/commits?author=pixelastic "Documentation") | -| [
Sol Park](https://github.com/solpark)
[💻](https://github.com/netlify/netlify-cms/commits?author=solpark "Code") | [
Michael Romani](https://github.com/michaelromani)
[💻](https://github.com/netlify/netlify-cms/commits?author=michaelromani "Code") | +| [
Luís Miguel](https://github.com/Quicksaver)
[🐛](https://github.com/netlify/netlify-cms/issues?q=author%3AQuicksaver "Bug reports") [💻](https://github.com/netlify/netlify-cms/commits?author=Quicksaver "Code") | [
Chris Swithinbank](http://chrisswithinbank.net/)
[📖](https://github.com/netlify/netlify-cms/commits?author=delucis "Documentation") | [
remmah](https://github.com/remmah)
[📖](https://github.com/netlify/netlify-cms/commits?author=remmah "Documentation") | [
Sumeet Jain](http://sumeetjain.com)
[📖](https://github.com/netlify/netlify-cms/commits?author=sumeetjain "Documentation") | [
Sagar Khatri](https://github.com/ragasirtahk)
[📖](https://github.com/netlify/netlify-cms/commits?author=ragasirtahk "Documentation") [💡](#example-ragasirtahk "Examples") | [
Kevin Doocey](https://www.dooceykev.in)
[💻](https://github.com/netlify/netlify-cms/commits?author=Doocey "Code") | [
Swieckowski](https://www.linkedin.com/in/arthur-swieckowski/)
[💻](https://github.com/netlify/netlify-cms/commits?author=Swieckowski "Code") [📖](https://github.com/netlify/netlify-cms/commits?author=Swieckowski "Documentation") [⚠️](https://github.com/netlify/netlify-cms/commits?author=Swieckowski "Tests") | +| [
Tim Carry](http://www.pixelastic.com/)
[💻](https://github.com/netlify/netlify-cms/commits?author=pixelastic "Code") [🎨](#design-pixelastic "Design") [📖](https://github.com/netlify/netlify-cms/commits?author=pixelastic "Documentation") | [
Sol Park](https://github.com/solpark)
[💻](https://github.com/netlify/netlify-cms/commits?author=solpark "Code") | [
Michael Romani](https://github.com/michaelromani)
[💻](https://github.com/netlify/netlify-cms/commits?author=michaelromani "Code") | This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome! From 98b33c99e9c025440c51e700b6519004eb13bd9f Mon Sep 17 00:00:00 2001 From: Caleb Date: Thu, 8 Feb 2018 17:50:45 -0700 Subject: [PATCH 17/17] Clarify docs --- website/site/content/docs/configuration-options.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/website/site/content/docs/configuration-options.md b/website/site/content/docs/configuration-options.md index 1e15bf3deada..d744c27b4b5a 100644 --- a/website/site/content/docs/configuration-options.md +++ b/website/site/content/docs/configuration-options.md @@ -77,6 +77,7 @@ The `collections` setting is the heart of your Netlify CMS configuration, as it - `delete`: `false` prevents users from deleting items in a collection; defaults to `true` - `extension`: see detailed description below - `format`: see detailed description below +- `frontmatter_delimiter`: see detailed description under `format` - `slug`: see detailed description below - `fields` (required): see detailed description below @@ -99,7 +100,8 @@ You may also specify a custom `extension` not included in the list above, as lon - `yaml-frontmatter`: same as the `frontmatter` format above, except frontmatter will be both parsed and saved only as YAML, followed by unparsed body text. The default delimiter for this option is `---`. - `toml-frontmatter`: same as the `frontmatter` format above, except frontmatter will be both parsed and saved only as TOML, followed by unparsed body text. The default delimiter for this option is `+++`. - `json-frontmatter`: same as the `frontmatter` format above, except frontmatter will be both parsed and saved as JSON, followed by unparsed body text. The default delimiter for this option is `{` `}`. -- `frontmatter_delimiter`: if you have an explicit frontmatter format declared, this option allows you to specify a custom delimiter like `~~~`. + +`frontmatter_delimiter`: if you have an explicit frontmatter format declared, this option allows you to specify a custom delimiter like `~~~`. ### `slug`