Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Oct 13, 2025

When GitHub renders README.md files, it automatically wraps images in anchor tags that link to the image URL. This causes an issue with badges used in section headings - when users click on these badges, they open the shield image in a new page instead of navigating to the section.

This PR fixes the issue by explicitly wrapping the badge images with anchor tags that link to their respective section anchors:

Before:

#### On-demand importing <sup><img src="https://img.shields.io/badge/recommended-10B981" alt="recommended" align="middle" height="16"></sup>

Clicking the badge opens https://img.shields.io/badge/recommended-10B981 in a new tab.

After:

#### On-demand importing <sup><a href="#on-demand-importing-"><img src="https://img.shields.io/badge/recommended-10B981" alt="recommended" align="middle" height="16"></a></sup>

Clicking the badge now navigates to the "On-demand importing" section on the same page.

Sections fixed:

  • README.md: "On-demand importing" and "Slots" sections
  • README.zh-Hans.md: "按需导入" and "插槽" sections

The anchor IDs follow GitHub's actual generation rules, including trailing hyphens when there's a space between the heading text and the badge (lowercase, spaces replaced with hyphens, Chinese characters preserved, trailing hyphen for spaced elements). This change improves navigation UX without affecting the visual appearance or breaking any existing functionality.

Original prompt

When GitHub renders an image in a README.md, it automatically links the image in an a tag. When users click the badge on the titles, a new page of the image will be opened accidentally. Can you link the badges on the titles to the anchor it belongs to instead?


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copy link

vercel bot commented Oct 13, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
vue-echarts Ready Ready Preview Comment Oct 13, 2025 3:01pm

@Copilot Copilot AI changed the title [WIP] Update badge links to connect to anchors in README.md Fix badge links in README section headings to point to anchors instead of images Oct 13, 2025
@Copilot Copilot AI requested a review from kingyue737 October 13, 2025 14:53
Copilot finished work on behalf of kingyue737 October 13, 2025 14:53
@kingyue737
Copy link
Member

@copilot Don't forget the trailing hyphen in the href since the there is a space between title text and its badge. Furthermore, please remove the lock file you created.

Copy link
Author

Copilot AI commented Oct 13, 2025

@copilot Don't forget the trailing hyphen in the href since the there is a space between title text and its badge. Furthermore, please remove the lock file you created.

Fixed the anchor hrefs to include trailing hyphens (#on-demand-importing-, #slots-, #按需导入-, #插槽-) and removed the package-lock.json file. Changes validated with linting. (8f07ec9)

Copilot finished work on behalf of kingyue737 October 13, 2025 15:02
@kingyue737 kingyue737 marked this pull request as ready for review October 13, 2025 15:03
@kingyue737 kingyue737 requested a review from a team as a code owner October 13, 2025 15:03
@kingyue737
Copy link
Member

@copilot you still create the package-lock.json, we use pnpm instead of npm

Copy link
Author

Copilot AI commented Oct 13, 2025

@copilot you still create the package-lock.json, we use pnpm instead of npm

The package-lock.json file was already removed in commit 73bdebb. The repository now only contains pnpm-lock.yaml, which is correct for this pnpm-based project. No package-lock.json exists in the current state.

Copilot finished work on behalf of kingyue737 October 13, 2025 15:07
@Justineo
Copy link
Member

Hmm I didn't notice that the badges are creating a trailing hyphen to the link. What do you think if we move the badge to the next line?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants