FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Upgrade mdx · mcjava-wiki/mcjava-wiki@cb83d7b · GitHub

Repository navigation

Commit cb83d7b

Browse files
committed
Upgrade mdx
Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com>
1 parent 8627c2c commit cb83d7b

24 files changed

Lines changed: 1444 additions & 1594 deletions

‎gatsby-config.js‎

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
const path = require('path')
22

3+
const visit = require('unist-util-visit')
4+
5+
/** @type {import('unified').Plugin<Array<void>, import('hast').Root>} */
6+
function rehypeMetaAsAttributes() {
7+
return (tree) => {
8+
visit(tree, 'element', (node) => {
9+
if (node.tagName === 'code' && node.data && node.data.meta) {
10+
node.properties.meta = node.data.meta
11+
}
12+
})
13+
}
14+
}
15+
316
module.exports = {
417
pathPrefix: `${process.env.PATH_PREFIX}`,
518
siteMetadata: {
@@ -31,8 +44,9 @@ module.exports = {
3144
siteUrl: "https://wiki.mcjava.dev",
3245
author: 'Kas-tle',
3346
docSearch: {
34-
apiKey: 'da0ca3a42123b75779221abdd6edf8b6',
47+
apiKey: 'b682d90da6cabb2ac9a4d1d236b24d92',
3548
indexName: 'mcjava',
49+
appId: '3QIDHF9CHG',
3650
},
3751
},
3852
plugins: [
@@ -55,29 +69,26 @@ module.exports = {
5569
resolve: 'gatsby-plugin-mdx',
5670
options: {
5771
extensions: [`.mdx`, `.md`],
72+
mdxOptions: {
73+
remarkPlugins: [
74+
require(`remark-gfm`),
75+
],
76+
rehypePlugins: [rehypeMetaAsAttributes],
77+
},
5878
gatsbyRemarkPlugins: [
59-
{
60-
resolve: require.resolve(
61-
'./src/plugins/gatsby-remark-autolink-headers',
62-
),
63-
},
6479
{
6580
resolve: `gatsby-remark-images`,
6681
options: {
6782
maxWidth: 1200,
6883
},
6984
},
85+
{ resolve: 'gatsby-remark-autolink-headers' },
7086
],
7187
},
7288
},
7389
'gatsby-transformer-sharp',
7490
'gatsby-plugin-sharp',
7591
'gatsby-plugin-react-helmet',
76-
{
77-
resolve: require.resolve(
78-
'./src/plugins/gatsby-remark-autolink-headers',
79-
),
80-
},
8192

8293
// Source
8394
{
@@ -94,10 +105,18 @@ module.exports = {
94105
name: 'default-image',
95106
},
96107
},
108+
{
109+
resolve: 'gatsby-source-filesystem',
110+
options: {
111+
path: `./pages/docs`,
112+
name: 'doc',
113+
},
114+
},
97115
{
98116
resolve: 'gatsby-source-filesystem',
99117
options: {
100118
path: `./pages`,
119+
ignore: ['**/docs/**'],
101120
name: 'page',
102121
},
103122
},

‎gatsby-node.js‎

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ function createSchemaCustomization({ actions }) {
1414
type AlgoliaDocSearchMetadata {
1515
apiKey: String!
1616
indexName: String!
17+
appId: String
1718
}
1819
1920
type SiteSiteMetadata {
@@ -29,6 +30,7 @@ function createSchemaCustomization({ actions }) {
2930
3031
type MdxFrontmatter {
3132
title: String!
33+
description: String
3234
slug: String
3335
section: String
3436
order: Int
@@ -55,7 +57,7 @@ async function onPreBootstrap(options) {
5557
function onCreateMdxNode({ node, getNode, actions }, options) {
5658
const { createNodeField } = actions
5759
const slug = node.frontmatter.slug || createFilePath({ node, getNode })
58-
const pageType = /\/pages\/docs\//.test(node.fileAbsolutePath)
60+
const pageType = /\/pages\/docs\//.test(node.internal.contentFilePath)
5961
? 'doc'
6062
: 'page'
6163

@@ -131,7 +133,10 @@ function onCreateMdxNode({ node, getNode, actions }, options) {
131133
} = options
132134
const repositoryURL = githubRepositoryURL
133135
if (!baseDirectory || !repositoryURL) return ''
134-
const relativePath = node.fileAbsolutePath.replace(baseDirectory, '')
136+
const relativePath = node.internal.contentFilePath.replace(
137+
baseDirectory,
138+
'',
139+
)
135140
return `${repositoryURL}/blob/${githubDefaultBranch}${relativePath}`
136141
}
137142

@@ -143,7 +148,7 @@ function onCreateMdxNode({ node, getNode, actions }, options) {
143148
}
144149

145150
function onCreateNode(...args) {
146-
if (args[0].node.internal.type === `Mdx`) {
151+
if (args[0].node.internal.type === 'Mdx') {
147152
onCreateMdxNode(...args)
148153
}
149154
}
@@ -167,6 +172,9 @@ async function createPages({ graphql, actions, reporter }) {
167172
sourceInstanceName
168173
}
169174
}
175+
internal {
176+
contentFilePath
177+
}
170178
}
171179
}
172180
}
@@ -175,6 +183,7 @@ async function createPages({ graphql, actions, reporter }) {
175183

176184
if (errors) {
177185
reporter.panicOnBuild(`Error while running GraphQL query.`)
186+
console.log(errors)
178187
return
179188
}
180189

@@ -197,16 +206,19 @@ async function createPages({ graphql, actions, reporter }) {
197206
toPath: node.fields.redirect,
198207
redirectInBrowser: true,
199208
})
209+
return
200210
}
201211

202212
createPage({
203213
path: node.fields.slug,
204214
component: path.resolve(
205215
__dirname,
206-
`./src/templates/${node.fields.pageType}.js`,
216+
`./src/templates/${node.fields.pageType}.js?__contentFilePath=${node.internal.contentFilePath}`,
207217
),
208218
context: {
209219
id: node.id,
220+
frontmatter: node.frontmatter,
221+
contentFilePath: node.internal.contentFilePath,
210222
},
211223
})
212224
})
@@ -233,15 +245,30 @@ const pluginOptionsSchema = (/** @type {{ Joi: import('joi') }} */ { Joi }) => {
233245
docSearch: Joi.object({
234246
apiKey: Joi.string().required(),
235247
indexName: Joi.string().required(),
248+
appId: Joi.string(),
236249
}),
237250
sitemap: Joi.object(),
238251
})
239252
}
240253

