Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
29 changes: 19 additions & 10 deletions website/gatsby-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,40 @@
*
* See: https://www.gatsbyjs.com/docs/browser-apis/
*/
require("./src/styles/global.css")
const React = require("react")
const { default: AppHeader } = require("./src/components/AppHeader")
const { default: AppHeaderWhite } = require("./src/components/AppHeaderWhite")

const Layout = require("./src/components/documentsMenu/menu").default
const JsonLayout = require("./src/components/jsonMenu/menu").default
const SpaceLayout = require("./src/components/space/spaceLayout").default
const { default: AppFooter } = require("./src/components/AppFooter")
// You can delete this file if you're not using it
import("./src/assets/sass/index.scss")
exports.wrapPageElement = ({ element, props }) => {
// props provide same data to Layout as Page element will get
// including location, data, etc - you don't need to pass it
console.log(element, "@@@!")

return (
<>
{element.key.includes("documents") ? (
<>
<AppHeaderWhite></AppHeaderWhite>
<Layout {...props}>{element}</Layout>
<AppFooter></AppFooter>
</>
) : (
<SpaceLayout {...props}>{element}</SpaceLayout>
)}
<div className=" ">
{element.key.includes("documents") ? (
<>
<div style={{ minHeight: "100vh", backgroundColor: "#fff" }}>
<AppHeaderWhite></AppHeaderWhite>
<Layout {...props}>{element}</Layout>
</div>
</>
) : element.key.includes("examples") ? (
<div style={{ minHeight: "100vh", backgroundColor: "#fff" }}>
<AppHeaderWhite></AppHeaderWhite>
<JsonLayout {...props}>{element}</JsonLayout>
</div>
) : (
<SpaceLayout {...props}>{element}</SpaceLayout>
)}
</div>
</>
)
}
32 changes: 31 additions & 1 deletion website/gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = {
siteUrl: `https://gatsbystarterdefaultsource.gatsbyjs.io/`,
},
plugins: [
`gatsby-plugin-postcss`,
`gatsby-plugin-react-helmet`,
`gatsby-plugin-image`,
`gatsby-plugin-sass`,
Expand All @@ -19,16 +20,45 @@ module.exports = {
path: path.resolve(__dirname, "../docs"),
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
name: `examples`,
path: path.resolve(__dirname, "../examples"),
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
name: `images`,
path: `${__dirname}/src/images`,
},
},

`gatsby-transformer-sharp`,
`gatsby-plugin-sharp`,
`gatsby-transformer-remark`,
`json-content`,
// `gatsby-transformer-plaintext`,
{
resolve: `gatsby-transformer-remark`,
options: {
plugins: [
{
resolve: `gatsby-remark-autolink-headers`,
options: {
offsetY: `100`,
icon: `<svg aria-hidden="true" height="20" version="1.1" viewBox="0 0 16 16" width="20"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>`,
className: `custom-class`,
maintainCase: true,
removeAccents: true,
isIconAfterHeader: true,
elements: [`h1`, `h2`],
},
},
],
},
},

{
resolve: `gatsby-plugin-manifest`,
options: {
Expand Down
13 changes: 12 additions & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,34 @@
"@icon-park/react": "^1.3.5",
"@mantine/core": "^4.2.5",
"@mantine/hooks": "^4.2.5",
"antd": "^4.21.0",
"aos": "^2.3.4",
"autoprefixer": "^10.4.7",
"gatsby": "^4.14.0",
"gatsby-plugin-gatsby-cloud": "^4.14.0",
"gatsby-plugin-image": "^2.14.1",
"gatsby-plugin-manifest": "^4.14.0",
"gatsby-plugin-mantine": "^4.0.0",
"gatsby-plugin-offline": "^5.14.0",
"gatsby-plugin-postcss": "^5.16.0",
"gatsby-plugin-react-helmet": "^5.14.0",
"gatsby-plugin-sass": "^5.14.0",
"gatsby-plugin-sharp": "^4.14.1",
"gatsby-remark-autolink-headers": "^5.16.0",
"gatsby-remark-table-of-contents": "^2.0.0",
"gatsby-source-filesystem": "^4.14.0",
"gatsby-transformer-json": "^4.15.0",
"gatsby-transformer-plaintext": "^2.0.0",
"gatsby-transformer-remark": "^5.14.0",
"gatsby-transformer-sharp": "^4.14.0",
"node-sass": "^6.0.1",
"postcss": "^8.4.14",
"prop-types": "^15.8.1",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-helmet": "^6.1.0"
"react-helmet": "^6.1.0",
"react-json-view": "^1.21.3",
"tailwindcss": "^3.1.0"
},
"devDependencies": {
"prettier": "^2.6.2"
Expand Down
48 changes: 48 additions & 0 deletions website/plugins/json-content/gatsby-node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const isNodeSupported = node => {
return isTextFile(node) || isFileWithoutExtension(node)
}

const isTextFile = node => {
return (
node.internal.type === "File" &&
node.internal.mediaType === "application/json"
)
}

const isFileWithoutExtension = node => {
return (
node.internal.type === "File" &&
node.internal.mediaType === "application/octet-stream" &&
!node.internal.extension
)
}

exports.onCreateNode = async ({
node,
actions,
loadNodeContent,
createNodeId,
createContentDigest,
}) => {
if (!isNodeSupported(node)) {
return
}
const { createNode, createParentChildLink } = actions
const content = await loadNodeContent(node)
const id = createNodeId(`${node.id} >>> jsonContent`)
const plainTextNode = {
id,
children: [],
content,
parent: node.id,
internal: {
contentDigest: createContentDigest(content),
type: "jsonContent",
},
}
createNode(plainTextNode)
createParentChildLink({
parent: node,
child: plainTextNode,
})
}
40 changes: 40 additions & 0 deletions website/plugins/json-content/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "json-content",
"version": "2.0.0",
"description": "",
"main": "index.js",
"author": "huang yi chao",
"license": "MIT",
"private": false,
"keywords": [
"gatsby",
"gatsby-plugin",
"plaintext",
"text"
],
"peerDependencies": {
"gatsby": "^3.0.0"
},
"dependencies": {
"@babel/runtime": "^7.13.10"
},
"devDependencies": {
"@babel/cli": "^7.13.14",
"@babel/core": "^7.13.15",
"babel-preset-gatsby-package": "^1.3.0",
"bluebird": "^3.7.2",
"cross-env": "^7.0.3",
"jest": "^26.6.3",
"prettier": "^2.2.1"
},
"scripts": {
"build": "babel src --out-dir . --ignore **/__tests__",
"prepare": "cross-env NODE_ENV=production npm run build",
"watch": "babel -w src --out-dir . --ignore **/__tests__",
"test": "jest"
},
"engines": {
"node": ">=10.13.0"
}
}

Loading