【发布时间】:2020-11-19 05:04:10
【问题描述】:
我正在编写有关 Gatsby JS 的博客,但我遇到了超链接问题,我无法解决。
我有以下问题
const options = {
renderNode: {
"embedded-asset-block": (node) => {
const alt = node.data.target.fields.title['es']
const url = node.data.target.fields.file['es'].url
return <img alt={alt} src={url} />
},
[INLINES.HYPERLINK]: (node) => {
if(node.data.uri.indexOf('youtube.com') !== -1){
return(
<iframe width="560" height="315" src={node.data.uri} frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
)
}else{
return(
<a href={node.data.uri}>{node.content.value}</a>
)
}
}
}
}
通过此查询,我可以添加资产和 youtube 视频。问题是,当我添加超链接时,它们会显示在页面上但没有文字。
我只看到<a href="https://www.test.es"></a> 而不是这个链接的文字。
我知道问题出在<a href={node.data.uri}>{node.content.value}</a>,但我无法查询该值。
这是 GraphQL:
"body": {
"json": {
"nodeType": "document",
"data": {},
"content": [
{
"nodeType": "paragraph",
"content": [
{
"nodeType": "text",
"value": "Desde ",
"marks": [],
"data": {}
},
{
"nodeType": "hyperlink",
"content": [
{
"nodeType": "text",
"value": "FelixDigital",
"marks": [],
"data": {}
}
我需要查询值(FelixDigital)
有人可以帮我吗?
非常感谢,
【问题讨论】: