mirror of
https://github.com/explosion/spaCy.git
synced 2025-08-06 05:10:21 +03:00
Remove unused files
This commit is contained in:
parent
5f4abe40ef
commit
e89d61e7c9
|
@ -1,50 +0,0 @@
|
||||||
import { navigate } from 'gatsby'
|
|
||||||
|
|
||||||
import './src/styles/layout.sass'
|
|
||||||
import Juniper from './src/components/juniper'
|
|
||||||
import 'intersection-observer'
|
|
||||||
|
|
||||||
// Workaround to rewrite anchor links
|
|
||||||
const clientSideRewrites = {
|
|
||||||
'/usage/linguistic-features/#rule-based-matching': '/usage/rule-based-matching',
|
|
||||||
}
|
|
||||||
|
|
||||||
/* eslint-disable */
|
|
||||||
import HKGroteskSemiBoldWOFF from './src/fonts/hkgrotesk-semibold.woff'
|
|
||||||
import HKGroteskSemiBoldWOFF2 from './src/fonts/hkgrotesk-semibold.woff2'
|
|
||||||
import HKGroteskSemiBoldItalicWOFF from './src/fonts/hkgrotesk-semibolditalic.woff'
|
|
||||||
import HKGroteskSemiBoldItalicWOFF2 from './src/fonts/hkgrotesk-semibolditalic.woff2'
|
|
||||||
import HKGroteskBoldWOFF from './src/fonts/hkgrotesk-bold.woff'
|
|
||||||
import HKGroteskBoldWOFF2 from './src/fonts/hkgrotesk-bold.woff2'
|
|
||||||
import HKGroteskBoldItalicWOFF from './src/fonts/hkgrotesk-bolditalic.woff'
|
|
||||||
import HKGroteskBoldItalicWOFF2 from './src/fonts/hkgrotesk-bolditalic.woff2'
|
|
||||||
/* eslint-enable */
|
|
||||||
|
|
||||||
export const onInitialClientRender = () => {
|
|
||||||
// Importing Juniper in the component currently causes various problems
|
|
||||||
// because of the global window reference in its dependencies. So this
|
|
||||||
// is kinda hacky at the moment.
|
|
||||||
window.Juniper = Juniper
|
|
||||||
}
|
|
||||||
|
|
||||||
export const onRouteUpdate = ({ location }) => {
|
|
||||||
window.dispatchEvent(new Event('resize')) // for progress
|
|
||||||
window.dispatchEvent(new Event('scroll')) // for progress
|
|
||||||
if (location.hash) {
|
|
||||||
// Client-side rewrites
|
|
||||||
const rewrite = clientSideRewrites[location.pathname + location.hash]
|
|
||||||
if (rewrite) {
|
|
||||||
navigate(rewrite)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
setTimeout(() => {
|
|
||||||
const el = document.querySelector(`${location.hash}`)
|
|
||||||
if (el) {
|
|
||||||
// Navigate to targeted element
|
|
||||||
el.scrollIntoView()
|
|
||||||
// Force recomputing :target pseudo class with pushState/popState
|
|
||||||
window.location.hash = location.hash
|
|
||||||
}
|
|
||||||
}, 0)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,176 +0,0 @@
|
||||||
const autoprefixer = require('autoprefixer')
|
|
||||||
const path = require('path')
|
|
||||||
|
|
||||||
// https://florian.ec/blog/gatsby-build-netlify-segmentation-fault/
|
|
||||||
const sharp = require('sharp')
|
|
||||||
sharp.cache(false)
|
|
||||||
sharp.simd(false)
|
|
||||||
|
|
||||||
// Markdown plugins
|
|
||||||
const wrapSectionPlugin = require('./src/plugins/remark-wrap-section.js')
|
|
||||||
const customAttrsPlugin = require('./src/plugins/remark-custom-attrs.js')
|
|
||||||
const codeBlocksPlugin = require('./src/plugins/remark-code-blocks.js')
|
|
||||||
|
|
||||||
// Import metadata
|
|
||||||
const site = require('./meta/site.json')
|
|
||||||
const { domain, nightly: isNightly, legacy: isLegacy } = site
|
|
||||||
const { siteUrl } = require('./meta/dynamicMeta')
|
|
||||||
|
|
||||||
const DEFAULT_TEMPLATE = path.resolve('./src/templates/index.js')
|
|
||||||
|
|
||||||
const favicon = `src/images/icon${isNightly ? '_nightly' : isLegacy ? '_legacy' : ''}.png`
|
|
||||||
const branch = isNightly ? 'develop' : 'master'
|
|
||||||
|
|
||||||
// Those variables are going to be replaced in the Markdown, e.g. %%GITHUB_SPACY
|
|
||||||
const replacements = {
|
|
||||||
GITHUB_SPACY: `https://github.com/explosion/spaCy/tree/${branch}`,
|
|
||||||
GITHUB_PROJECTS: `https://github.com/${site.projectsRepo}`,
|
|
||||||
SPACY_PKG_NAME: isNightly ? 'spacy-nightly' : 'spacy',
|
|
||||||
SPACY_PKG_FLAGS: isNightly ? ' --pre' : '',
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
siteMetadata: {
|
|
||||||
...site,
|
|
||||||
siteUrl,
|
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
{
|
|
||||||
resolve: `gatsby-plugin-sass`,
|
|
||||||
options: {
|
|
||||||
indentedSyntax: true,
|
|
||||||
postCssPlugins: [autoprefixer()],
|
|
||||||
cssLoaderOptions: {
|
|
||||||
localIdentName:
|
|
||||||
process.env.NODE_ENV == 'development'
|
|
||||||
? '[name]-[local]-[hash:8]'
|
|
||||||
: '[hash:8]',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
`gatsby-plugin-react-helmet`,
|
|
||||||
{
|
|
||||||
resolve: `gatsby-source-filesystem`,
|
|
||||||
options: {
|
|
||||||
name: `docs`,
|
|
||||||
path: `${__dirname}/docs`,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
resolve: `gatsby-source-filesystem`,
|
|
||||||
options: {
|
|
||||||
name: `pages`,
|
|
||||||
path: `${__dirname}/src/pages`,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
resolve: `gatsby-source-filesystem`,
|
|
||||||
options: {
|
|
||||||
name: `images`,
|
|
||||||
path: `${__dirname}/src/images`,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
resolve: `gatsby-source-filesystem`,
|
|
||||||
options: {
|
|
||||||
name: `docsImages`,
|
|
||||||
path: `${__dirname}/docs/images`,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
resolve: 'gatsby-plugin-react-svg',
|
|
||||||
options: {
|
|
||||||
rule: {
|
|
||||||
include: /src\/images\/(.*)\.svg/,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
resolve: `gatsby-mdx`,
|
|
||||||
options: {
|
|
||||||
root: __dirname,
|
|
||||||
extensions: ['.md', '.mdx'],
|
|
||||||
defaultLayouts: {
|
|
||||||
pages: DEFAULT_TEMPLATE,
|
|
||||||
},
|
|
||||||
mdPlugins: [customAttrsPlugin, wrapSectionPlugin, codeBlocksPlugin],
|
|
||||||
gatsbyRemarkPlugins: [
|
|
||||||
{
|
|
||||||
resolve: `gatsby-remark-smartypants`,
|
|
||||||
options: {
|
|
||||||
backticks: false,
|
|
||||||
dashes: 'oldschool',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
resolve: `gatsby-remark-images`,
|
|
||||||
options: {
|
|
||||||
maxWidth: 650,
|
|
||||||
linkImagesToOriginal: true,
|
|
||||||
sizeByPixelDensity: false,
|
|
||||||
showCaptions: true,
|
|
||||||
quality: 80,
|
|
||||||
withWebp: { quality: 80 },
|
|
||||||
wrapperStyle: { marginBottom: '20px' },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
// NB: This need to run after gatsby-remark-images!
|
|
||||||
resolve: `gatsby-remark-unwrap-images`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
resolve: `gatsby-remark-copy-linked-files`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
resolve: 'gatsby-remark-find-replace',
|
|
||||||
options: {
|
|
||||||
replacements,
|
|
||||||
prefix: '%%',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
`gatsby-transformer-sharp`,
|
|
||||||
`gatsby-plugin-sharp`,
|
|
||||||
`gatsby-plugin-catch-links`,
|
|
||||||
`gatsby-plugin-sitemap`,
|
|
||||||
{
|
|
||||||
resolve: `gatsby-plugin-manifest`,
|
|
||||||
options: {
|
|
||||||
name: site.title,
|
|
||||||
short_name: site.title,
|
|
||||||
start_url: `/`,
|
|
||||||
background_color: site.theme,
|
|
||||||
theme_color: site.theme,
|
|
||||||
display: `minimal-ui`,
|
|
||||||
icon: favicon,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
resolve: `gatsby-plugin-plausible`,
|
|
||||||
options: { domain },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
resolve: 'gatsby-plugin-robots-txt',
|
|
||||||
options: {
|
|
||||||
host: siteUrl,
|
|
||||||
sitemap: `${siteUrl}/sitemap.xml`,
|
|
||||||
// If we're in a special state (nightly, legacy) prevent indexing
|
|
||||||
resolveEnv: () => (isNightly ? 'development' : 'production'),
|
|
||||||
env: {
|
|
||||||
production: {
|
|
||||||
policy: [{ userAgent: '*', allow: '/' }],
|
|
||||||
},
|
|
||||||
development: {
|
|
||||||
policy: [
|
|
||||||
{ userAgent: '*', disallow: ['/'] },
|
|
||||||
{ userAgent: 'Twitterbot', allow: '/' },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
`gatsby-plugin-offline`,
|
|
||||||
],
|
|
||||||
}
|
|
|
@ -1,267 +0,0 @@
|
||||||
const path = require('path')
|
|
||||||
const { createFilePath } = require('gatsby-source-filesystem')
|
|
||||||
|
|
||||||
const DEFAULT_TEMPLATE = path.resolve('./src/templates/index.js')
|
|
||||||
const BASE_PATH = 'docs'
|
|
||||||
const PAGE_EXTENSIONS = ['.md', '.mdx']
|
|
||||||
const siteMetadata = require('./meta/site.json')
|
|
||||||
const universe = require('./meta/universe.json')
|
|
||||||
const models = require('./meta/languages.json')
|
|
||||||
|
|
||||||
function replacePath(pagePath) {
|
|
||||||
return pagePath === `/` ? pagePath : pagePath.replace(/\/$/, ``)
|
|
||||||
}
|
|
||||||
|
|
||||||
function getNodeTitle({ childMdx }) {
|
|
||||||
const frontmatter = (childMdx || {}).frontmatter || {}
|
|
||||||
return (frontmatter.title || '').replace("'", '’')
|
|
||||||
}
|
|
||||||
|
|
||||||
function findNode(pages, slug) {
|
|
||||||
return slug ? pages.find(({ node }) => node.fields.slug === slug) : null
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.createPages = ({ graphql, actions }) => {
|
|
||||||
const { createPage } = actions
|
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
resolve(
|
|
||||||
graphql(
|
|
||||||
`
|
|
||||||
{
|
|
||||||
allFile(filter: { ext: { in: [".md", ".mdx"] } }) {
|
|
||||||
edges {
|
|
||||||
node {
|
|
||||||
base
|
|
||||||
ext
|
|
||||||
name
|
|
||||||
relativeDirectory
|
|
||||||
absolutePath
|
|
||||||
childMdx {
|
|
||||||
code {
|
|
||||||
scope
|
|
||||||
}
|
|
||||||
frontmatter {
|
|
||||||
title
|
|
||||||
teaser
|
|
||||||
source
|
|
||||||
api_base_class
|
|
||||||
api_string_name
|
|
||||||
api_trainable
|
|
||||||
tag
|
|
||||||
new
|
|
||||||
next
|
|
||||||
search_exclude
|
|
||||||
menu
|
|
||||||
sidebar {
|
|
||||||
label
|
|
||||||
items {
|
|
||||||
text
|
|
||||||
url
|
|
||||||
}
|
|
||||||
}
|
|
||||||
section
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fields {
|
|
||||||
id
|
|
||||||
slug
|
|
||||||
fileName
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
).then((result) => {
|
|
||||||
if (result.errors) {
|
|
||||||
console.log(result.errors)
|
|
||||||
reject(result.errors)
|
|
||||||
}
|
|
||||||
|
|
||||||
const sections = Object.assign(
|
|
||||||
{},
|
|
||||||
...siteMetadata.sections.map((s) => ({ [s.id]: s }))
|
|
||||||
)
|
|
||||||
|
|
||||||
/* Regular pages */
|
|
||||||
|
|
||||||
const pages = result.data.allFile.edges
|
|
||||||
pages.forEach((page) => {
|
|
||||||
const { name } = path.parse(page.node.absolutePath)
|
|
||||||
if (!name.startsWith('_')) {
|
|
||||||
const mdx = page.node.childMdx || {}
|
|
||||||
const frontmatter = mdx.frontmatter || {}
|
|
||||||
const section = frontmatter.section || page.node.relativeDirectory
|
|
||||||
const sectionMeta = sections[section] || {}
|
|
||||||
const title = getNodeTitle(page.node)
|
|
||||||
const next = findNode(pages, frontmatter.next)
|
|
||||||
const baseClass = findNode(pages, frontmatter.api_base_class)
|
|
||||||
const apiDetails = {
|
|
||||||
stringName: frontmatter.api_string_name,
|
|
||||||
baseClass: baseClass
|
|
||||||
? {
|
|
||||||
title: getNodeTitle(baseClass.node),
|
|
||||||
slug: frontmatter.api_base_class,
|
|
||||||
}
|
|
||||||
: null,
|
|
||||||
trainable: frontmatter.api_trainable,
|
|
||||||
}
|
|
||||||
createPage({
|
|
||||||
path: replacePath(page.node.fields.slug),
|
|
||||||
component: DEFAULT_TEMPLATE,
|
|
||||||
context: {
|
|
||||||
id: page.node.id,
|
|
||||||
slug: page.node.fields.slug,
|
|
||||||
isIndex: page.node.fields.fileName === 'index',
|
|
||||||
title,
|
|
||||||
section,
|
|
||||||
sectionTitle: sectionMeta.title,
|
|
||||||
menu: frontmatter.menu || [],
|
|
||||||
teaser: frontmatter.teaser,
|
|
||||||
apiDetails,
|
|
||||||
source: frontmatter.source,
|
|
||||||
sidebar: frontmatter.sidebar,
|
|
||||||
tag: frontmatter.tag,
|
|
||||||
version: frontmatter.new,
|
|
||||||
theme: sectionMeta.theme,
|
|
||||||
searchExclude: frontmatter.search_exclude,
|
|
||||||
relativePath: page.node.relativePath,
|
|
||||||
next: next
|
|
||||||
? {
|
|
||||||
title: getNodeTitle(next.node),
|
|
||||||
slug: next.node.fields.slug,
|
|
||||||
}
|
|
||||||
: null,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
/* Universe */
|
|
||||||
|
|
||||||
const universeContext = {
|
|
||||||
section: 'universe',
|
|
||||||
sectionTitle: sections.universe.title,
|
|
||||||
theme: sections.universe.theme,
|
|
||||||
}
|
|
||||||
|
|
||||||
createPage({
|
|
||||||
path: '/universe',
|
|
||||||
component: DEFAULT_TEMPLATE,
|
|
||||||
context: {
|
|
||||||
slug: '/universe',
|
|
||||||
isIndex: true,
|
|
||||||
title: 'Overview',
|
|
||||||
...universeContext,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
const universeResources = universe.resources
|
|
||||||
universeResources.forEach((page) => {
|
|
||||||
const slug = `/universe/project/${page.id}`
|
|
||||||
|
|
||||||
createPage({
|
|
||||||
path: slug,
|
|
||||||
component: DEFAULT_TEMPLATE,
|
|
||||||
context: {
|
|
||||||
id: page.id,
|
|
||||||
slug: slug,
|
|
||||||
isIndex: false,
|
|
||||||
title: page.title || page.id,
|
|
||||||
teaser: page.slogan,
|
|
||||||
data: { ...page, isProject: true },
|
|
||||||
...universeContext,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
const universeCategories = universe.categories
|
|
||||||
const categories = [].concat.apply(
|
|
||||||
[],
|
|
||||||
universeCategories.map((cat) => cat.items)
|
|
||||||
)
|
|
||||||
categories.forEach((page) => {
|
|
||||||
const slug = `/universe/category/${page.id}`
|
|
||||||
|
|
||||||
createPage({
|
|
||||||
path: slug,
|
|
||||||
component: DEFAULT_TEMPLATE,
|
|
||||||
context: {
|
|
||||||
id: page.id,
|
|
||||||
slug: slug,
|
|
||||||
isIndex: false,
|
|
||||||
title: page.title,
|
|
||||||
teaser: page.description,
|
|
||||||
data: { ...page, isCategory: true },
|
|
||||||
...universeContext,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
/* Models */
|
|
||||||
|
|
||||||
const langs = models.languages
|
|
||||||
const modelLangs = langs.filter(({ models }) => models && models.length)
|
|
||||||
modelLangs.forEach(({ code, name, models, example, has_examples }, i) => {
|
|
||||||
const slug = `/models/${code}`
|
|
||||||
const next = i < modelLangs.length - 1 ? modelLangs[i + 1] : null
|
|
||||||
createPage({
|
|
||||||
path: slug,
|
|
||||||
component: DEFAULT_TEMPLATE,
|
|
||||||
context: {
|
|
||||||
id: code,
|
|
||||||
slug: slug,
|
|
||||||
isIndex: false,
|
|
||||||
title: name,
|
|
||||||
section: 'models',
|
|
||||||
sectionTitle: sections.models.title,
|
|
||||||
theme: sections.models.theme,
|
|
||||||
next: next ? { title: next.name, slug: `/models/${next.code}` } : null,
|
|
||||||
meta: { models, example, hasExamples: has_examples },
|
|
||||||
},
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.onCreateNode = ({ node, actions, getNode }) => {
|
|
||||||
const { createNodeField } = actions
|
|
||||||
if (PAGE_EXTENSIONS.includes(node.ext)) {
|
|
||||||
const slug = createFilePath({ node, getNode, basePath: BASE_PATH, trailingSlash: false })
|
|
||||||
const { name } = path.parse(node.absolutePath)
|
|
||||||
createNodeField({ name: 'fileName', node, value: name })
|
|
||||||
createNodeField({ name: 'slug', node, value: slug })
|
|
||||||
createNodeField({ name: 'id', node, value: node.id })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.onCreateWebpackConfig = ({ stage, loaders, actions }) => {
|
|
||||||
// Support relative paths in MDX components
|
|
||||||
actions.setWebpackConfig({
|
|
||||||
resolve: {
|
|
||||||
modules: [
|
|
||||||
path.resolve(__dirname),
|
|
||||||
path.resolve(__dirname, 'docs'),
|
|
||||||
path.resolve(__dirname, 'src'),
|
|
||||||
'node_modules',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
module: {
|
|
||||||
rules: [
|
|
||||||
{
|
|
||||||
test: /\.(html|svg)$/,
|
|
||||||
use: 'raw-loader',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
})
|
|
||||||
if (stage === 'build-javascript') {
|
|
||||||
// Turn off source maps
|
|
||||||
actions.setWebpackConfig({
|
|
||||||
devtool: false,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user