• This is a reasonable default for generating unique ids for elements in the Markdown component.

    Parameters

    • textOrTokens: string | readonly Token[]

      The text or list of marked.Token to convert to a unique id

    Returns string

    a unique id that can be applied to a component

    Example

    Simple Example

    const text = "This is some heading text";
    const id = useSluggedId(text);
    // "this-is-some-heading-text"

    Example

    Using Tokens

    const tokens: readonly Token[] = [
    { type: "text", text: "Some content", raw: "Some content" },
    {
    type: "link",
    text: "Link Text",
    raw: "[Link Text](https://example.com)",
    href: "https://example.com",
    title: "",
    tokens: [
    {
    type: "text",
    raw: "Link Text",
    text: "Link Text",
    },
    ],
    },
    ];
    const id = useSluggedId(tokens);
    // "some-content-link-text"

Generated using TypeDoc