Git Product home page Git Product logo

tinacms-doc-toolkit's Introduction

Welcome to the react tinacms documentation toolkit

Getting started

  1. Create a new docs site: npx create-next-app --example https://github.com/tinalabs/tinacms-doc-toolkit/tree/master/packages/example-site-next docs

  2. Then navigate to the docs site: cd docs

  3. And start the dev server and follow the on-screen instructions: npm run dev

You can see further instructions for getting started and using the toolkit in the documentation.

Note

This toolkit comes pre-configured to deploy to Github pages, with a Github actions workflow stored in the .github folder.

If you create a new Github repository with this site, it will automatically deploy to Github pages.

Setting up from scratch

Please see SETUP.md for instructions on how to get up a nextjs site from scratch using the plugin

tinacms-doc-toolkit's People

Contributors

chrisdmacrae avatar logan-anderson avatar

Watchers

 avatar  avatar  avatar  avatar

tinacms-doc-toolkit's Issues

Update to look like TinaCMS docs

Make it look like the TinaCMS docs, minus:

  • The docs sidebar
  • The docs footer

The table of contents should reflect:

  • The pages in the tina-demo.config.js
  • The h2s in the MDX doc you're currently viewing

Add a CRA example

Same as Next example -- ideally they would share MDX files somehow. A script to copy them at build time?

MDX logic

Overview

Documenting a third-party plugin should be easy, fun, and interactive for the end-user.

Tina plugins are hard to reason about in text-based documentation, much easier to reason about visually.

Scope

A JSON config specifies which MDX files are part of the demo. This is used by helpers for CRA and Next.js to generate routes for every specified MDX file on-the-fly.

As each route is rendered, the MDX will be processed with remark and mdx to become the body of the page.

Value

MDX will allow users to import the pieces of their plugin code in markdown documentation, making integration documentation painless and easy.

Appetite

1 person, 2 days.

Bake in loadComponent

Right now we're only supporting Next.js and CRA, so we know a web pack loading strategy will work.

I also don't think we should scope it to mdx files.

If we include it in the tinacms-demo-toolkit package, and make the loadComponent prop of Layout optional, defaulting to the baked in logic if its undefined, that would be better.

This works 100% for MDX, TSX, TS, JS, and JSX:

export const loadComponent = async (fileName: string) => {
  try {
    const component = await import(`../docs/${fileName}`);
    return component;
  } catch (e) {
    console.error(`${fileName} was not found`);
    console.error(e);
    throw e;
  }
};

E.g, doing:

|- docs/
|--- page/
|---- content.mdx
|---- code.tsx
|---- index.ts

index.ts

import Content from "./content.mdx";

export default Content;

It works just fine.

Wrap up mdx logic for next.js

Lets put the next.config.js logic inside an imported method:

export function configureNext(config: any) {
  config.pageExtensions: pageExtensions: ['js', 'jsx', 'ts', 'tsx', 'md', 'mdx'];

  return withMDX(config);
}

const withMDX = require('@next/mdx')({
  extension: /\.mdx?$/,
})

next.config.js

import { configureNext } from "tinacms-demo-toolkit";

module.exports = (phase, { defaultConfig }) => {
  const config = defaultConfig;

  return configureNext(config);
}

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.