Skip to content

Commit

Permalink
docs(StoryTitle): make anchorable
Browse files Browse the repository at this point in the history
KOTVA
  • Loading branch information
MiroslavPetrik committed Mar 9, 2024
1 parent efbd0af commit 0438674
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions .storybook/blocks/StoryTitle.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import React from "react";
import { Title } from "@storybook/blocks";
import { useOf } from "@storybook/blocks";
import { Markdown, useOf } from "@storybook/blocks";
import type { ModuleExport } from "@storybook/types";

export const StoryTitle = ({ of }: { of: ModuleExport }) => {
const resolvedOf = useOf(of || "story", ["story", "meta"]);
switch (resolvedOf.type) {
case "story": {
return <h3>{resolvedOf.story.name}</h3>;
}
case "meta": {
return <h3>{resolvedOf.preparedMeta.title}</h3>;
return <Markdown>{`### ${resolvedOf.story.name}`}</Markdown>;
}
}

return <></>;
};

0 comments on commit 0438674

Please sign in to comment.