1
1
mirror of https://github.com/primer/css.git synced 2024-09-21 05:39:15 +03:00

remove old lib

This commit is contained in:
emplums 2019-04-02 22:36:44 -07:00
parent 09674e3e02
commit 165d4a5961
3 changed files with 0 additions and 153 deletions

View File

@ -1,43 +0,0 @@
/* eslint-disable no-console */
const {NODE_ENV, NOW_URL} = process.env
module.exports = (nextConfig = {}) => {
const {assetPrefix = NOW_URL || ''} = nextConfig
return Object.assign({}, nextConfig, {
assetPrefix,
pageExtensions: ['js', 'jsx', 'md', 'mdx'],
publicRuntimeConfig: Object.assign(
{
assetPrefix,
production: NODE_ENV === 'production'
},
nextConfig.publicRuntimeConfig
),
webpack(config, options) {
if (!options.defaultLoaders) {
throw new Error(
'This plugin is not compatible with Next.js versions below 5.0.0 https://err.sh/next-plugins/upgrade'
)
}
config.module.rules.push({
test: /\.svg$/,
use: '@svgr/webpack'
})
config.module.rules.push({
test: /\.mdx?$/,
use: [options.defaultLoaders.babel, require.resolve('./mdx-loader')]
})
if (typeof nextConfig.webpack === 'function') {
return nextConfig.webpack(config, options)
}
return config
}
})
}

View File

@ -1,48 +0,0 @@
const {getOptions} = require('loader-utils')
const mdx = require('@mdx-js/mdx')
const emoji = require('remark-emoji')
const images = require('remark-images')
const rehypePrism = require('./rehype-prism')
const textr = require('remark-textr')
const toc = require('remark-toc')
const mdxExportJSONByDefault = require('mdx-constant')
const grayMatter = require('gray-matter')
const typographicBase = require('typographic-base')
module.exports = async function(source) {
let result
const {data, content: mdxContent} = grayMatter(source)
const callback = this.async()
const options = Object.assign(
{
mdPlugins: [
[toc, {heading: '(table of|section)? contents'}],
images,
emoji,
[textr, {plugins: [typographicBase]}]
],
hastPlugins: [rehypePrism],
compilers: [mdxExportJSONByDefault('frontMatter', data)]
},
getOptions(this),
{filepath: this.resourcePath}
)
try {
result = await mdx(mdxContent, options)
} catch (err) {
return callback(err)
}
return callback(
null,
`
import React from 'react'
import {MDXTag} from '@mdx-js/tag'
${result}
`
)
}

View File

@ -1,62 +0,0 @@
const visit = require('unist-util-visit')
const nodeToString = require('hast-util-to-string')
const nodeToHTML = require('hast-util-to-html')
const refractor = require('refractor')
const aliases = {
js: 'jsx',
html: 'markup'
}
module.exports = options => {
options = options || {}
return tree => visit(tree, 'element', visitor)
function visitor(node, index, parent) {
if (!parent || parent.tagName !== 'pre' || node.tagName !== 'code') {
return
}
const lang = getLanguage(node, options.aliases || aliases)
if (lang === null) {
return
}
let result = node
const source = nodeToString(node)
try {
parent.properties.className = (parent.properties.className || []).concat(`language-${lang}`)
result = refractor.highlight(source, lang)
} catch (err) {
if (/Unknown language/.test(err.message)) {
return
}
throw err
}
node.children = []
node.properties.source = source
node.properties.dangerouslySetInnerHTML = {
__html: nodeToHTML({
type: 'root',
children: result
})
}
}
}
function getLanguage(node, aliases) {
const className = node.properties.className || []
for (const classListItem of className) {
if (classListItem.slice(0, 9) === 'language-') {
const language = classListItem.slice(9).replace(/{.*/, '')
const alias = aliases[language]
return alias || language
}
}
return null
}