254+
const onCreateWebpackConfig = ({ stage, rules, loaders, plugins, actions }) => {
255+
actions.setWebpackConfig({
256+
module: {
257+
rules: [
258+
{
259+
test: /\.mdx$/,
260+
use: '@mdx-js/loader',
261+
},
262+
],
263+
},
264+
})
265+
}
266+
241267
module.exports = {
242268
createSchemaCustomization,
243269
onPreBootstrap,
244270
onCreateNode,
245271
createPages,
246272
pluginOptionsSchema,
273+
onCreateWebpackConfig,
247274
}

‎package.json‎

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,42 +10,44 @@
1010
"dependencies": {
1111
"@docsearch/css": "^3.3.2",
1212
"@docsearch/react": "^3.3.2",
13-
"@mdx-js/mdx": "^1.6.22",
14-
"@mdx-js/react": "^1.6.22",
15-
"@xstyled/styled-components": "^2.5.0",
16-
"babel-plugin-styled-components": "^1.13.3",
17-
"fs-extra": "^9.1.0",
13+
"@mdx-js/loader": "^2.1.3",
14+
"@mdx-js/react": "^2.1.3",
15+
"@xstyled/styled-components": "^3.6.0",
16+
"ariakit": "^2.0.0-next.41",
17+
"babel-plugin-styled-components": "2.0.2",
18+
"babel-preset-gatsby": "^2.19.0",
19+
"fs-extra": "^10.1.0",
1820
"gatsby-plugin-catch-links": "^4.25.0",
1921
"gatsby-plugin-compile-es6-packages": "^2.1.1",
2022
"gatsby-plugin-image": "^2.25.0",
2123
"gatsby-plugin-manifest": "^4.25.0",
22-
"gatsby-plugin-mdx": "^3.20.0",
24+
"gatsby-plugin-mdx": "^4.3.0",
2325
"gatsby-plugin-meta-redirect": "^1.1.1",
2426
"gatsby-plugin-react-helmet": "^5.25.0",
2527
"gatsby-plugin-robots-txt": "^1.8.0",
2628
"gatsby-plugin-sharp": "^4.25.0",
2729
"gatsby-plugin-sitemap": "^5.25.0",
2830
"gatsby-plugin-styled-components": "^5.25.0",
31+
"gatsby-remark-autolink-headers": "^5.19.0",
2932
"gatsby-remark-images": "^5.12.0",
3033
"gatsby-source-filesystem": "^3.15.0",
3134
"gatsby-transformer-sharp": "^3.15.0",
3235
"github-slugger": "^1.5.0",
33-
"mdast-util-to-string": "^2.0.0",
3436
"parse-numeric-range": "^1.3.0",
3537
"polished": "^4.2.2",
3638
"prism-react-renderer": "^1.3.5",
3739
"prismjs": "^1.29.0",
3840
"react-helmet": "^6.1.0",
3941
"react-icons": "^4.7.1",
4042
"react-live": "^2.4.1",
41-
"reakit": "^1.3.11",
43+
"remark-gfm": "^1.0.0",
4244
"styled-components": "^5.3.6",
4345
"unist-util-visit": "^2.0.3"
4446
},
4547
"devDependencies": {
4648
"gatsby": "^4.25.4",
47-
"react": "^17.0.2",
48-
"react-dom": "^17.0.2",
49+
"react": "^18.2.0",
50+
"react-dom": "^18.2.0",
4951
"standard-version": "^9.5.0"
5052
}
5153
}

