seo - 在 AEM 中,我想在 &lt;script&gt;&lt;/script&gt; 标签内添加 <sly></sly> 标签。模式内的多字段选项

标签 seo aem json-ld sightly

所以我正在构建一个多字段创作选项。如果需要,发布者可以添加值并创建更多文本字段。但问题是添加 <sly> <script> 内的标签标签给我带来了问题。例如:

<sly data-sly-use.FAQschemaObject="${'../../../clientlibs/clientlib-base/js/collection/multi-collection.js' @ resourcePath = resource.path , multifieldName='FAQschemas'}"> </sly>

    <script type="application/ld+json">
<sly data-sly-list.FAQschema="${FAQschemaObject}" data-sly-unwrap>
{
"@context": "https://schema.org",
"@type": "FAQPage",
"mainEntity": [{
"@type": "Question",
"name": "${FAQschema.properties.question @ context = "html"}",
"acceptedAnswer": {
"@type": "Answer",
"text": "${FAQschema.properties.answer @ context = "html"}"
}
}]
            }
</script>
</sly>
因此,如您所见,我只想在填充值时显示此脚本。如果他们愿意,还可以让作者选择添加更多问题和答案值。我正在尝试实现谷歌提供的常见问题解答模式。 https://developers.google.com/search/docs/data-types/faqpage
因此,我想实现类似 googles 示例的内容:
<script type="application/ld+json">
    {
      "@context": "https://schema.org",
      "@type": "FAQPage",
      "mainEntity": [{
        "@type": "Question",
        "name": "What is the return policy?",
        "acceptedAnswer": {
          "@type": "Answer",
          "text": "Most unopened items in new condition and returned within <strong>90 days</strong> will receive a refund or exchange. Some items have a modified return policy noted on the receipt or packing slip. Items that are opened or damaged or do not have a receipt may be denied a refund or exchange. Items purchased online or in-store may be returned to any store.<br /><p>Online purchases may be returned via a major parcel carrier. <a href=http://example.com/returns> Click here </a> to initiate a return.</p>"
        }
      }, {
        "@type": "Question",
        "name": "How long does it take to process a refund?",
        "acceptedAnswer": {
          "@type": "Answer",
          "text": "We will reimburse you for returned items in the same way you paid for them. For example, any amounts deducted from a gift card will be credited back to a gift card. For returns by mail, once we receive your return, we will process it within 4–5 business days. It may take up to 7 days after we process the return to reflect in your account, depending on your financial institution's processing time."
        }
      }, {
        "@type": "Question",
        "name": "What is the policy for late/non-delivery of items ordered online?",
        "acceptedAnswer": {
          "@type": "Answer",
          "text": "Our local teams work diligently to make sure that your order arrives on time, within our normaldelivery hours of 9AM to 8PM in the recipient's time zone. During  busy holiday periods like Christmas, Valentine's and Mother's Day, we may extend our delivery hours before 9AM and after 8PM to ensure that all gifts are delivered on time. If for any reason your gift does not arrive on time, our dedicated Customer Service agents will do everything they can to help successfully resolve your issue. <br/> <p><a href=https://example.com/orders/>Click here</a> to complete the form with your order-related question(s).</p>"
        }
      }, {
        "@type": "Question",
        "name": "When will my credit card be charged?",
        "acceptedAnswer": {
          "@type": "Answer",
          "text": "We'll attempt to securely charge your credit card at the point of purchase online. If there's a problem, you'll be notified on the spot and prompted to use another card. Once we receive verification of sufficient funds, your payment will be completed and transferred securely to us. Your account will be charged in 24 to 48 hours."
        }
      }, {
        "@type": "Question",
        "name": "Will I be charged sales tax for online orders?",
        "acceptedAnswer": {
          "@type": "Answer",
          "text":"Local and State sales tax will be collected if your recipient's mailing address is in: <ul><li>Arizona</li><li>California</li><li>Colorado</li></ul>"}
        }]
    }
    </script>
作者可以通过添加新值来创建新字段,但保持以下结构。任何工作示例?

最佳答案

解决此问题的一种变通方法是将您需要包含在脚本标记中的所有代码放入其自己的 HTML 文件中,并将其包含在脚本标记中。有了这个,它应该被很好地捡起来。

<script data-sly-include='read-multifield-partial.html'></script>
或者
在 Sling 模型或使用 JS 中创建此 JSON,然后直接将其转储,而不是直接循环并构建它。

关于seo - 在 AEM 中,我想在 &lt;script&gt;&lt;/script&gt; 标签内添加 <sly></sly> 标签。模式内的多字段选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65835110/

相关文章:

php - CodeIgniter 中的 Seo 友好 url

javascript - 如何将 Material Design 组件添加到 Adob​​e Experience Manager

schema.org - 谷歌 "The full body of the article"是什么意思

javascript - application/ld+json与javascript数据交换

html - 我可以使用 http ://schema. org/Organization 的多个实例吗?

url - URL 中的 SEO 策略唯一 ID

github - 在 GitHub README 中添加元标记是否使其更易于搜索

java - org.apache.commons.mail,version=[1.3,2) -- 无法解决 CQ5(AEM) 中的问题

aem - 如何向 htmlparser 生成器添加其他元素

JSON-LD: 'Syntax error: value, object or array expected.'