Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: update all to MUI v5 #968

Merged
merged 65 commits into from
Dec 4, 2021
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
f7b873f
build(deps-dev): bump ts-graphql-plugin from 2.1.3 to 2.1.4
dependabot[bot] Sep 7, 2021
20a8178
Merge pull request #962 from OI-wiki/dependabot/npm_and_yarn/ts-graph…
Enter-tainer Sep 7, 2021
3f782b2
refractor: rename confusing `gatsby-config.esm`
diauweb Sep 21, 2021
dde537c
refactor: minimum runnable site, add mobx as state management
SkyeYoung Sep 21, 2021
deea009
feat: Header component
SkyeYoung Sep 22, 2021
69c2194
refactor: SmartLink
SkyeYoung Sep 23, 2021
4d8d2aa
style: Link => SmartLink
SkyeYoung Sep 23, 2021
3f92055
refactor: Footer
SkyeYoung Sep 23, 2021
3a8238f
feat: Main component
SkyeYoung Sep 23, 2021
a5e8a4e
refactor: NavSidebar
SkyeYoung Sep 23, 2021
57a2fab
refactor(navsidebar): extract types and functions, fix scrollbar style
SkyeYoung Sep 25, 2021
69db5d7
refactor(header): change appear logic, add onTop status
SkyeYoung Sep 25, 2021
c3e62d3
refactor: TocSidebar component
SkyeYoung Sep 25, 2021
59ba62f
refactor(doc): add img's stand-in and Tocsidebar, amend style
SkyeYoung Sep 25, 2021
732b403
refactor(main): transition and style
SkyeYoung Sep 25, 2021
972322b
refactor: add stand-in of Pre, Code, Img, amend hightlight-themes => …
SkyeYoung Sep 26, 2021
8bea7fd
feat(stand-in): Table
SkyeYoung Sep 26, 2021
62bf9c3
feat(stand-in): Blockquote
SkyeYoung Sep 26, 2021
ff9c3b0
refactor(doc): extract components object to stand-in/index.tsx
SkyeYoung Sep 26, 2021
ffb047a
feat(stand-in): List
SkyeYoung Sep 26, 2021
99c8657
feat(stand-in): CodeBlock
SkyeYoung Sep 26, 2021
35cdfeb
refactor(main): style of Content
SkyeYoung Sep 26, 2021
a2aabe2
fix(stand-in): inline code style
SkyeYoung Sep 26, 2021
c6e39e8
refactor(globalstyle): extract pseudoCodeStyle
SkyeYoung Sep 26, 2021
5d21d69
refactor(stand-in): link, refactor components obj => getComponents func
SkyeYoung Sep 26, 2021
b803a57
feat(stand-in): Details, Summary
SkyeYoung Sep 26, 2021
6eec6a3
fix(stand-in/link): tooltip
SkyeYoung Sep 27, 2021
b685f5b
refactor(pseudocodestyle): simplify css selectors
SkyeYoung Sep 27, 2021
2c92df1
feat(headerstore): appearLock
SkyeYoung Sep 27, 2021
06179be
refactor: EditWarn components
SkyeYoung Sep 27, 2021
0deb1ff
refactor: Title component
SkyeYoung Sep 27, 2021
993184a
refactor: Time component
SkyeYoung Sep 27, 2021
dc16f6d
refactor: Tags component
SkyeYoung Sep 27, 2021
b074a9a
refactor: Meta component
SkyeYoung Sep 27, 2021
3cb8f5f
feat(headerstore): current height
SkyeYoung Sep 28, 2021
72601b0
refactor: folder name stand-in => customed, gatsby-func => gatsby
SkyeYoung Sep 28, 2021
6013814
refactor(smartlink): simplify getElementViewPosition
SkyeYoung Sep 28, 2021
e783caf
fix(tocsidebar): change top to headerStore.currentHeight
SkyeYoung Sep 28, 2021
d9eee66
Merge branch 'master' into mui-v5
SkyeYoung Sep 28, 2021
e4eb166
refactor(theme/index): rename commonTypo => commonTypStyle
SkyeYoung Sep 28, 2021
ed51190
refactor: Indicator component
SkyeYoung Sep 29, 2021
e42990c
refactor(title): prop title => children
SkyeYoung Oct 4, 2021
04d725c
refactor: extract Layout component
SkyeYoung Oct 4, 2021
83c33f7
feat(main): prop withToc, withNav
SkyeYoung Oct 4, 2021
b0cfdd2
refactor: template Tag
SkyeYoung Oct 4, 2021
d3f7dc3
refactor(tag): interface TagsProps => TagProps
SkyeYoung Oct 5, 2021
d859eed
refactor: Changelog Template
SkyeYoung Oct 5, 2021
d6578e9
fix(header): reset Header appear status when route changed
SkyeYoung Oct 5, 2021
8a683e8
refactor: 404 page
SkyeYoung Oct 6, 2021
4efd62b
refactor: Pages page
SkyeYoung Oct 6, 2021
d88439e
refactor: page Play and related components
SkyeYoung Oct 7, 2021
eddceba
fix(play): style
SkyeYoung Oct 7, 2021
06c6329
feat: add github codespaces config
renbaoshuo Oct 10, 2021
6a24743
fix: gitpod config & button
renbaoshuo Oct 10, 2021
bf065d1
Merge pull request #981 from renbaoshuo/github-codespaces
Enter-tainer Oct 10, 2021
8cac002
Merge pull request #982 from renbaoshuo/fix-gitpod
Enter-tainer Oct 10, 2021
1331d6d
fix(smartlink): wrong href
SkyeYoung Oct 12, 2021
7dd574c
Merge pull request #983 from SkyeYoung/smartlink-fix
Enter-tainer Oct 13, 2021
f255fba
merge master into mui-v5
SkyeYoung Oct 18, 2021
14083a4
refactor: Search Component
SkyeYoung Oct 19, 2021
607eee2
fix(pages): missing check of tags
SkyeYoung Oct 19, 2021
4a2341b
perf(search): reduce the bundle size
SkyeYoung Oct 19, 2021
2ef16a4
refactor: CommentCard component
SkyeYoung Oct 22, 2021
d873c01
refactor: Comment Component
SkyeYoung Oct 24, 2021
30bb570
fix(Comment): style, store
SkyeYoung Oct 26, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions gatsby-theme-oi-wiki/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ module.exports = {
'@typescript-eslint/ban-ts-comment': 'warn',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
'warn',
'warn', { 'argsIgnorePattern': '^_' },
],
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
Expand All @@ -73,7 +73,9 @@ module.exports = {
{
files: [
'.eslintrc.js',
'gatsby-*.js',
'gatsby-node.js',
'gatsby-config.js',
'gatsby-config.esm.js',
'plugins/**/*.js',
],
env: {
Expand Down
7 changes: 5 additions & 2 deletions gatsby-theme-oi-wiki/gatsby-browser.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require('./static/extra.css')
import('./static/extra.css')
import WrapRootElement from './src/gatsby-func/WrapRootElement'

exports.onRouteUpdate = () => {
const onRouteUpdate = () => {
if (process.env.GATSBY_IS_DEV) {
requestIdleCallback(() => MathJax.typeset())
}
Expand All @@ -10,3 +11,5 @@ exports.onRouteUpdate = () => {
console.error(e)
}
}

export { onRouteUpdate, WrapRootElement as wrapRootElement }
272 changes: 168 additions & 104 deletions gatsby-theme-oi-wiki/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const _ = require('lodash')
const git = require('simple-git')
const { createFilePath } = require('gatsby-source-filesystem')
const { SitemapManager } = require('sitemap-manager')
const path = require('path')

exports.onCreateWebpackConfig = ({ actions }) => {
actions.setWebpackConfig({
Expand All @@ -16,10 +17,6 @@ exports.onCreateWebpackConfig = ({ actions }) => {
})
}

const gitQuery = async function (prop) {
const res = await git().log(['-15', prop]).catch(err => console.log(err))
return res
}
exports.onCreateNode = ({ node, actions, getNode }) => {
const { createNodeField } = actions
// you only want to operate on `Mdx` nodes. If you had content from a
Expand All @@ -43,12 +40,10 @@ exports.onCreateNode = ({ node, actions, getNode }) => {
}
}

exports.createPages = async ({ actions, graphql, reporter }) => {
const { createPage } = actions
const gitQuery = async (prop) => await git().log(['-15', prop])

const docTemplate = require.resolve('./src/templates/doc.js')
const tagTemplate = require.resolve('./src/templates/tags.js')
const logTemplate = require.resolve('./src/templates/changelog.js')
exports.createPages = async (args) => {
const { graphql, actions, reporter } = args

const result = await graphql(`
{
Expand Down Expand Up @@ -78,122 +73,191 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
}
`)

// handle errors
// return when the result is wrong
if (result.errors) {
reporter.panicOnBuild('Error while running GraphQL query.')
return
}

const posts = result.data.postsRemark.edges
// console.log(posts)
// Create post detail pages
const { createPage } = actions
const data = result.data
const docTemplate = require.resolve('./src/templates/Doc.tsx')

const posts = data.postsRemark.edges

for (const index in posts) {
const { node } = posts[index]

const previous = index === posts.length - 1 ? null : posts[index + 1]
const prev = index === posts.length - 1 ? null : posts[index + 1]
const next = index === 0 ? null : posts[index - 1]
// /workspace/gatsby-oi-wiki/docs/empty.md -> docs/empty.md
const { fileAbsolutePath: path } = node
const relativePath = path.slice(path.indexOf('/docs') + 1)
const relativePath = path?.slice(path.indexOf('/docs') + 1) || ''

const log = await gitQuery(relativePath).catch(err => console.error(err))

const log = await gitQuery(relativePath)
createPage({
path: node.fields.slug,
component: docTemplate,
context: {
id: node.id,
lastModified: log.latest?.date || new Date().toString(),
previous,
prev,
next,
},
})
createPage({
path: node.fields.slug + 'changelog/',
component: logTemplate,
context: {
title: node.frontmatter.title,
changelog: log,
relativePath,
},
})
}

// Extract tag data from query
const tags = result.data.tagsGroup.group

// Make tag pages
tags.forEach((tag) => {
createPage({
path: `/tags/${_.kebabCase(tag.fieldValue)}/`,
component: tagTemplate,
context: {
tag: tag.fieldValue,
},
})
})

if (result.errors) {
reporter.panic(result.errors)
}
}

exports.onPostBuild = async ({ graphql, reporter }) => {
let queryResult = await graphql(`{
site {
siteMetadata {
siteUrl
}
}
postsQuery:allMarkdownRemark {
edges {
node {
id
fields{
slug
}
fileAbsolutePath
}
}
}
tagsQuery:allMarkdownRemark(limit: 2000) {
group(field: frontmatter___tags) {
fieldValue
}
}
}`)
if (queryResult.errors) {
reporter.panicOnBuild('Error while running GraphQL query to create sitemaps.', queryResult.errors)
}
queryResult = queryResult.data
const siteUrl = queryResult.site.siteMetadata.siteUrl

const MySitemap = new SitemapManager({ siteURL: siteUrl })
for (const index in queryResult.postsQuery.edges) {
const { node } = queryResult.postsQuery.edges[index]
const { fileAbsolutePath: path } = node
const relativePath = path.slice(path.indexOf('/docs') + 1)
const lastmod = (await gitQuery(relativePath)).latest?.date || new Date().toString()
// exports.createPages = async ({ actions, graphql, reporter }) => {
// const { createPage } = actions
//
// const docTemplate = require.resolve('./src/templates/doc.js')
// const tagTemplate = require.resolve('./src/templates/tags.js')
// const logTemplate = require.resolve('./src/templates/changelog.js')
//
// const result = await graphql(`
// {
// postsRemark: allMarkdownRemark(
// sort: { order: DESC, fields: [frontmatter___title] }
// limit: 2000
// ) {
// edges {
// node {
// fields {
// slug
// }
// id
// frontmatter {
// tags
// title
// }
// fileAbsolutePath
// }
// }
// }
// tagsGroup: allMarkdownRemark(limit: 2000) {
// group(field: frontmatter___tags) {
// fieldValue
// }
// }
// }
// `)
//
// // handle errors
// if (result.errors) {
// reporter.panicOnBuild('Error while running GraphQL query.')
// return
// }
//
// const posts = result.data.postsRemark.edges
// // console.log(posts)
// // Create post detail pages
//
// for (const index in posts) {
// const { node } = posts[index]
//
// const previous = index === posts.length - 1 ? null : posts[index + 1]
// const next = index === 0 ? null : posts[index - 1]
// // /workspace/gatsby-oi-wiki/docs/empty.md -> docs/empty.md
// const { fileAbsolutePath: path } = node
// const relativePath = path.slice(path.indexOf('/docs') + 1)
//
// const log = await gitQuery(relativePath)
// createPage({
// path: node.fields.slug,
// component: docTemplate,
// context: {
// id: node.id,
// lastModified: log.latest?.date || new Date().toString(),
// previous,
// next,
// },
// })
// createPage({
// path: node.fields.slug + 'changelog/',
// component: logTemplate,
// context: {
// title: node.frontmatter.title,
// changelog: log,
// relativePath,
// },
// })
// }
//
// // Extract tag data from query
// const tags = result.data.tagsGroup.group
//
// // Make tag pages
// tags.forEach((tag) => {
// createPage({
// path: `/tags/${_.kebabCase(tag.fieldValue)}/`,
// component: tagTemplate,
// context: {
// tag: tag.fieldValue,
// },
// })
// })
//
// if (result.errors) {
// reporter.panic(result.errors)
// }
// }

MySitemap.addUrl('articles', [{
loc: new URL(node.fields.slug, siteUrl).toString(),
lastmod,
}])
MySitemap.addUrl('logs', [{
loc: new URL(node.fields.slug + 'changelog/', siteUrl).toString(),
lastmod,
}])
}
queryResult.tagsQuery.group.forEach(({ fieldValue }) => {
MySitemap.addUrl('tags', [{
loc: new URL(`/tags/${_.kebabCase(fieldValue)}/`, siteUrl).toString(),
}])
})
MySitemap.addUrl('pages', [
{ loc: new URL('/pages/', siteUrl).toString() },
{ loc: new URL('/settings/', siteUrl).toString() },
])
await MySitemap.finish().catch((e) => {
reporter.error(e)
})
}
// exports.onPostBuild = async ({ graphql, reporter }) => {
// let queryResult = await graphql(`{
// site {
// siteMetadata {
// siteUrl
// }
// }
// postsQuery:allMarkdownRemark {
// edges {
// node {
// id
// fields{
// slug
// }
// fileAbsolutePath
// }
// }
// }
// tagsQuery:allMarkdownRemark(limit: 2000) {
// group(field: frontmatter___tags) {
// fieldValue
// }
// }
// }`)
// if (queryResult.errors) {
// reporter.panicOnBuild('Error while running GraphQL query to create sitemaps.', queryResult.errors)
// }
// queryResult = queryResult.data
// const siteUrl = queryResult.site.siteMetadata.siteUrl
//
// const MySitemap = new SitemapManager({ siteURL: siteUrl })
// for (const index in queryResult.postsQuery.edges) {
// const { node } = queryResult.postsQuery.edges[index]
// const { fileAbsolutePath: path } = node
// const relativePath = path.slice(path.indexOf('/docs') + 1)
// const lastmod = (await gitQuery(relativePath)).latest?.date || new Date().toString()
//
// MySitemap.addUrl('articles', [{
// loc: new URL(node.fields.slug, siteUrl).toString(),
// lastmod,
// }])
// MySitemap.addUrl('logs', [{
// loc: new URL(node.fields.slug + 'changelog/', siteUrl).toString(),
// lastmod,
// }])
// }
// queryResult.tagsQuery.group.forEach(({ fieldValue }) => {
// MySitemap.addUrl('tags', [{
// loc: new URL(`/tags/${_.kebabCase(fieldValue)}/`, siteUrl).toString(),
// }])
// })
// MySitemap.addUrl('pages', [
// { loc: new URL('/pages/', siteUrl).toString() },
// { loc: new URL('/settings/', siteUrl).toString() },
// ])
// await MySitemap.finish().catch((e) => {
// reporter.error(e)
// })
// }
Loading