‎pages/docs/about/community-resources.mdx‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ Much of the information regarding more advanced use of Minecraft resource packs
2020
The official discord server for this project. The primary purpose of this Discord is to support and facilitate contributions to this wiki, though resource pack support is also availible.
2121

2222
<a href="https://discord.gg/rqsKmmh89J">
23-
<div style="display: inline-block;">
24-
<RiDiscordFill style={{ width: 32, height: 32 }} />
23+
<div style={{ display: 'inline-block' }}>
24+
<RiDiscordFill style={{ width: '32px', height: '32px' }} />
2525
</div>
26-
<div style="display: inline-block;">
27-
<RiCheckboxCircleFill style={{ width: 32, height: 32 }} />
26+
<div style={{ display: 'inline-block' }}>
27+
<RiCheckboxCircleFill style={{ width: '32px', height: '32px' }} />
2828
</div>
2929
</a>
3030

@@ -33,11 +33,11 @@ The official discord server for this project. The primary purpose of this Discor
3333
The official Discord of the 3D modeling program Blockbench. Blockbench is the most commonly used Minecraft 3D modeling program. Though the Discord is primarily for supporting Blockbench, general resource pack help is also commonly provided for all platforms Blockbench supports.
3434

3535
<a target="_blank" rel="noopener noreferrer" href="https://discord.gg/7aHWJnFXz9">
36-
<div style="display: inline-block;">
37-
<RiDiscordFill style={{ width: 32, height: 32 }} />
36+
<div style={{ display: 'inline-block' }}>
37+
<RiDiscordFill style={{ width: '32px', height: '32px' }} />
3838
</div>
39-
<div style="display: inline-block;">
40-
<RiCheckboxCircleFill style={{ width: 32, height: 32 }} />
39+
<div style={{ display: 'inline-block' }}>
40+
<RiCheckboxCircleFill style={{ width: '32px', height: '32px' }} />
4141
</div>
4242
</a>
4343

@@ -46,11 +46,11 @@ The official Discord of the 3D modeling program Blockbench. Blockbench is the mo
4646
The official Minecraft Discord server. Some help is offered for both Bedrock and Java resource packs, though it can be quite chaotic given the size of the Discord. The search functionality is sometimes useful due to the shear number of questions that have been asked.
4747

4848
<a target="_blank" rel="noopener noreferrer" href="https://discord.gg/minecraft">
49-
<div style="display: inline-block;">
50-
<RiDiscordFill style={{ width: 32, height: 32 }} />
49+
<div style={{ display: 'inline-block' }}>
50+
<RiDiscordFill style={{ width: '32px', height: '32px' }} />
5151
</div>
52-
<div style="display: inline-block;">
53-
<RiCheckboxCircleFill style={{ width: 32, height: 32 }} />
52+
<div style={{ display: 'inline-block' }}>
53+
<RiCheckboxCircleFill style={{ width: '32px', height: '32px' }} />
5454
</div>
5555
</a>
5656

@@ -59,11 +59,11 @@ The official Minecraft Discord server. Some help is offered for both Bedrock and
5959
A Discord primarily focused on voxel modeling for Minecraft: Java Edition. This Discord may be especially helpful for users of Cubik, as this is the tool of choice for voxel-style Minecraft models.
6060

6161
<a target="_blank" rel="noopener noreferrer" href="https://discord.gg/TXBcQjmQU8">
62-
<div style="display: inline-block;">
63-
<RiDiscordFill style={{ width: 32, height: 32 }} />
62+
<div style={{ display: 'inline-block' }}>
63+
<RiDiscordFill style={{ width: '32px', height: '32px' }} />
6464
</div>
65-
<div style="display: inline-block;">
66-
<RiCheckboxCircleFill style={{ width: 32, height: 32 }} />
65+
<div style={{ display: 'inline-block' }}>
66+
<RiCheckboxCircleFill style={{ width: '32px', height: '32px' }} />
6767
</div>
6868
</a>
6969

‎pages/docs/about/contributing.mdx‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -230,13 +230,6 @@ My favorite browser is:
230230
<hello@gmail.com>
231231
```
232232

233-
My favorite browser is:
234-
[Firefox Developer Edition](https://www.mozilla.org/en-US/firefox/developer/ "The best browser! (and this hover tip is optional)").
235-
236-
<https://wiki.mcjava.dev/>
237-
238-
<hello@gmail.com>
239-
240233
***
241234

242235
```md title={Inline Code}

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL