# テーマ内のカテゴリの完全な説明を取得する

**URL:** <https://meta.discourse.org/t/receive-the-full-description-of-a-category-in-a-theme/152017>\
**Category:** Development\
**Created:** [2020 年 5 月 19 日午後 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:** 1\
**Showing post:** 7

<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:** [2020 年 5 月 20 日午前 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](#):
>
> カテゴリの「トップ」や「最新」ボタンの近くにリンクを追加したいと考えています。テーマはカテゴリごとに設定できないため、カテゴリの説明の「非表示部分」にリンクのデータを追加しようと思いました。カテゴリ一覧では、カテゴリ説明の最初の部分のみが表示されるためです。

特定のカテゴリページでのみリンクを条件付きで表示したいという目的であれば、一度立ち止まって別のアプローチを試すことをお勧めします。

例えば、以下のような設定があると仮定します。

```plaintext
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, // リンク先
  customFilter: category => {
    return (
      category && category.name.toLowerCase() === TARGET_CATEGORY.toLowerCase() // 対象カテゴリ
    );
  }
});

```

ここで重要なのは `customFilter` です。これがまさに求めている機能だと思われます。

複数のリンクを追加する場合は、それを [forEach](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach) で囲む必要があります。

---

_[View the full topic](https://meta.discourse.org/t/receive-the-full-description-of-a-category-in-a-theme/152017)._
