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

feat(docs): Link to main sections from /docs/ #12529

Merged
merged 1 commit into from
Mar 12, 2019
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
8 changes: 8 additions & 0 deletions docs/docs/advanced-tutorials.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: Advanced Tutorials
overview: true
---

Learn about topics that are too large for a doc and warrant a tutorial.

[[guidelist]]
8 changes: 8 additions & 0 deletions docs/docs/api-reference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: API Reference
overview: true
---

Learn more about Gatsby APIs and configuration.

[[guidelist]]
8 changes: 8 additions & 0 deletions docs/docs/conceptual-guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: Conceptual Guide
overview: true
---

Read high-level overviews of the Gatsby approach.

[[guidelist]]
8 changes: 8 additions & 0 deletions docs/docs/guides.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: Guides
overview: true
---

Dive deeper into different topics around building with Gatsby, like sourcing data, deployment, and more.

[[guidelist]]
8 changes: 8 additions & 0 deletions docs/docs/releases-and-migration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: "Releases & Migration"
overview: true
---

Find release notes and guides for migration between major versions.

[[guidelist]]
5 changes: 5 additions & 0 deletions www/src/data/sidebars/doc-links.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- title: Recipes
link: /docs/recipes/
- title: Guides
link: /docs/guides/
items:
- title: Preparing Your Environment
link: /docs/preparing-your-environment/
Expand Down Expand Up @@ -288,6 +289,7 @@
- title: Awesome Gatsby Resources
link: /docs/awesome-gatsby/
- title: API Reference
link: /docs/api-reference/
items:
- title: Gatsby Link
link: /docs/gatsby-link/
Expand All @@ -306,6 +308,7 @@
- title: API Philosophy
link: /docs/api-specification/
- title: Releases & Migration
link: /docs/releases-and-migration/
items:
- title: v2 Release Notes
link: /docs/v2-release-notes/
Expand All @@ -316,6 +319,7 @@
- title: Migrating from v0 to v1
link: /docs/migrating-from-v0-to-v1/
- title: Conceptual Guide
link: /docs/conceptual-guide/
items:
- title: The Gatsby Core Philosophy*
link: /docs/gatsby-core-philosophy/
Expand Down Expand Up @@ -386,6 +390,7 @@
- title: Terminology
link: /docs/behind-the-scenes-terminology/
- title: Advanced Tutorials
link: /docs/advanced-tutorials/
items:
- title: Making a Site with User Authentication
link: /docs/authentication-tutorial/
Expand Down
37 changes: 21 additions & 16 deletions www/src/pages/docs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class IndexRoute extends React.Component {
to dig straight in.
</li>
<li>
<Link to="/docs/recipes">Recipes</Link>: A happy medium between
<Link to="/docs/recipes/">Recipes</Link>: A happy medium between
the tutorial and the quick start, find some quick answers for
how to accomplish some specific, common tasks with Gatsby.
</li>
Expand All @@ -45,33 +45,38 @@ class IndexRoute extends React.Component {
</li>
<ul>
<li>
<strong>Guides</strong>: Dive deeper into different topics
around building with Gatsby, like sourcing data, deployment,
and more.
<Link to="/docs/guides/">Guides</Link>: Dive deeper into
different topics around building with Gatsby, like sourcing
data, deployment, and more.
</li>
<li>
<strong>Ecosystem</strong>: Check out libraries for Gatsby
starters and plugins, as well as external community resources.
<Link to="/ecosystem/">Ecosystem</Link>: Check out libraries
for Gatsby starters and plugins, as well as external community
resources.
</li>
<li>
<strong>API Reference</strong>: Learn more about Gatsby APIs
and configuration.
<Link to="/docs/api-reference/">API Reference</Link>: Learn
more about Gatsby APIs and configuration.
</li>
<li>
<strong>Releases &amp; Migration</strong>: Find release notes
and guides for migration between major versions.
<Link to="/docs/releases-and-migration/">
Releases &amp; Migration
</Link>
: Find release notes and guides for migration between major
versions.
</li>
<li>
<strong>Conceptual Guide</strong>: Read high-level overviews
of the Gatsby approach.
<Link to="/docs/conceptual-guide/">Conceptual Guide</Link>:
Read high-level overviews of the Gatsby approach.
</li>
<li>
<strong>Behind the Scenes</strong>: Dig into how Gatsby works
under the hood.
<Link to="/docs/behind-the-scenes/">Behind the Scenes</Link>:
Dig into how Gatsby works under the hood.
</li>
<li>
<strong>Advanced Tutorials</strong>: Learn about topics that
are too large for a doc and warrant a tutorial.
<Link to="/docs/advanced-tutorials/">Advanced Tutorials</Link>
: Learn about topics that are too large for a doc and warrant
a tutorial.
</li>
</ul>
</ol>
Expand Down
23 changes: 10 additions & 13 deletions www/src/templates/template-docs-markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,8 @@ import Container from "../components/container"

import docsHierarchy from "../data/sidebars/doc-links.yaml"

// I’m doing some gymnastics here that I can only hope you’ll forgive me for.
// Find the guides in the sidebar YAML.
const guides = docsHierarchy.find(group => group.title === `Guides`).items

// Search through guides tree, which may be 2, 3 or more levels deep
const childItemsBySlug = (guides, slug) => {
// Search through tree, which may be 2, 3 or more levels deep
const childItemsBySlug = (docsHierarchy, slug) => {
let result

const iter = a => {
Expand All @@ -31,7 +27,7 @@ const childItemsBySlug = (guides, slug) => {
return Array.isArray(a.items) && a.items.some(iter)
}

guides.some(iter)
docsHierarchy.some(iter)
return result && result.items
}

Expand All @@ -40,14 +36,15 @@ const getPageHTML = page => {
return page.html
}

const guidesForPage = childItemsBySlug(guides, page.fields.slug) || []
const guideList = guidesForPage
.map(guide => `<li><a href="${guide.link}">${guide.title}</a></li>`)
const subitemsForPage =
childItemsBySlug(docsHierarchy, page.fields.slug) || []
const subitemList = subitemsForPage
.map(subitem => `<li><a href="${subitem.link}">${subitem.title}</a></li>`)
.join(``)
const toc = guideList
const toc = subitemList
? `
<h2>Guides in this section:</h2>
<ul>${guideList}</ul>
<h2>In this section:</h2>
<ul>${subitemList}</ul>
`
: ``

Expand Down