Giter Club home page Giter Club logo

gatsby-theme-documentation's Introduction

gatsby-theme-documentation

A minimalist Gatsby Theme for documentation sites built with MDX and Theme UI.

Get up and running in seconds with a beautiful docs site so you can do what's more important: write docs.

image

Features

Installation

yarn add gatsby-theme-documentation

Install as a starter

Name Command
Base gatsby new johno/gatsby-starter-documentation
Dark gatsby new johno/gatsby-starter-documentation-dark
Tomato gatsby new johno/gatsby-starter-documentation-tomato

Read the full setup guide

Usage

// gatsby-config.js
module.exports = {
  plugins: [
    'gatsby-theme-documentation'
  ]
}

Customizing the sidebar

gatsby-theme-documentation uses a sidebar.mdx file to populate the navigation. In order to customize it you can shadow it by creating a file at src/gatsby-theme-documentation/sidebar.mdx.

Example sidebar.mdx

- [Introduction](/introduction/)
- [Getting Started](/getting-started/)
- [GitHub](https://github.com/johno/gatsby-theme-documentation)

Customizing the header

Similarly to sidebar customization, you can also change the header content by writing MDX. You can shadow the default header by creating a file at src/gatsby-theme-documentation/header.mdx

Example header.mdx

# ![Docs Logo](https://contrast.now.sh/white/black?width=80&height=40&text=DOCS)

- [GitHub](https://github.com/johno/gatsby-theme-documentation)
- [Twitter](https://twitter.com/4lpine)

Adding component shortcodes

You can add shortcodes to your docs site which can be used throughout your docs pages by extending the components passed to MDXProvider. You can do this by using component shadowing and creating the following file in the root of your project: src/gatsby-theme-documentation/components.js.

Example components.js

import baseComponents from 'gatsby-theme-documentation/src/components'

import MyCustomH1 from '../components/my-custom-h1'

export default {
  ...baseComponents,
  h1: MyCustomH1
}

Readme routing

In order to get documents rendered in directories on GitHub, it's common to specify a readme.md similarly to the index.html on normal websites. Since this theme is meant to work seamlessly with docs directories on GitHub, file/path/readme.md will be automatically turned into /file/path/index.html in the built site. Links will also be redirected to support the new url scheme.

Docs schema

This theme creates a Docs type which can be queried as an individual document or a collection. This data can be used to create additional pages, create summaries, etc.

Query an individual document

{
  docs(slug: {eq: "/some-page"}) {
    slug
    body
  }
}

Query a collection

{
  allDocs {
    slug
  }
}

gatsby-theme-documentation's People

Contributors

imedadel avatar jletey avatar johno avatar kyleamathews avatar rdela avatar renovate-bot avatar renovate[bot] avatar steveruizok avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

gatsby-theme-documentation's Issues

Add a theme switcher

Would love for a theme switcher (kind of like on the Theme UI docs) with support for custom colors, and also with defaults such as light, dark, deep, and tomato

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Other Branches

These updates are pending. To force PRs open, click the checkbox below.

  • Update actions/setup-node action to v3

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/publish.yml
  • actions/checkout master
  • actions/setup-node v1
  • johno/actions-push-subdirectories master
  • johno/actions-yarn master
npm
package.json
  • gatsby 3.14.6
  • lerna 4.0.0
  • react 18.2.0
  • react-dom 18.2.0
  • react 18.2.0
  • react-dom 18.2.0
packages/gatsby-theme-documentation/package.json
  • @emotion/core 10.3.1
  • @mdx-js/mdx 1.6.22
  • @mdx-js/react 1.6.22
  • @theme-ui/presets 0.9.1
  • @theme-ui/prism 0.3.5
  • @theme-ui/sidenav 0.9.1
  • gatsby-plugin-mdx 2.14.2
  • gatsby-plugin-meta-redirect 1.1.1
  • gatsby-plugin-react-helmet 4.14.0
  • gatsby-plugin-redirects 1.0.0
  • gatsby-plugin-theme-ui 0.3.5
  • gatsby-source-filesystem 3.14.0
  • is-absolute-url 4.0.1
  • react-helmet 6.1.0
  • remark-emoji 2.2.0
  • remark-slug 6.1.0
  • theme-ui 0.2.52
  • gatsby 3.14.6
  • react 18.2.0
  • react-dom 18.2.0
  • gatsby ^2.15.24 || ^3.0.0
  • react ^16.9.0 || ^17.0.0 || ^18.0.0
  • react-dom ^16.9.0 || ^17.0.0 || ^18.0.0

  • Check this box to trigger a request for Renovate to run again on this repository

Cannot change theme for prism

Great package!

While the theme.js file will set visual properties for general styles (e.g. changing the text color to 'red' will change all of the text to the color red), the prism properties are ignored.

For example, changing the color for all values to 'muted' will result in no change to the color of any style -- they'll all remain purple on gray as defined in the package.

mdx not updated, plus a weird warning

Hi, thank your for the work. But I encountered 2 issues and wan't sure if they are related.

  1. Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()

image

Seems like Sidenav can't use ref. But I don't know how to solve it.

  1. mdx in docs not updating immediately: I have to gatsby clean and then gatsby develop to see the changes. Updating sidebar.mdx works fine, thought.

(Thanks again. I'm new to React and gatsby.)

Margin on mobile

@johno As you may know, we're using this theme for our documentation at Learn Anything (here is our repo) ... and we've noticed that there isn't any margins for the mobile view. Here is a screenshot:

Would love a fix for this ๐Ÿ™

TypeError: Cannot read property 'headings' of null

I'm getting the above error when trying to recreate the example website.

To reproduce:

gatsby new docs johno/gatsby-starter-documentation
cd docs
gatsby develop

In the console the errors are mostly about invalid GraphQL queries, so it's possible that "cannot read property" isn't the core problem.

Full traceback:

ERROR #85901  GRAPHQL

There was an error in your GraphQL query:

[BABEL] unknown: Invalid Option: The 'modules' option must be one of
 - 'false' to indicate no module processing
 - a specific module type: 'commonjs', 'amd', 'umd', 'systemjs' - 'auto' (default) which will automatically select 'false' if the current
   process is known to support ES module syntax, or "commonjs" otherwise
 (While processing: "base$1")

   1 | query userskyletmpdocsnodeModulesgatsbyThemeDocumentationsrctemplatesdocJs1005468272($id: String!) {
   2 |   doc: docs(id: {eq: $id}) {
   3 |     id
   4 |     title
   5 |     description
>  6 |     excerpt
     |     ^
   7 |     body
   8 |     headings {
   9 |       value
  10 |     }
  11 |   }
  12 | }
  13 |

File path: /Users/kyle/tmp/docs/node_modules/gatsby-theme-documentation/src/templates/doc.js
Url path: /
Plugin: none

There are a few of these errors, one for each file apparently.

> gatsby --version
Gatsby CLI version: 2.8.13
Gatsby version: 2.22.4
  Note: this is the Gatsby version for the site at: /Users/kyle/tmp/docs
> node --version
v12.13.1

Mac OS 10.15.3

Trouble adding local image support

Hello, thanks for sharing this theme!

I've added your theme to an existing barebones gatsby site, and I'd like to have the ability to include local images in mdx files with the format, with the image located in the same directory as the mdx file.

I've tried two local image methods separately with no success.

  1. Adding this to top level gatsby-config.js
`gatsby-plugin-sharp`,
    {
      resolve: `gatsby-plugin-mdx`,
      options: {
        gatsbyRemarkPlugins: [
          {
            resolve: `gatsby-remark-images`,
            options: {
              maxWidth: 1200,
            },
          },
        ],
      },
    }
  1. Also..
{
    resolve: `gatsby-transformer-remark`,
    options: {
      plugins: [
        {
          resolve: `gatsby-remark-copy-linked-files`,
          options: {
            destinationDir: `path/to/dir`,
            ignoreFileExtensions: [],
          },
        },
      ],
    },
  },

Would appreciate any suggestions!
-Kent

Using pathPrefix creates wrong hyperlinks in sidebar

Steps to reproduce

  1. Add pathPrefix config to gatsby-config.js
  2. Build using gatsby build --prefix-paths (Gatsby docs)

Expected behavior

Paths should have the path prefix added once.
e.g. /endpoints would become /my-path/endpoints after build.

Actual behavior

For assets and links inside .mdx pages inside /docs the path is added once, but for links created in sidebar.mdx the path is added twice.
Actual result: /my-path/my-path/endpoints

Actual generated example

src/gatsby-theme-documentation/sidebar.mdx

<li><div class="css-70qvj9">
<a class="css-1dbh7qa" href="/my-path/my-path/">Api</a>
</div></li>
<li><div class="css-70qvj9">
<a class="css-1dbh7qa" href="/my-path/my-path/installation">Installation</a>
</div></li>
<li><div class="css-70qvj9"><a class="css-1dbh7qa" href="/my-path/my-path/endpoints">Endpoints</a>
</div></li>

gatsby-config.js

module.exports = {
	siteMetadata: {
		title: 'API Documentation',
		description: 'Docs for API',
	},
	plugins: [
		'gatsby-theme-documentation',
	],
	pathPrefix: 'my-path',
}

Feature Request - Sidebar Nav

This is more of a feature request than anything but if when you've navigated to a submenu item, the sub nav that you're currently in should remain open on page load.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.