Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for other markdown file extensions #612

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/isomorphic/create-routes.js
Expand Up @@ -97,7 +97,13 @@ module.exports = (files, pagesReq) => {
const staticFileTypes = [
'ipynb',
'md',
'rmd',
'mkd',
'mkdn',
'mdwn',
'mdown',
'markdown',
'litcoffee',
'html',
'json',
'yaml',
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/build-page/load-frontmatter.js
Expand Up @@ -16,7 +16,7 @@ export default function loadFrontmatter (pagePath: string): {} {
// in the browser.

let data
if (ext === 'md') {
if (ext.match(/^(md|rmd|mkdn?|mdwn|mdown|markdown|litcoffee)$/)) {
const rawData = frontMatter(fs.readFileSync(pagePath, { encoding: 'utf-8' }))
data = objectAssign({}, rawData.attributes)
} else if (ext === 'html') {
Expand Down
4 changes: 2 additions & 2 deletions lib/utils/load-context.js
Expand Up @@ -2,10 +2,10 @@
// This file is auto-written and used by Gatsby to require
// files from your pages directory.
module.exports = function (callback) {
let context = require.context('./pages', true, /(coffee|cjsx|ts|tsx|jsx|js|markdown|md|ipynb|html|json|yaml|toml)$/) // eslint-disable-line
let context = require.context('./pages', true, /(coffee|cjsx|ts|tsx|jsx|js|md|rmd|mkdn?|mdwn|mdown|markdown|litcoffee|ipynb|html|json|yaml|toml)$/) // eslint-disable-line
if (module.hot) {
module.hot.accept(context.id, () => {
context = require.context('./pages', true, /(coffee|cjsx|ts|tsx|jsx|js|markdown|md|ipynb|html|json|yaml|toml)$/) // eslint-disable-line
context = require.context('./pages', true, /(coffee|cjsx|ts|tsx|jsx|js|md|rmd|mkdn?|mdwn|mdown|markdown|litcoffee|ipynb|html|json|yaml|toml)$/) // eslint-disable-line
return callback(context)
})
}
Expand Down
8 changes: 7 additions & 1 deletion lib/utils/page-file-types.js
Expand Up @@ -5,8 +5,14 @@ const pageFileTypes = [
'tsx',
'jsx',
'js',
'markdown',
'md',
'rmd',
'mkd',
'mkdn',
'mdwn',
'mdown',
'markdown',
'litcoffee',
'html',
'json',
'yaml',
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/webpack.config.js
Expand Up @@ -245,7 +245,7 @@ module.exports = (program, directory, suppliedStage, webpackPort = 1500, routes
],
})
config.loader('md', {
test: /\.md$/,
test: /\.(md|rmd|mkdn?|mdwn|mdown|markdown|litcoffee)$/,
loader: 'markdown',
})
config.loader('html', {
Expand Down