# 带有锚点的 Onebox 隐藏了锚点

**URL:** https://meta.discourse.org/t/oneboxes-with-anchors-hide-the-anchor/191125
**Category:** Feature
**Created:** [2021年五月20日 21:11 UTC](https://meta.discourse.org/t/oneboxes-with-anchors-hide-the-anchor/191125 "2021-05-20T21:11:11Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![mbauman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mbauman/32/139835_2.png) [@mbauman](https://meta.discourse.org/u/mbauman)
#### Post date: [2021年五月20日 21:11 UTC](https://meta.discourse.org/t/oneboxes-with-anchors-hide-the-anchor/191125/1 "2021-05-20T21:11:11Z")

</div>

当我编写一个带有锚点的 onebox（例如指向 GitHub 问题中的特定评论）时，生成的 onebox 会包含多个链接：

> <https://github.com/discourse/discourse/pull/7666#issuecomment-497742621>
>
> You've signed the CLA, jjaffeux. Thank you! This pull request is ready for revie…w.

顶部那个较小的链接（灰色，显示为 `github.com/discourse/discourse` 文本）保留了锚点，但那个显眼的大蓝色链接却去掉了它。我明白在没有特殊支持的情况下，onebox 描述的是页面本身，但我编写了一个带有锚点的标签，希望大多数点击它的人能直接跳转到该锚点。当然，如果只有少量评论，这不算什么大问题；但如果你试图链接到复杂问题中的中间部分，丢失上下文就会成为一个更大的问题。

另一个功能请求是，希望能为 GitHub 评论添加特殊的锚点支持，就像你们为 [Wikipedia](https://meta.discourse.org/t/support-wikipedia-anchors-in-onebox/19664) 所做的那样（注意：该旧话题中生成的 onebox 有些令人困惑，因为 Wikipedia 的页面结构此后已发生变化，但它仍然有效）：

> **[HTTP cookie | Secure cookie](https://en.wikipedia.org/wiki/HTTP_cookie#Secure_cookie)**
>
> A secure cookie can only be transmitted over an encrypted connection (i.e. HTTPS). They cannot be transmitted over unencrypted connections (i.e. HTTP). This makes the cookie less likely to be exposed to cookie theft via eavesdropping. A cookie is made secure by adding the Secure flag to the cookie.
> An http-only cookie cannot be accessed by client-side APIs, such as JavaScript. This restriction eliminates the threat of cookie theft via cross-site scripting (XSS). However, the cookie remains vulne...

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [2022年十月6日 18:13 UTC](https://meta.discourse.org/t/oneboxes-with-anchors-hide-the-anchor/191125/2 "2022-10-06T18:13:04Z")

</div>

@nbianca 最近对此进行了一些改进，现在可在 tests-passed 上使用。请告诉我们您的使用体验。

---

<div class="post-metadata">

### Author: ![nbianca](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nbianca/32/157984_2.png) [@nbianca](https://meta.discourse.org/u/nbianca)
#### Post date: [2022年十月29日 05:00 UTC](https://meta.discourse.org/t/oneboxes-with-anchors-hide-the-anchor/191125/3 "2022-10-29T05:00:17Z")

</div>

此主题在 2 天后自动关闭。不再允许回复。
