feat: Add nofollow and ugc to external links#907
Merged
imaegoo merged 1 commit intoMar 31, 2026
Conversation
f2c-ci-robot Bot
pushed a commit
to halo-dev/plugin-comment-widget
that referenced
this pull request
Apr 7, 2026
fix #214 - `+ ugc` 符合最新语义(Google 自 2019) 我调查了下其他的 - twikoo 是 noopener noreferrer nofollow ugc twikoojs/twikoo#907 - waline 是 ugc nofollow noopener noreferrer walinejs/waline#3531 - artalk 是 noreferrer noopener nofollow ArtalkJS/Artalk#1120 - valine 是 noopener 相关文档: - nofollow 和 ugc 一起用以保证兼容性:https://developers.google.com/search/blog/2019/09/evolving-nofollow-new-ways-to-identify?hl=zh-cn#can-i-use-more-than-one-rel-value-on-a-link - 几个用于出站链接的 rel 值(sponsored,ugc,nofollow)介绍:https://developers.google.com/search/docs/crawling-indexing/qualify-outbound-links?hl=zh-cn --- 没有把链接的 target / rel 处理放进 packages/comment-widget/src/utils/html.ts 的 cleanHtml(),而是放在了渲染期 packages/comment-widget/src/comment-content.ts。 给评论正文里的 <a> 统一补 target="_blank" 和 rel="noopener noreferrer nofollow ugc" 作为渲染策略,区分于清洗逻辑。如果要在清洗的时候就做这个 rel 修改,有以下问题: - 首先数据库要额外保存 rel,要修改默认 sanitize-html 策略(附:sanitize-html 默认给 a 允许的是:href、name、target。) - 之前数据不带 rel 的已有数据,在渲染时也不能自带加上新 rel。
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.
+ ugc符合最新语义(Google 自 2019)我调查了下其他的
相关文档: