# TOC 컴포넌트 및 헤더 ID

**URL:** https://meta.discourse.org/t/toc-component-and-header-ids/156601
**Category:** Support
**Created:** [7월 2, 2020, 2:00오후 UTC](https://meta.discourse.org/t/toc-component-and-header-ids/156601 "2020-07-02T14:00:34Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![Johani](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/johani/32/176920_2.png) [@Johani](https://meta.discourse.org/u/Johani)
#### Post date: [7월 6, 2020, 7:06오전 UTC](https://meta.discourse.org/t/toc-component-and-header-ids/156601/3 "2020-07-06T07:06:40Z")

</div>

> [@guildai](#):
>
> 개인적으로 Discourse가 요소의 `id` 속성을 제거해서는 안 된다고 생각합니다.

> [@guildai](#):
>
> 불행히도 Discourse는 위의 코드가 실행되기 전에 게시글 요소에서 `id` 속성을 제거하여 로직이 무력화됩니다.
> 
> `<h4 id="alt-main-outlet">main outlet</h4>` 를 사용하는 헤더는 다음과 같습니다:

헤더를 추가해야 한다면 `heading--` 접두사가 필요합니다. 이에 대한 자세한 정보는 여기서 확인하실 수 있습니다: [Linking to a heading within a post or topic](https://meta.discourse.org/t/deep-linking-to-headings-anchors/47552)

이러한 접두사가 없는 id는 id 값과 관계없이 모두 제거됩니다.

> [@guildai](#):
>
> TOC(목차)를 사용할 경우, 두 개의 **Examples** 헤더가 동일한 ID를 갖게 됩니다.

중복된 텍스트를 가진 헤더는 현재 TOC 구성 요소에서 지원되지 않으며, 과거에도 지원된 적이 없습니다. 해당 구성 요소는 헤더의 텍스트를 기반으로 id를 생성합니다. 따라서 텍스트가 완전히 동일한 두 개의 헤더는 동일한 id를 부여받게 됩니다.

현재 해당 구성 요소에서 이 문제를 패치할 계획은 없습니다. 자동 id 생성은 [다음 버전의 Discourse](https://meta.discourse.org/t/discourse-version-2-6/151394) 기능 목록에 포함되어 있으며, 헤더의 인덱스를 id에 추가하여 중복 헤더 문제를 해결할 계획입니다.

> [@guildai](#):
>
> Discourse 팀이 ID 하이재킹에 대해 그렇게 우려한다면, 모든 Discourse ID에 접두사를 붙여야 합니다(예: `discourse-main-outlet`). 그리고 ID 제거는 이러한 접두사가 있는 ID에만 적용되어야 합니다.

이를 코어에 구현할 때, 생성된 헤더에 접두사를 추가하는 것만으로도 충분할 것이라고 생각합니다.

---

_[View the full topic](https://meta.discourse.org/t/toc-component-and-header-ids/156601)._
