1
1
mirror of https://github.com/primer/css.git synced 2024-11-28 22:01:43 +03:00

Remove lib directory

This commit is contained in:
Cole Bemis 2019-08-12 15:35:07 -07:00
parent c358916d8d
commit 1bcaf6695d
4 changed files with 0 additions and 165 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'), require.resolve('./search-loader')]
})
if (typeof nextConfig.webpack === 'function') {
return nextConfig.webpack(config, options)
}
return config
}
})
}

View File

@ -1,47 +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)
}
const code = `
import React from 'react'
import {MDXTag} from '@mdx-js/tag'
${result}
`
return callback(null, code)
}

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
}

View File

@ -1,13 +0,0 @@
const grayMatter = require('gray-matter')
const fs = require('fs')
const {join} = require('path')
const searchIndex = {}
const searchIndexPath = join(process.cwd(), 'searchIndex.js')
module.exports = function(source) {
const {data, content} = grayMatter(source)
searchIndex[data.path] = Object.assign({title: data.title, path: data.path, keywords: data.keywords}, {content})
fs.writeFileSync(searchIndexPath, `export default ${JSON.stringify(searchIndex, null, 2)}`, 'utf8')
return source
}