# 테마에서 카테고리 전체 설명 받기

**URL:** https://meta.discourse.org/t/receive-the-full-description-of-a-category-in-a-theme/152017
**Category:** Development
**Created:** [5월 19, 2020, 11:20오후 UTC](https://meta.discourse.org/t/receive-the-full-description-of-a-category-in-a-theme/152017 "2020-05-19T23:20:42Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![sbernhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sbernhard/32/208186_2.png) [@sbernhard](https://meta.discourse.org/u/sbernhard)
#### Post date: [5월 19, 2020, 11:20오후 UTC](https://meta.discourse.org/t/receive-the-full-description-of-a-category-in-a-theme/152017/1 "2020-05-19T23:20:42Z")

</div>

AFAIK(제가 아는 한), 설명은 설명의 첫 번째 섹션, 즉 첫 번째 게시물의 첫 번째 부분에 저장(및 유지 관리)됩니다.

카테고리에서 “top”, “Latest” 버튼 근처에 링크를 추가하고 싶습니다. 테마는 카테고리별로 설정할 수 없으므로, 카테고리 설명의 "숨겨진 부분"에 링크 데이터를 단순히 추가할 수 있을 것이라 생각했습니다. 카테고리 목록에는 카테고리 설명의 첫 번째 조각만 표시되므로요.

데이터는 다음과 같은 형태가 될 것입니다: {TAG,linkText,linkTitle,linkHref}.

죄송합니다. 아마도 최선의 방법은 아닐 것 같습니다:

> **[GitHub - sbernhard/discourse-add-category-links: This component scans the full description of a...](https://github.com/sbernhard/discourse-add-category-links)**
>
> This component scans the full description of a discourse category for given tags and display the additional links to categories.

테마/위젯에서 카테고리 설명 텍스트의 전체 데이터를 가져올 수 있을까요?

미리 감사드립니다.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [5월 19, 2020, 11:22오후 UTC](https://meta.discourse.org/t/receive-the-full-description-of-a-category-in-a-theme/152017/2 "2020-05-19T23:22:00Z")

</div>

> [@sbernhard](#):
>
> 테마에서 카테고리의 설명 텍스트 전체 데이터를 가져올 수 있나요?

네, [Category Banners](https://meta.discourse.org/t/discourse-category-banners/86241?u=falco) 링크가 바로 그 용도로 사용됩니다.

---

<div class="post-metadata">

### Author: ![sbernhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sbernhard/32/208186_2.png) [@sbernhard](https://meta.discourse.org/u/sbernhard)
#### Post date: [5월 19, 2020, 11:27오후 UTC](https://meta.discourse.org/t/receive-the-full-description-of-a-category-in-a-theme/152017/3 "2020-05-19T23:27:48Z")

</div>

글쎄, 내 생각은 다음과 같습니다.

- category.description은 잘 형성된 카테고리 설명을 반환합니다.
- category.description\_text은 순수한 데이터를 반환합니다.

하지만 둘 다 설명의 첫 번째 장만 반환할 뿐, 설명을 포함하는 카테고리의 첫 번째 게시물의 전체 내용은 반환하지 않습니다. 제가 놓치고 있는 부분이 있을까요?

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [5월 19, 2020, 11:43오후 UTC](https://meta.discourse.org/t/receive-the-full-description-of-a-category-in-a-theme/152017/4 "2020-05-19T23:43:25Z")

</div>

아, 그것이 의도된 동작입니다. Discourse는 UI 전반에서 카테고리 설명으로 about 토픽의 첫 번째 단락만 사용합니다.

다른 내용이 필요하시다면 콘텐츠를 가져오기 위해 추가 API 호출을 수행해야 합니다.

---

<div class="post-metadata">

### Author: ![sbernhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sbernhard/32/208186_2.png) [@sbernhard](https://meta.discourse.org/u/sbernhard)
#### Post date: [5월 19, 2020, 11:44오후 UTC](https://meta.discourse.org/t/receive-the-full-description-of-a-category-in-a-theme/152017/5 "2020-05-19T23:44:22Z")

</div>

테마 컴포넌트에서 이걸 구현할 수 있을까요? 예시가 있나요?

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [5월 20, 2020, 12:05오전 UTC](https://meta.discourse.org/t/receive-the-full-description-of-a-category-in-a-theme/152017/6 "2020-05-20T00:05:18Z")

</div>

[Topic List Sidebars](https://meta.discourse.org/t/discourse-category-sidebars/107561?u=falco) 가 정확히 이 기능을 수행합니다!

---

<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: [5월 20, 2020, 8:56오전 UTC](https://meta.discourse.org/t/receive-the-full-description-of-a-category-in-a-theme/152017/7 "2020-05-20T08:56:33Z")

</div>

> [@sbernhard](#):
>
> 카테고리의 “top”, “Latest” 버튼 근처에 링크를 추가하고 싶습니다. 테마는 카테고리별로 설정할 수 없으므로, 카테고리 설명의 “숨겨진 부분”에 링크 데이터를 단순히 추가할 수 있을 것 같았습니다. 카테고리 목록에는 카테고리 설명의 첫 번째 조각만 표시되므로 말이죠.

목표가 특정 카테고리 페이지에서 조건부로 링크를 렌더링하는 것이라면, 한 발짝 물러서서 다른 접근 방식을 시도해 보시는 것을 권장합니다.

다음과 같은 설정이 있다고 가정해 보겠습니다.

`target_category, link_text, link_title, link_href`

그런 다음 [이처럼](https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/app/lib/plugin-api.js#L784-L793) 처리할 수 있습니다.

```javascript
api.addNavigationBarItem({
  displayName: text, // 링크 텍스트
  name: title, // 링크 제목
  href: href, // 링크 href
  customFilter: category => {
    return (
      category && category.name.toLowerCase() === TARGET_CATEGORY.toLowerCase() // 대상 카테고리
    );
  }
});

```

여기서 중요한 부분은 `customFilter`입니다. 이것이 바로 여러분이 찾고 있는 것 같으니까요.

여러 개의 링크가 있다면, 이를 [forEach](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach)로 감싸야 합니다.

---

<div class="post-metadata">

### Author: ![sbernhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sbernhard/32/208186_2.png) [@sbernhard](https://meta.discourse.org/u/sbernhard)
#### Post date: [5월 20, 2020, 3:50오후 UTC](https://meta.discourse.org/t/receive-the-full-description-of-a-category-in-a-theme/152017/8 "2020-05-20T15:50:53Z")

</div>

@Falco 감사합니다. 제가 정확히 필요했던 것이었습니다.

@Johani 감사합니다. 제안을 잘 생각해 보았습니다. 불행히도 카테고리 수가 매우 많아서 설정에서 구성하는 것은 크기가 너무 커서 관리하기가 어려울 것입니다. 그래서 이 테마를 직접 작성하게 되었습니다.

제대로 작동하도록 만들었습니다. parent\_categories에 대한 지원을 추가하고 몇 가지 사소한 버그를 수정한 후, 문서화를 거쳐 “제대로 된 방식으로” 배포할 예정입니다.

---

<div class="post-metadata">

### Author: ![sbernhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sbernhard/32/208186_2.png) [@sbernhard](https://meta.discourse.org/u/sbernhard)
#### Post date: [5월 20, 2020, 11:35오후 UTC](https://meta.discourse.org/t/receive-the-full-description-of-a-category-in-a-theme/152017/9 "2020-05-20T23:35:56Z")

</div>

드디어, 이게 마지막인 것 같습니다. 자유롭게 사용해 주세요. Discourse에 기여해 주신 모든 분께 진심으로 “감사합니다” 말씀드립니다. 정말 훌륭한 작업입니다.

테마 컴포넌트 링크:

> **[GitHub - sbernhard/discourse-add-category-links: This component scans the full description of a...](https://github.com/sbernhard/discourse-add-category-links)**
>
> This component scans the full description of a discourse category for given tags and display the additional links to categories.
