Skip to content

Commit

Permalink
fix(gatsby-theme-docz): menu field on entry source node
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed Mar 21, 2019
1 parent c8579f8 commit 05457f2
Show file tree
Hide file tree
Showing 5 changed files with 236 additions and 11 deletions.
4 changes: 2 additions & 2 deletions core/docz-core/src/lib/Entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ export class Entry {

this.id = createId(file)
this.filepath = filepath
this.link = null
this.link = ''
this.slug = this.slugify(filepath, config.separator)
this.route = this.getRoute(parsed)
this.name = name
this.menu = parsed.menu || null
this.menu = parsed.menu || ''
this.headings = headingsFromAst(ast)
this.settings = parsed
}
Expand Down
44 changes: 41 additions & 3 deletions core/gatsby-theme-docz/gatsby-config.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,56 @@
const path = require('path')

const { mdPlugins, hastPlugins } = require('./src/utils/remark-plugins')
const { getDoczConfig } = require('./src/utils/parseConfig')

const getMdPlugins = () => {
let plugins = []

try {
plugins = [
[require('remark-frontmatter'), { type: 'yaml', marker: '-' }],
require('remark-docz'),
]
} catch (err) {
plugins = []
}

return plugins
}

const getHastPlugins = () => {
let plugins = []

try {
plugins = [
[require('rehype-docz'), { root: process.cwd() }],
require('rehype-slug'),
]
} catch (err) {
plugins = []
}

return plugins
}

