fix: show contributor count on contributors page - #43
Merged
Conversation
4evour
force-pushed
the
agent/remove-contributors-count
branch
from
August 3, 2026 10:35
4f5bd9b to
fd3a76b
Compare
LeoninCS
marked this pull request as ready for review
August 3, 2026 12:05
There was a problem hiding this comment.
Pull request overview
该 PR 修复了 contributors(贡献者)分区页的头部统计口径:该页面是数据驱动渲染贡献者卡片的,不应再沿用通用分区模板的“子页面篇数”统计,从而避免出现“共 0 篇”的误导信息,并兼容 Windows 本地预览与 Linux 构建的路径差异。
Changes:
- 在 contributors 页头部显示
共 N 位贡献者,计数来源与贡献者卡片使用同一份hugo.Data.contributors数据。 - 对
.File.Path做分隔符归一化(\->/),保证 Windows 预览与 Linux 构建一致识别 contributors 页。 - 其他 docs 分区页继续显示“共 N 篇”文章数统计,不改变既有行为。
| {{ $content := partial "goclub/stripped-content.html" . }} | ||
| {{ $filePath := replace .File.Path "\\" "/" }} | ||
| {{ $isContributors := eq $filePath "docs/contributors/_index.md" }} | ||
| {{ $contributors := hugo.Data.contributors }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
共 N 位贡献者on the contributors page, using the same contributor data array that renders the cards.Why
The shared section template counted child pages, but the contributors page is data-driven. That produced the misleading
共 0 篇label even though contributor cards were present. The deployment workflow regenerates the contributor data from merged pull requests, so the displayed count now updates with that data instead of being hard-coded.Impact
Only the contributors page header changes. Contributor cards and article counts on other section pages remain unchanged.
Validation
hugo --minifywith Hugo Extended 0.159.0LeoninCS/GoClub: 25 contributors generated共 25 位贡献者, 25 contributor cards, and no共 0 篇