Skip to content

Commit

Permalink
mime-db switched to text/markdown from text/x-markdown for the mimeTy…
Browse files Browse the repository at this point in the history
…pe of markdown (#1945)

* mime-db switched to text/markdown from text/x-markdown for the mimeType of markdown

* Logic… it be hard
  • Loading branch information
KyleAMathews committed Aug 28, 2017
1 parent 0446fd2 commit 116b64b
Show file tree
Hide file tree
Showing 15 changed files with 55 additions and 52 deletions.
2 changes: 1 addition & 1 deletion docs/docs/create-source-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ For example, it's quite common for services to allow you to add content as markd
If you pull that markdown into Gatsby and create a new node, what then? How would
a user of your source plugin convert that markdown into HTML they can use in
their site? Luckily you don't have to do anything. Just create a node for the markdown
content and set its mediaType as `text/x-markdown` and the various Gatsby markdown transformer
content and set its mediaType as `text/markdown` and the various Gatsby markdown transformer
plugins will see your node and transform it into HTML.

This loose coupling between data source and transformer plugins allow Gatsby site
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/node-interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ nodes.
* The [Remark
(Markdown library) transformer
plugin](/packages/gatsby-transformer-remark/) looks for new nodes that
are created with a `mediaType` of `text/x-markdown` and then transforms these
are created with a `mediaType` of `text/markdown` and then transforms these
nodes into `MarkdownRemark` nodes with an `html` field.
* The [YAML transformer plugin](/packages/gatsby-transformer-yaml/) looks
for new nodes with a media type of `text/yaml` (e.g. a `.yaml` file) and creates new
Expand Down
2 changes: 1 addition & 1 deletion examples/using-mongodb/gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
options: { dbName: `cloud`, collection: `documents`,
server: { address: `ds143532.mlab.com`, port: 43532 },
auth: { user: `admin`, password: `12345` },
map: {description: `text/x-markdown`}
map: {description: `text/markdown`}
},
},
`gatsby-plugin-react-helmet`,
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/gatsby-source-contentful/src/normalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ function createTextNode(node, key, text, createNode) {
[key]: str,
internal: {
type: _.camelCase(`${node.internal.type} ${key} TextNode`),
mediaType: `text/x-markdown`,
mediaType: `text/markdown`,
content: str,
contentDigest: digest(str),
},
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-source-mongodb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module.exports = {
dbName: `local`,
collection: `documents`
map: {
body: `text/x-markdown`,
body: `text/markdown`,
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Array [
"content": "A pretty cool jsdoc example
",
"contentDigest": "1effd106a9028bac69276a250a0f96f5",
"mediaType": "text/x-markdown",
"mediaType": "text/markdown",
"type": "DocumentationJSComponentDescription",
},
"parent": "node_1",
Expand All @@ -21,7 +21,7 @@ Array [
"content": "A nice crispy apple
",
"contentDigest": "bdc56b714e173673c86ecf5f556c5fd1",
"mediaType": "text/x-markdown",
"mediaType": "text/markdown",
"type": "DocumentationJSComponentDescription",
},
"parent": "node_1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe(`transformer-react-doc-gen: onCreateNode`, () => {
let types = groupBy(createdNodes, `internal.type`)
expect(
types.DocumentationJSComponentDescription.every(
d => d.internal.mediaType === `text/x-markdown`
d => d.internal.mediaType === `text/markdown`
)
).toBe(true)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function createDescriptionNode(
children: [],
internal: {
type: `DocumentationJSComponentDescription`,
mediaType: `text/x-markdown`,
mediaType: `text/markdown`,
content: markdownStr,
contentDigest: digest(markdownStr),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe(`transformer-react-doc-gen: onCreateNode`, () => {
let types = groupBy(createdNodes, `internal.type`)
expect(
types.ComponentDescription.every(
d => d.internal.mediaType === `text/x-markdown`
d => d.internal.mediaType === `text/markdown`
)
).toBe(true)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function createDescriptionNode(node, entry, boundActionCreators) {
text: entry.description,
internal: {
type: `ComponentDescription`,
mediaType: `text/x-markdown`,
mediaType: `text/markdown`,
content: entry.description,
contentDigest: digest(entry.description),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Where oh where is my little pony?
"id": "whatever",
"internal": Object {
"contentDigest": "whatever",
"mediaType": "text/x-markdown",
"mediaType": "text/markdown",
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe(`Process markdown content correctly`, () => {
children: [],
internal: {
contentDigest: `whatever`,
mediaType: `text/x-markdown`,
mediaType: `text/markdown`,
},
}

Expand Down
5 changes: 4 additions & 1 deletion packages/gatsby-transformer-remark/src/on-node-create.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ module.exports = async function onCreateNode({
const { createNode, createParentChildLink } = boundActionCreators

// We only care about markdown content.
if (node.internal.mediaType !== `text/x-markdown`) {
if (
node.internal.mediaType !== `text/markdown` &&
node.internal.mediaType !== `text/x-markdown`
) {
return
}

Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby/src/redux/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ const typeOwners = {}
* one if your data doesn't fit in any existing bucket. Transformer plugins
* frequently use node media types for deciding if they should transform a
* node into a new one. E.g. markdown transformers look for media types of
* text/x-markdown.
* text/markdown.
* @param {string} node.internal.type An arbitrary globally unique type
* choosen by the plugin creating the node. Should be descriptive of the
* node as the type is used in forming GraphQL types so users will query
Expand All @@ -232,7 +232,7 @@ const typeOwners = {}
* parent: `the-id-of-the-parent-node`,
* children: [],
* internal: {
* mediaType: `text/x-markdown`,
* mediaType: `text/markdown`,
* type: `CoolServiceMarkdownField`,
* content: JSON.stringify(fieldData),
* contentDigest: crypto
Expand Down

0 comments on commit 116b64b

Please sign in to comment.