From c73792c7b8c19562e6adecdddee41d59e030e930 Mon Sep 17 00:00:00 2001 From: Guillaume Chau Date: Mon, 17 Oct 2022 19:06:36 +0200 Subject: [PATCH] feat(md): links to other stories, fix #265 --- docs/guide/svelte3/docs.md | 10 ++++ docs/guide/vue2/docs.md | 10 ++++ docs/guide/vue3/docs.md | 10 ++++ .../src/components/MarkdownLinks.story.vue | 4 ++ .../src/app/components/panel/StoryDocs.vue | 28 ++++++++- packages/histoire/src/node/markdown.ts | 57 ++++++++++++++----- 6 files changed, 103 insertions(+), 16 deletions(-) diff --git a/docs/guide/svelte3/docs.md b/docs/guide/svelte3/docs.md index 5540ecaa..aecf7479 100644 --- a/docs/guide/svelte3/docs.md +++ b/docs/guide/svelte3/docs.md @@ -37,6 +37,16 @@ This is a demo book using Svelte 3. Learn more about Histoire [here](https://histoire.dev/). ``` +### Links + +You can link to other stories using a relative path to the story file: + +```md +- [Go to Story](./BaseButton.story.svelte) +- [Go to CodeGen > Slots](./CodeGen.story.svelte?variantId=slots) +- [Go to Markdown file](./MarkdownFile.story.md) +``` + ## Source code ::: warning diff --git a/docs/guide/vue2/docs.md b/docs/guide/vue2/docs.md index 23a1535b..2008d824 100644 --- a/docs/guide/vue2/docs.md +++ b/docs/guide/vue2/docs.md @@ -55,6 +55,16 @@ This is a demo book using Vue 2. Learn more about Histoire [here](https://histoire.dev/). ``` +### Links + +You can link to other stories using a relative path to the story file: + +```md +- [Go to Story](./BaseButton.story.vue) +- [Go to CodeGen > Slots](./CodeGen.story.vue?variantId=slots) +- [Go to Markdown file](./MarkdownFile.story.md) +``` + ## Source code By default, Histoire will attempt to generate a copyable source code from the story, dynamically from the current state. diff --git a/docs/guide/vue3/docs.md b/docs/guide/vue3/docs.md index 34e679c9..72732a1a 100644 --- a/docs/guide/vue3/docs.md +++ b/docs/guide/vue3/docs.md @@ -55,6 +55,16 @@ This is a demo book using Vue 3. Learn more about Histoire [here](https://histoire.dev/). ``` +### Links + +You can link to other stories using a relative path to the story file: + +```md +- [Go to Story](./BaseButton.story.vue) +- [Go to CodeGen > Slots](./CodeGen.story.vue?variantId=slots) +- [Go to Markdown file](./MarkdownFile.story.md) +``` + ## Source code By default, Histoire will attempt to generate a copyable source code from the story, dynamically from the current state. diff --git a/examples/vue3/src/components/MarkdownLinks.story.vue b/examples/vue3/src/components/MarkdownLinks.story.vue index b076cc21..c22c8a36 100644 --- a/examples/vue3/src/components/MarkdownLinks.story.vue +++ b/examples/vue3/src/components/MarkdownLinks.story.vue @@ -12,4 +12,8 @@ # Welcome This is just a link to [Histoire.dev](https://histoire.dev/){id="link-to-history"}. + +- [Go to Introduction](./Introduction.story.vue) +- [Go to CodeGen > Slots](./CodeGen.story.vue?variantId=slots) +- [Go to Markdown file](../MarkdownFile.story.md) diff --git a/packages/histoire-app/src/app/components/panel/StoryDocs.vue b/packages/histoire-app/src/app/components/panel/StoryDocs.vue index 66c3ad51..8ba34b53 100644 --- a/packages/histoire-app/src/app/components/panel/StoryDocs.vue +++ b/packages/histoire-app/src/app/components/panel/StoryDocs.vue @@ -47,6 +47,7 @@ export function useStoryDoc (story: Ref) {