diff --git a/lib/config.js b/lib/config.js index fd4aa753..df110b5d 100644 --- a/lib/config.js +++ b/lib/config.js @@ -11,10 +11,13 @@ module.exports = (nextConfig = {}) => { assetPrefix, pageExtensions: ['js', 'jsx', 'md', 'mdx'], - publicRuntimeConfig: Object.assign({ - assetPrefix, - production: NODE_ENV === 'production' - }, nextConfig.publicRuntimeConfig), + publicRuntimeConfig: Object.assign( + { + assetPrefix, + production: NODE_ENV === 'production' + }, + nextConfig.publicRuntimeConfig + ), webpack(config, options) { if (!options.defaultLoaders) { @@ -23,7 +26,7 @@ module.exports = (nextConfig = {}) => { ) } - const {dev, isServer} = options + const {dev} = options // only attempt to sync locally and in CI if (dev && !configured) { @@ -37,10 +40,7 @@ module.exports = (nextConfig = {}) => { config.module.rules.push({ test: /\.mdx?$/, - use: [ - options.defaultLoaders.babel, - require.resolve('./mdx-loader') - ] + use: [options.defaultLoaders.babel, require.resolve('./mdx-loader')] }) configured = true diff --git a/lib/mdx-loader.js b/lib/mdx-loader.js index bb8335d6..8072d69f 100644 --- a/lib/mdx-loader.js +++ b/lib/mdx-loader.js @@ -24,9 +24,7 @@ module.exports = async function(source) { emoji, [textr, {plugins: [typographicBase]}] ], - hastPlugins: [ - rehypePrism - ], + hastPlugins: [rehypePrism], compilers: [mdxExportJSONByDefault('frontMatter', data)] }, getOptions(this), @@ -39,11 +37,12 @@ module.exports = async function(source) { return callback(err) } - let code = ` + return callback( + null, + ` import React from 'react' import {MDXTag} from '@mdx-js/tag' ${result} ` - - return callback(null, code) + ) } diff --git a/lib/rehype-prism.js b/lib/rehype-prism.js index 1cf431fc..4290825b 100644 --- a/lib/rehype-prism.js +++ b/lib/rehype-prism.js @@ -27,7 +27,7 @@ module.exports = options => { let result = node const source = nodeToString(node) try { - parent.properties.className = (parent.properties.className || []).concat('language-' + lang) + parent.properties.className = (parent.properties.className || []).concat(`language-${lang}`) result = refractor.highlight(source, lang) } catch (err) { if (/Unknown language/.test(err.message)) { @@ -52,8 +52,8 @@ function getLanguage(node, aliases) { for (const classListItem of className) { if (classListItem.slice(0, 9) === 'language-') { - let language = classListItem.slice(9).replace(/{.*/, '') - let alias = aliases[language] + const language = classListItem.slice(9).replace(/{.*/, '') + const alias = aliases[language] return alias || language } } diff --git a/lib/rename.js b/lib/rename.js index a9d697a8..603f7448 100644 --- a/lib/rename.js +++ b/lib/rename.js @@ -2,7 +2,7 @@ module.exports = function rename(fn, options = {}) { const {log = noop} = options return (files, metal, done) => { for (const [key, file] of Object.entries(files)) { - let dest = fn(file, key, files, metal) + const dest = fn(file, key, files, metal) if (dest === true) { log(`[rename] keep: ${key}`) } else if (dest && dest !== key) {