Skip to content

[Bug]: Anchor for docs page Subheading wrong #25026

Closed
@xyy94813

Description

Describe the bug

In current version of storybook:

  • Uses storyName as an anchor id.
  • encodes the special characters. (replace by - when custom story name)

Extremely high duplication of Story anchors under non-English documents
This can limit non-English documents, especially for i18n.

<Subheading>{story.name}</Subheading>

const tagID = children.toLowerCase().replace(/[^a-z0-9]/gi, '-');

To Reproduce

// button.stories.tsx

const meta: Meta<typeof Button> = {
  //...
}

export default meta;

type Story = StoryObj<typeof Button>;

export const primary: Story = {
  name: '你好', // this is Chinese
}

export const story2: Story = {
  name: '故事', // this is Chinese
}

System

System:
    OS: macOS 13.6.1
    CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 16.20.2 - ~/.nvm/versions/node/v16.20.2/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 8.19.4 - ~/.nvm/versions/node/v16.20.2/bin/npm <----- active
  Browsers:
    Chrome: 119.0.6045.159
    Safari: 16.6
  npmPackages:
    @storybook/addon-actions: ^7.5.3 => 7.5.3 
    @storybook/addon-essentials: ^7.5.3 => 7.5.3 
    @storybook/react: ^7.5.3 => 7.5.3 
    @storybook/react-vite: ^7.5.3 => 7.5.3 
    @storybook/storybook-deployer: ^2.8.16 => 2.8.16 
    eslint-plugin-storybook: ^0.6.15 => 0.6.15 
    storybook: ^7.5.3 => 7.5.3

Additional context

Why do we need replace(/[^a-z0-9]/gi, '-') ???
Wouldn't it be better to use encodeURI ???

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions