0.0.68 • Published 1 year ago

@storybook-extras/markdown v0.0.68

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Getting started

  1. Install the addon:
yarn add @storybook-extras/markdown -D
  1. Add the addon to your Storybook config:
// .storybook/main.ts
import { StorybookConfig } from '@storybook/angular';
import { ExtrasConfig } from '@storybook-extras/preset';

const config: StorybookConfig & ExtrasConfig = {
    ...
    "stories": [
        "../*.@(md|html)",
        "../src/**/*.stories.@(js|jsx|ts|tsx)"
    ],
    "addons": [
        "@storybook-extras/markdown",
        ...
    ],
    ...
}

export default config;
  1. Optionally you may want to pass includes and/or excludes options if needed like so:
export default {
    addons: [
        {
            name: '@storybook-extras/markdown',
            options: {
                includes: '../stories/**/*.@(md|html)',
                excludes: [/\.component\.html$/],
                stories: [
                    {
                        path: '../stories/markdown-main-js.md',
                        title: 'Markdown/main.js',
                    },
                ],
            },
        },
    ],
};

That's it, you're done. Now you will find README & CHANGELOG along with HTML docs if you want as well, in your Storybook sidebar and you can open them and see the contents.

Custom Titles

Currently Storybook will be using the file name as the story title, e.g. README.md will be README. This addon supports multiple options to customize the title for your .md & .html files.

PrecedenceOptionExample
1Use the HTML title tag<title>Docs/Custom Title</title>
2Use the HTML meta tag, usign Meta will throw an error<meta title="Custom Title" />
3Uses a markdown comment in the file{/*title:"Custom Title"*/}
4Use predefined list of titles from main.jsSee below
5Use the filename with a + to separate the title. Note: full path will be omitted.Markdown+Custom Title.md becomes Markdown/Custom Title

Predefined Titles

// .storybook/main.ts
import { StorybookConfig } from '@storybook/angular';
import { ExtrasConfig } from '@storybook-extras/preset';

const config: StorybookConfig & ExtrasConfig = {
    // if you are using @storybook-extras/markdown
    addons: [
        {
            name: '@storybook-extras/markdown',
            options: {
                titles: {
                    '../README.md': 'Custom Title',
                },
            },
        },
    ],
    // if you are using @storybook-extras/preset
    extras: {
        markdown: {
            titles: {
                '../README.md': 'Custom Title',
            },
        },
    },
};

export default config;

NOTE: Custom Title processing is dependendant on #20809

Read More

I have written a series of articles to explain the motivation and purpose behind this addon. Feel free to read through.

Also make sure to check out these PRs that made this addon possible:

0.0.68

1 year ago

0.0.40

1 year ago

0.0.46

1 year ago

0.0.37

1 year ago

0.0.38

1 year ago

0.0.39

1 year ago

0.0.32

1 year ago

0.0.33

1 year ago

0.0.34

1 year ago

0.0.36

1 year ago

0.0.62

1 year ago

0.0.63

1 year ago

0.0.64

1 year ago

0.0.65

1 year ago

0.0.66

1 year ago

0.0.67

1 year ago

0.0.60

1 year ago

0.0.61

1 year ago

0.0.59

1 year ago

0.0.51

1 year ago

0.0.52

1 year ago

0.0.53

1 year ago

0.0.54

1 year ago

0.0.55

1 year ago

0.0.56

1 year ago

0.0.57

1 year ago

0.0.58

1 year ago

0.0.50

1 year ago

0.0.48

1 year ago

0.0.31

1 year ago

0.0.30

1 year ago

0.0.28

1 year ago

0.0.27

1 year ago

0.0.26

1 year ago

0.0.24

1 year ago

0.0.23

1 year ago

0.0.22

1 year ago

0.0.21

1 year ago

0.0.15

1 year ago

0.0.14

1 year ago

0.0.13

1 year ago

0.0.12

1 year ago

0.0.11

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago