0

Squarespace のページ設定でサムネイル画像を取得する JSON テンプレート ステートメントをいくつか作成しました。本来どおりに機能しますが、ブログ リスト、ブログ アイテム、および通常のページから取得する 3 つのセクションがあります。

現在、サイトにアクセスすると、コードは 3 つすべてを実行します。ステートメントを挿入したいのですが{or}、そのように構成され、正しく機能します。

私をつまずかせているのは、a{.section}や a{.main-image?}などがあるため、これら 3 つのコード セクションを 1 つにまとめて{.section mainImage}配置する場所がわからないことです。{or}

どうすればこれを行うことができますか?

<!--Displays Thumbnail image from first blog post in the blog list-->
{.section items.0}
{.main-image?}
            <div class="color-overlay"></div>
<figure class="content-fill main-image"><img {@|image-meta}></figure>
{.end} 
{.end}

<!--Displays Thumbnail image blog post-->       
{.section item}
{.main-image?}
            <div class="color-overlay"></div>
<figure class="content-fill main-image"><img {@|image-meta}></figure>
{.end} 
{.end}

<!--Displays Thumbnail image in a Page-->       
{.section collection}
{.section mainImage}
            <div class="color-overlay"></div>
<figure class="content-fill main-image"><img {@|image-meta}></figure>
{.end} 
{.end}

私をつまずかせているのは、a{.section}や a{.main-image?}などがあるため、これら 3 つのコード セクションを 1 つにまとめて{.section mainImage}配置する場所がわからないことです。{or}

4

1 に答える 1

0

答えが見つかりました!セクション全体をラップする必要があります

{.if items.0 || 項目} .. {または} .. {終了}

ここを参照してください:

{.if items.0 || item}

        <!--Displays Thumbnail image from first blog post in the blog list-->
        {.section items.0}
        {.main-image?}
                    <div class="color-overlay"></div>
        <figure class="content-fill main-image"><img {@|image-meta}></figure>
        {.end} 
        {.end}

        <!--Displays Thumbnail image blog post--> 
        {.section item}
        {.main-image?}
                    <div class="color-overlay"></div>
        <figure class="content-fill main-image"><img {@|image-meta}></figure>
        {.end} 
        {.end}

        {.or}

        <!--Displays Thumbnail image in a Page--> 
        {.section collection}
        {.section mainImage}
                    <div class="color-overlay"></div>
        <figure class="content-fill main-image"><img {@|image-meta}></figure>
        {.end} 
        {.end}

        {.end}
于 2014-03-20T17:25:28.770 に答える