2017-08-11 2 views
0

私はJSON-LDスクリプトの内容を動的に保ちたいと思います。しかし、AMPは私にJavascriptを使用させることは許されず、スクリプトは頭の中にあるべきです。
アンプリストのため、身体の内容をダイナミックに保つことは問題ではありません。AMP JSON-LD動的コンテンツ

<head> 
    <script type="application/ld+json"> 
    { 
    "@context": "http://schema.org", 
    "@type": "NewsArticle", 
    "mainEntityOfPage": { 
     "@type": "WebPage", 
     "@id": "www.google.com" 
    }, 
    "headline": "???" 
    } 
    </script> 
</head> 
<body> 
    <amp-list layout="fixed-height" height="100vh" width="auto" src="www.google.com/json" class="m1"> 
      <template type="amp-mustache" id="amp-template-id"> 
       <p>{{title}}</p> 
      </template> 
    </amp-list> 
</body> 

記事のタイトルは、{{}}を使用してamp-listタグ内でアクセスできます。ヘッドラインの値としてヘッドのjson-ldにこの値が必要です。これを行う方法に関する提案はありますか?

答えて

0

JSON-LDではなくMicrodataを使用してドキュメントにマークを付けることができます。この方法では、メタデータは、あなたのコンテンツにインライン化されるだろうとアンペア・リストを介して生成することができます。

<amp-list layout="fixed-height" height="100vh" width="auto" src="www.google.com/json" class="m1"> 
    <template type="amp-mustache" id="amp-template-id"> 
    <h1 itemprop="headline">{{title}}</h1> 
    <h2 itemprop="author" itemscope itemtype="https://schema.org/Person"> 
     <span itemprop="name">{{author}}</span> 
    </h2> 
    ... 
    </template> 
</amp-list> 

Hereは、フルミクロサンプルです。

+0

これは解決策です。しかし、私はJSON-LDを好むだろう。それで動作させる方法はありませんか? –

+0

いいえありません。 –

関連する問題