使用 graphql 查询反应结构化数据

React Structured Data with graphql query

有没有人试过在 React 项目中实现这个? github/npm 网站上的文档不多。当我尝试注入数据时,是否有特定的方法来添加 graphql 数据?

JSX:

<JSONLD>
  <Generic jsonldtype="event" schema={{
    name: "${adv_event.title}", 
    description: "${adv_event.body}",
    startDate: "YYYY-MM-DDT:HH:MM",
    endDate: "YYYY-MM-DDT:HH:MM",
    image: "",
  }}>
    <Generic type="location" jsonldtype="Place" schema={{ name: "test", }}/>
  </Generic>       
</JSONLD>

我尝试过的:

name: "${adv_event.title}", 

name: "`${adv_event.title}`", 

name: {adv_event.title}, 

我本来打算删除 post 但是,如果以后有其他人在寻找这个问题:

答案是

name: `${adv_event.title}`,