module.exports = opts => {
const { paths, ...config } = getDoczConfig(opts)
const mdPlugins = getMdPlugins()
const hastPlugins = getHastPlugins()

return {
plugins: [
{
resolve: 'gatsby-mdx',
options: {
extensions: ['.md', '.mdx'],
mdPlugins: config.mdPlugins.concat(mdPlugins),
hastPlugins: config.hastPlugins.concat(hastPlugins),
mdPlugins:
config && config.mdPlugins
? config.mdPlugins.concat(mdPlugins)
: mdPlugins,
hastPlugins:
config && config.hastPlugins
? config.hastPlugins.concat(hastPlugins)
: hastPlugins,
defaultLayouts: {
default: path.join(paths.app, 'components/Layout.js'),
},
Expand Down
4 changes: 2 additions & 2 deletions core/gatsby-theme-docz/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"docz-theme-default": "^1.0.0-rc.2",
"docz-utils": "^1.0.0-rc.2",
"fs-extra": "^7.0.1",
"gatsby": "^2.2.2",
"gatsby-mdx": "^0.4.3",
"gatsby": "^2.2.5",
"gatsby-mdx": "^0.4.4",
"gatsby-plugin-compile-es6-packages": "^1.0.6",
"gatsby-plugin-manifest": "^2.0.24",
"gatsby-plugin-react-helmet": "^3.0.10",
Expand Down
6 changes: 2 additions & 4 deletions core/gatsby-theme-docz/src/node/sourceNodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,16 @@ module.exports = async ({ actions, createNodeId }, opts) => {
})
}

const createEntriesNodes = async payload => {
const createEntriesNodes = async () => {
const map = await entries.get()
const values = Object.entries(map)
const contentDigest = digest(JSON.stringify(values))

values.forEach(([key, entry]) => {
if (!entry) return null
const contentDigest = digest(JSON.stringify(entry))
createNode({
...entry,
children: [],
link: entry.link || false,
menu: entry.menu || false,
internal: {
contentDigest,
type: `DoczEntries`,
Expand Down
189 changes: 189 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7935,6 +7935,33 @@ gatsby-cli@^2.4.16:
yargs "^12.0.5"
yurnalist "^1.0.2"

gatsby-cli@^2.4.17:
version "2.4.17"
resolved "https://registry.npmjs.org/gatsby-cli/-/gatsby-cli-2.4.17.tgz#38f0d2fd55de595b457a1d2a1048fb8f88a8f143"
integrity sha512-qhhFqYy7N8G4d8hSJycdib5OeU2bHgQq+TUdMFs0wZ13Kmyr34EabdnHdSdhZdS/lUAjet6L2KugTZ6DnQFERw==
dependencies:
"@babel/code-frame" "^7.0.0"
"@babel/runtime" "^7.0.0"
bluebird "^3.5.0"
common-tags "^1.4.0"
convert-hrtime "^2.0.0"
core-js "^2.5.0"
envinfo "^5.8.1"
execa "^0.8.0"
fs-exists-cached "^1.0.0"
fs-extra "^4.0.1"
hosted-git-info "^2.6.0"
lodash "^4.17.10"
meant "^1.0.1"
opentracing "^0.14.3"
pretty-error "^2.1.1"
resolve-cwd "^2.0.0"
source-map "^0.5.7"
stack-trace "^0.0.10"
update-notifier "^2.3.0"
yargs "^12.0.5"
yurnalist "^1.0.2"

gatsby-link@^2.0.16:
version "2.0.16"
resolved "https://registry.npmjs.org/gatsby-link/-/gatsby-link-2.0.16.tgz#5d140e43f3aec6dd59e01c1468d77a54092370c5"
Expand Down Expand Up @@ -7970,6 +7997,32 @@ gatsby-mdx@^0.4.3:
unist-util-remove "^1.0.1"
unist-util-visit "^1.4.0"

gatsby-mdx@^0.4.4:
version "0.4.4"
resolved "https://registry.npmjs.org/gatsby-mdx/-/gatsby-mdx-0.4.4.tgz#1297101f6018c6cf03319c6e0acd508a01478fa6"
integrity sha512-OOJqN4nQjo0dmfyWGk8R3nOdc2duGYydbxDdjCfFqRLQCxkVvRvAWNqxZG7LzAqdwqRUYW7pRWm9RNrwwttsmw==
dependencies:
"@babel/plugin-proposal-object-rest-spread" "^7.0.0"
debug "^4.0.1"
escape-string-regexp "^1.0.5"
fs-extra "^7.0.0"
gray-matter "^4.0.1"
loader-utils "^1.2.3"
lodash "^4.17.10"
mdast-util-to-string "^1.0.4"
mdast-util-toc "^2.0.1"
mime "^2.3.1"
pretty-bytes "^5.1.0"
remark "^9.0.0"
retext "^5.0.0"
slash "^2.0.0"
static-site-generator-webpack-plugin "^3.4.2"
strip-markdown "^3.0.1"
underscore.string "^3.3.4"
unist-util-map "^1.0.4"
unist-util-remove "^1.0.1"
unist-util-visit "^1.4.0"

gatsby-plugin-compile-es6-packages@^1.0.6:
version "1.0.6"
resolved "https://registry.npmjs.org/gatsby-plugin-compile-es6-packages/-/gatsby-plugin-compile-es6-packages-1.0.6.tgz#4c864d9fa697dc5b41b4b5c9e4215c49b722f086"
Expand Down Expand Up @@ -8163,6 +8216,134 @@ gatsby@^2.2.2:
webpack-stats-plugin "^0.1.5"
yaml-loader "^0.5.0"

gatsby@^2.2.5:
version "2.2.5"
resolved "https://registry.npmjs.org/gatsby/-/gatsby-2.2.5.tgz#0c4220c634ee69b9af1b35318019eb10d60e7a69"
integrity sha512-gc2d8bbcV/AF06pk1XDn7YzE/4fz2jC0PePKq6Wr/eOM9n2PSyimzBcxRon95HzGsgmXDT4pnS3KNrvlQkkbRw==
dependencies:
"@babel/code-frame" "^7.0.0"
"@babel/core" "^7.0.0"
"@babel/parser" "^7.0.0"
"@babel/polyfill" "^7.0.0"
"@babel/runtime" "^7.0.0"
"@babel/traverse" "^7.0.0"
"@gatsbyjs/relay-compiler" "2.0.0-printer-fix.2"
"@pieh/friendly-errors-webpack-plugin" "1.7.0-chalk-2"
"@reach/router" "^1.1.1"
address "1.0.3"
autoprefixer "^9.4.3"
babel-core "7.0.0-bridge.0"
babel-eslint "^9.0.0"
babel-loader "^8.0.0"
babel-plugin-add-module-exports "^0.2.1"
babel-plugin-dynamic-import-node "^1.2.0"
babel-plugin-remove-graphql-queries "^2.6.2"
babel-preset-gatsby "^0.1.9"
better-opn "0.1.4"
better-queue "^3.8.6"
bluebird "^3.5.0"
browserslist "3.2.8"
cache-manager "^2.9.0"
cache-manager-fs-hash "^0.0.6"
chalk "^2.3.2"
chokidar "^2.0.2"
common-tags "^1.4.0"
compression "^1.7.3"
convert-hrtime "^2.0.0"
copyfiles "^1.2.0"
core-js "^2.5.0"
css-loader "^1.0.0"
debug "^3.1.0"
del "^3.0.0"
detect-port "^1.2.1"
devcert-san "^0.3.3"
domready "^1.0.8"
dotenv "^4.0.0"
eslint "^5.6.0"
eslint-config-react-app "^3.0.0"
eslint-loader "^2.1.0"
eslint-plugin-flowtype "^2.46.1"
eslint-plugin-graphql "^2.0.0"
eslint-plugin-import "^2.9.0"
eslint-plugin-jsx-a11y "^6.0.3"
eslint-plugin-react "^7.8.2"
event-source-polyfill "^1.0.5"
express "^4.16.3"
express-graphql "^0.6.12"
fast-levenshtein "~2.0.4"
file-loader "^1.1.11"
flat "^4.0.0"
fs-exists-cached "1.0.0"
fs-extra "^5.0.0"
gatsby-cli "^2.4.17"
gatsby-link "^2.0.16"
gatsby-plugin-page-creator "^2.0.10"
gatsby-react-router-scroll "^2.0.6"
glob "^7.1.1"
graphql "^14.1.1"
graphql-compose "^6.0.3"
graphql-playground-middleware-express "^1.7.10"
graphql-relay "^0.6.0"
graphql-tools "^3.0.4"
hash-mod "^0.0.5"
invariant "^2.2.4"
is-relative "^1.0.0"
is-relative-url "^2.0.0"
is-wsl "^1.1.0"
jest-worker "^23.2.0"
joi "12.x.x"
json-loader "^0.5.7"
json-stringify-safe "^5.0.1"
kebab-hash "^0.1.2"
lodash "^4.17.10"
lokijs "^1.5.6"
md5 "^2.2.1"
md5-file "^3.1.1"
mime "^2.2.0"
mini-css-extract-plugin "^0.4.0"
mitt "^1.1.2"
mkdirp "^0.5.1"
moment "^2.21.0"
name-all-modules-plugin "^1.0.1"
normalize-path "^2.1.1"
null-loader "^0.1.1"
opentracing "^0.14.3"
optimize-css-assets-webpack-plugin "^5.0.1"
parseurl "^1.3.2"
physical-cpu-count "^2.0.0"
pnp-webpack-plugin "^1.4.1"
postcss-flexbugs-fixes "^3.0.0"
postcss-loader "^2.1.3"
prop-types "^15.6.1"
raw-loader "^0.5.1"
react-dev-utils "^4.2.1"
react-error-overlay "^3.0.0"
react-hot-loader "^4.6.2"
redux "^4.0.0"
request "^2.85.0"
semver "^5.6.0"
shallow-compare "^1.2.2"
sift "^5.1.0"
signal-exit "^3.0.2"
slash "^1.0.0"
socket.io "^2.0.3"
stack-trace "^0.0.10"
string-similarity "^1.2.0"
style-loader "^0.21.0"
terser-webpack-plugin "^1.2.2"
"true-case-path" "^1.0.3"
type-of "^2.0.1"
url-loader "^1.0.1"
uuid "^3.1.0"
v8-compile-cache "^1.1.0"
webpack "~4.28.4"
webpack-dev-middleware "^3.0.1"
webpack-dev-server "^3.1.14"
webpack-hot-middleware "^2.21.0"
webpack-merge "^4.1.0"
webpack-stats-plugin "^0.1.5"
yaml-loader "^0.5.0"

gauge@~2.7.3:
version "2.7.4"
resolved "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7"
Expand Down Expand Up @@ -8565,6 +8746,14 @@ graphql-compose@^5.11.0:
graphql-type-json "^0.2.1"
object-path "^0.11.4"

graphql-compose@^6.0.3:
version "6.0.3"
resolved "https://registry.npmjs.org/graphql-compose/-/graphql-compose-6.0.3.tgz#fa5668a30694abef4166703aa03af07a741039a8"
integrity sha512-QpywEtNvlEQS0a5VIseMA/tk67QmEN9NNUx1B1tzGR/p7MePyus9wvci2cIP/mwdDrvLRRbwpmidSKQXFD3SEA==
dependencies:
graphql-type-json "^0.2.1"
object-path "^0.11.4"

graphql-config@^2.0.1:
version "2.2.1"
resolved "https://registry.npmjs.org/graphql-config/-/graphql-config-2.2.1.tgz#5fd0ec77ac7428ca5fb2026cf131be10151a0cb2"
Expand Down

0 comments on commit 05457f2

Please sign in to comment.