# 条件付きコンテンツ

条件付きコンテンツブロックを使うと、ユーザーデータや変数に基づいて、ページ上の特定のコンテンツブロックを誰が見られるかを制御できます。これらの変数は、Cookie、機能フラグ、認証済みアクセス、または URL パラメータを通じて渡すことができます。

### 条件付きコンテンツを作成する

条件付きブロックを追加するには、エディタで新しい行を始めて、 <kbd>/</kbd>と入力し、次に <picture><source srcset="broken-reference" media="(prefers-color-scheme: dark)"><img src="https://4217681718-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2F51vQZhUqnkdsYpyUo1Pj%2Fpage-condition.svg?alt=media&#x26;token=31dd334a-5097-4081-915c-db460e610ec6" alt="The Page condition icon in GitBook"></picture> **条件付きコンテンツ**.

ブロックを挿入したら、ブロック右上にある赤い条件バッジをクリックします。

これをクリックすると、次の方法で条件を追加できます。 [条件エディター](https://gitbook-v2-q67etdj25-gitbook.vercel.app/url/gitbook.com/docs/documentation/ja-gitbook-documentation/publishing-documentation/adaptive-content/adapting-your-content#working-with-the-condition-editor)。条件は次のように記述できます。 [式](https://gitbook.com/docs/creating-content/variables-and-expressions) サイトで定義されたデータに対して実行される式。データを参照できます。 [変数](https://gitbook-v2-q67etdj25-gitbook.vercel.app/url/gitbook.com/docs/documentation/ja-gitbook-documentation/creating-content/variables-and-expressions)、または訪問者から送られてくるデータを参照できます。 [クレーム](https://gitbook-v2-q67etdj25-gitbook.vercel.app/url/gitbook.com/docs/documentation/ja-gitbook-documentation/publishing-documentation/adaptive-content/enabling-adaptive-content#set-your-visitor-schema).

参照 [適応型コンテンツ](https://gitbook-v2-q67etdj25-gitbook.vercel.app/url/gitbook.com/docs/documentation/ja-gitbook-documentation/publishing-documentation/adaptive-content) 詳細については。

### 例

以下の例では、ボタンからリンクされた URL パラメータを使用して、どの条件付きコンテンツブロックを表示するかを制御しています。

{% if visitor.claims.unsigned.example\_attribute\_A %}
このブロックは、ユーザーのみに表示されます **で** 属性 A を持つ。

<a href="https://gitbook.com/docs/creating-content/blocks/conditional-content?visitor.example_attribute_A=false" class="button primary">属性 A なしで表示</a>
{% endif %}

{% if !visitor.claims.unsigned.example\_attribute\_A %}
このブロックは、ユーザーのみに表示されます **なしで** 属性 A を持つ。

<a href="https://gitbook.com/docs/creating-content/blocks/conditional-content?visitor.example_attribute_A=true" class="button primary">属性 A ありで表示</a>
{% endif %}

## Markdownでの表現

```markdown
## 例

{% if visitor.claims.unsigned.example_attribute_A %}
このブロックは、属性 A **あり** のユーザーにのみ表示されます。
<a href="https://gitbook.com/docs/creating-content/blocks/conditional-content?visitor.example_attribute_A=false" class="button primary">属性 A なしで表示</a>
{% endif %}

{% if !visitor.claims.unsigned.example_attribute_A %}
このブロックは、属性 A **なし** のユーザーにのみ表示されます。
<a href="https://gitbook.com/docs/creating-content/blocks/conditional-content?visitor.example_attribute_A=true" class="button primary">属性 A ありで表示</a>
{% endif %}
```
