Skip to content

Commit

Permalink
feat: basic support for mdx file extension (StaticJsCMS#964)
Browse files Browse the repository at this point in the history
  • Loading branch information
KaneFreeman authored Oct 31, 2023
1 parent 597d135 commit 215cb21
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/app/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ quote_type = single

[*.md]
trim_trailing_whitespace = false

[*.mdx]
trim_trailing_whitespace = false
3 changes: 3 additions & 0 deletions packages/core/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ quote_type = single

[*.md]
trim_trailing_whitespace = false

[*.mdx]
trim_trailing_whitespace = false
26 changes: 26 additions & 0 deletions packages/core/dev-test/backends/proxy/_data/navigation.mdx
Original file line number Diff line number Diff line change
@@ -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: '#'
---
39 changes: 39 additions & 0 deletions packages/core/dev-test/backends/proxy/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/formats/formats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const extensionFormatters: Record<string, FileFormatter> = {
toml: TomlFormatter,
json: JsonFormatter,
md: FrontmatterInfer,
mdx: FrontmatterInfer,
markdown: FrontmatterInfer,
html: FrontmatterInfer,
};
Expand Down
3 changes: 3 additions & 0 deletions packages/docs/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ quote_type = single

[*.md]
trim_trailing_whitespace = false

[*.mdx]
trim_trailing_whitespace = false
2 changes: 1 addition & 1 deletion packages/docs/content/docs/collection-overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down

0 comments on commit 215cb21

Please sign in to comment.