From 215cb21e892bfb4682f154406c61980690455eaf Mon Sep 17 00:00:00 2001 From: Daniel Lautzenheiser Date: Tue, 31 Oct 2023 11:31:04 -0400 Subject: [PATCH] feat: basic support for mdx file extension (#964) --- packages/app/.editorconfig | 3 ++ packages/core/.editorconfig | 3 ++ .../backends/proxy/_data/navigation.mdx | 26 +++++++++++++ .../core/dev-test/backends/proxy/config.yml | 39 +++++++++++++++++++ packages/core/src/formats/formats.ts | 1 + packages/docs/.editorconfig | 3 ++ .../docs/content/docs/collection-overview.mdx | 2 +- 7 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 packages/core/dev-test/backends/proxy/_data/navigation.mdx diff --git a/packages/app/.editorconfig b/packages/app/.editorconfig index 5fe0621b..e2e9c447 100644 --- a/packages/app/.editorconfig +++ b/packages/app/.editorconfig @@ -17,3 +17,6 @@ quote_type = single [*.md] trim_trailing_whitespace = false + +[*.mdx] +trim_trailing_whitespace = false diff --git a/packages/core/.editorconfig b/packages/core/.editorconfig index 5fe0621b..e2e9c447 100644 --- a/packages/core/.editorconfig +++ b/packages/core/.editorconfig @@ -17,3 +17,6 @@ quote_type = single [*.md] trim_trailing_whitespace = false + +[*.mdx] +trim_trailing_whitespace = false diff --git a/packages/core/dev-test/backends/proxy/_data/navigation.mdx b/packages/core/dev-test/backends/proxy/_data/navigation.mdx new file mode 100644 index 00000000..89d86efc --- /dev/null +++ b/packages/core/dev-test/backends/proxy/_data/navigation.mdx @@ -0,0 +1,26 @@ +--- +main_menu: + - label: News + href: /news + - label: Features + href: '#features' + - label: About + href: '#about' + - label: Contact + href: '#contact' +footer_menus: + - label: Company + links: + - label: Home + href: / + - label: 'Privacy Policy ' + href: '#' + - label: About us + href: '#' + - label: Documentation + links: + - label: Docs + href: '#' + - label: Blog + href: '#' +--- diff --git a/packages/core/dev-test/backends/proxy/config.yml b/packages/core/dev-test/backends/proxy/config.yml index 77021776..2cbeb28f 100644 --- a/packages/core/dev-test/backends/proxy/config.yml +++ b/packages/core/dev-test/backends/proxy/config.yml @@ -176,6 +176,45 @@ collections: - label: Description name: description widget: text + + - name: navigation + label: Navigation + file: packages/core/dev-test/backends/proxy/_data/navigation.mdx + extension: mdx + format: yaml-frontmatter + fields: + - name: main_menu + label: Main Menu + widget: list + collapsed: true + fields: + - name: label + label: Label + widget: string + - name: href + label: Href + widget: string + - name: footer_menus + label: Footer Menus + widget: list + collapsed: true + reuired: false + fields: + - name: label + label: Label + widget: string + - name: links + label: Links + widget: list + collapsed: true + fields: + - name: label + label: Label + widget: string + - name: href + label: Href + widget: string + - name: kitchenSink label: Kitchen Sink folder: packages/core/dev-test/backends/proxy/_sink diff --git a/packages/core/src/formats/formats.ts b/packages/core/src/formats/formats.ts index cb728211..0de5de4b 100644 --- a/packages/core/src/formats/formats.ts +++ b/packages/core/src/formats/formats.ts @@ -26,6 +26,7 @@ export const extensionFormatters: Record = { toml: TomlFormatter, json: JsonFormatter, md: FrontmatterInfer, + mdx: FrontmatterInfer, markdown: FrontmatterInfer, html: FrontmatterInfer, }; diff --git a/packages/docs/.editorconfig b/packages/docs/.editorconfig index 5fe0621b..e2e9c447 100644 --- a/packages/docs/.editorconfig +++ b/packages/docs/.editorconfig @@ -17,3 +17,6 @@ quote_type = single [*.md] trim_trailing_whitespace = false + +[*.mdx] +trim_trailing_whitespace = false diff --git a/packages/docs/content/docs/collection-overview.mdx b/packages/docs/content/docs/collection-overview.mdx index 7c09e0d9..fbf35ccc 100644 --- a/packages/docs/content/docs/collection-overview.mdx +++ b/packages/docs/content/docs/collection-overview.mdx @@ -57,7 +57,7 @@ collections: [ These settings determine how collection files are parsed and saved. Both are optional—Static CMS will attempt to infer your settings based on existing items in the collection. If your collection is empty, or you'd like more control, you can set these fields explicitly. -`extension` determines the file extension searched for when finding existing entries in a folder collection and it determines the file extension used to save new collection items. It accepts the following values: `yml`, `yaml`, `json`, `md`, `markdown`, `html`. +`extension` determines the file extension searched for when finding existing entries in a folder collection and it determines the file extension used to save new collection items. It accepts the following values: `yml`, `yaml`, `json`, `md`, `markdown`, `mdx`, `html`. You may also specify a custom `extension` not included in the list above, as long as the collection files can be parsed and saved in one of the supported formats below.