Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 无法从Gatsby JS上的GraphQL查询超链接_Reactjs_Graphql_Gatsby - Fatal编程技术网

Reactjs 无法从Gatsby JS上的GraphQL查询超链接

Reactjs 无法从Gatsby JS上的GraphQL查询超链接,reactjs,graphql,gatsby,Reactjs,Graphql,Gatsby,我正在写一个关于盖茨比JS的博客,我遇到了一个关于超链接的问题,我无法解决它 我有以下疑问 const options = { renderNode: { "embedded-asset-block": (node) => { const alt = node.data.target.fields.title['es'] const url = node.data.t

我正在写一个关于盖茨比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>
                    )
                }
            }
        }
    }
我需要查询值(FelixDigital)

有人能帮我吗


非常感谢,

您能在这段代码中执行调试器吗


很难说。。但是我要检查的是
节点的值。在我看来,内容似乎是一个数组,在数组的第一项中,你有值,因此在我看来,它应该更像是
节点。内容[0]。值

我猜你是在使用Contentful,使用GraphQL将数据拉入你的博客。对于Contentful,必须在JSON节点(所有富文本项)上使用documentToReactComponents。要获得FelixDigital,您可能需要执行以下操作:

import { documentToReactComponents } from '@contentful/rich-text-react-renderer';


return(
        <div>
           {documentToReactComponents(videos.videoItem.videoLinks.json, options)}
         </div>
    )
从'@contentful/rich text react renderer'导入{documentToReactComponents};
返回(
{documentoreactcomponents(videos.videoItem.videoLinks.json,选项)}
)
然后,这将使用您在
const options
中设置的iframe并获取src uri

有关更多信息,请访问

import { documentToReactComponents } from '@contentful/rich-text-react-renderer';


return(
        <div>
           {documentToReactComponents(videos.videoItem.videoLinks.json, options)}
         </div>
    )