如何使用JSON+;中的许多不同数据文件更改forloop目标;劳工处处长包括 问题

如何使用JSON+;中的许多不同数据文件更改forloop目标;劳工处处长包括 问题,json,liquid,structured-data,jekyll-theme,Json,Liquid,Structured Data,Jekyll Theme,我有一个JSON+LD包含在头部,用于解析QA(问答)类型的文章页面。forloop目标在每个主题页上都会更改。我不知道如何通过变量forloop目标来匹配每个页面的数据文件,这样它就可以在带有QA(问答)的文章的通用json+ld脚本中循环数据 如果在“毒品犯罪”页面上,则将drug.yml文件循环拉入通用json+LD中,插入 如果在刑事犯罪页面上,则将crime.yml文件循环拉入通用json+LD,进入 我试过的 我现在意识到我不能在forloop中插入frontmatter变量。然而,

我有一个JSON+LD包含在头部,用于解析QA(问答)类型的文章页面。forloop目标在每个主题页上都会更改。我不知道如何通过变量forloop目标来匹配每个页面的数据文件,这样它就可以在带有QA(问答)的文章的通用json+ld脚本中循环数据

  • 如果在“毒品犯罪”页面上,则将drug.yml文件循环拉入通用json+LD中,插入
  • 如果在刑事犯罪页面上,则将crime.yml文件循环拉入通用json+LD,进入
  • 我试过的 我现在意识到我不能在forloop中插入frontmatter变量。然而,每个页面上的数据文件名都会更改,以在
    中呈现JSON+LD

    forloop在页面上工作,因为forloop目标yml是硬编码的。在每一页的首页上,我都有:
    pagefaq:xxxxx
    。因此,我必须能够告诉JSON+LD循环要填充哪个数据文件

    示例YML文件
    drug.yml

    - id: q1
      question: "What is Florida's Marijuana Possesion Law?"
      answer: "In Florida, possession of marijuana without a prescription is a criminal offense. Individuals found to have less than 20 grams on their person may be charged with a misdemeanor, while those found with 20 grams or more of marijuana may be charged with a felony. Medical patients are advised to always have their card and their prescription on them when transporting their medication."
    - id: q2
      question: "What is Florida's Oxycodone possesion law?"
      answer: "A prescription painkiller, oxycodone can be found in both OxyContin and Percocet. Individuals found to have less than 7 grams of oxycodone on their person without a prescription may be charged with a third-degree felony. Individuals found to have 7 grams or more may be charged with trafficking."
    - id: q3
      question: "What is Florida's Drug Possesion Law?"
      answer: "Drug possession laws aim to limit the possession and personal use of illegal substances. These controlled substances include both Schedule 1 drugs like heroin, LSD, meth, and ecstasy and even prescription drugs like oxycodone and fentanyl.
    
    
    It’s important to note that marijuana, though allowed for medical use, is still classified as a Schedule 1 drug at the federal level and considered an illegal substance. In Florida, Amendment 2, which was passed in November 2016, allows for the use and cultivation of medical marijuana for qualifying patients. The law does not allow everyone carte blanche access to marijuana. Rather, it requires that patients apply for a medical marijuana card and imposes purchasing and possession limits to ensure that medical marijuana is not abused.
    
    
    Outside of medical marijuana, one must have a prescription. If you are in possession of marijuana, you can be charged with a misdemeanor or even a felony, depending on the amount of marijuana you have in your possession."
    
    答案来自


    您可以像这样使用括号表示法:

    {% for data in site.data.faq.[page.pagefaq] %}
    
    {% for data in site.data.faq.[page.pagefaq] %}