Files
jcutmirror/gatsby-config.js
2024-05-15 18:46:34 +08:00

127 lines
3.7 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Configure your Gatsby site with this file.
*
* See: https://www.gatsbyjs.com/docs/gatsby-config/
*/
const { createProxyMiddleware } = require('http-proxy-middleware');
const config = require('./config');
module.exports = {
siteMetadata: {
title: 'JCUT Mirror',
siteUrl: config.siteUrl,
description: 'JCUT Mirror is a non-profit program aimed at popularizing open source software and facilitating efficient access to various resources of open source projects by all users.',
author: 'JCUT YF',
},
assetPrefix: config.assetPrefix,
pathPrefix: config.pathPrefix,
plugins: [
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'mirrors',
path: `${__dirname}/docs`,
}
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'locales',
path: `${__dirname}/locales`,
}
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'news',
path: `${__dirname}/news`,
}
},
{
resolve: "gatsby-plugin-mdx",
options: {
mdxOptions: {
remarkPlugins: [
// Add GitHub Flavored Markdown (GFM) support
// Warning: Most of the remark ecosystem is ESM which means that packages
// like remark-gfm dont work out of the box with Gatsby v5. To make remark-gfm
// compatible with the current Gatsby version, we have to use an old version of
// remark-gfm. Please take care in future updates.
require(`remark-gfm`),
],
},
}
},
{
resolve: "gatsby-plugin-react-svg",
options: {
rule: {
include: /icons/,
omitKeys: [
'inkscapePageshadow', 'inkscapePageopacity', 'inkscapePagecheckerboard',
'inkscapeZoom', 'inkscapeCx', 'inkscapeCy', 'inkscapeWindowWidth', 'inkscapeWindowHeight',
'inkscapeWindowX', 'inkscapeWindowY', 'inkscapeWindowMaximized', 'inkscapeCurrentLayer',
'sodipodiNodetypes', 'sodipodiDocname', 'inkscapeVersion', 'xmlnsInkscape', 'xmlnsSodipodi',
'xmlnsSvg',
]
}
}
},
{
resolve: `gatsby-plugin-react-i18next`,
options: {
localeJsonSourceName: 'locales', // name given to `gatsby-source-filesystem` plugin.
languages: config.locales,
defaultLanguage: config.defaultLanguage,
redirect: false,
// if you are using Helmet, you must include siteUrl, and make sure you add http:https
siteUrl: config.siteUrl,
// you can pass any i18next options
// pass following options to allow message content as a key
i18nextOptions: {
interpolation: {
escapeValue: false // not needed for react as it escapes by default
},
keySeparator: false,
nsSeparator: false
},
pages: Object.values(config.documentSources).map(
s => ({
matchPath: s.path,
getLanguageFromPath: s.getLanguageFromPath,
})
)
}
},
{
resolve: 'gatsby-plugin-manifest',
options: {
icon: 'resource/icons/favicon.svg',
},
},
`gatsby-plugin-sass`,
{
resolve: "gatsby-plugin-sitemap",
options: {
serialize: ({ path }) => {
return {
url: path,
lastmod: new Date(0).toISOString(),
};
},
},
},
],
developMiddleware: app => {
app.use(
'/api',
createProxyMiddleware({
target: 'http://mirrors.jcut.edu.cn',
onProxyReq: (proxyRes, req, res) => {
proxyRes.setHeader('host', 'mirrors.jcut.edu.cn');
},
}),
);
}
}