ashhitch/wp-graphql-yoast-seo

使用wp-graphql查询Yoast SEO数据

安装量: 123,356

依赖项: 0

建议者: 0

安全性: 0

星星: 221

关注者: 9

分支: 49

开放问题: 23

类型:wordpress-plugin

v4.22.5 2023-06-30 20:18 UTC

README

Latest Stable Version Total Downloads Monthly Downloads

WPGraphQl Yoast SEO Plugin

请注意,Yoast插件的第14版是一个重大更新。

如果你卡在Yoast V14之前的版本,请使用此插件的v3。

这是WPGraphQL插件(https://github.com/wp-graphql/wp-graphql)的一个扩展,它返回Yoast SEO数据。

使用此插件吗?我很想看到你用它做了什么。😃 @ash_hitchcock

当前返回以下SEO数据

  • 页面
  • 文章
  • 自定义文章类型
  • 产品(WooCommerce)
  • 分类
  • 自定义分类法
  • WooCommerce产品
  • Yoast配置
    • 网站管理员验证
    • 社交档案
    • 方案
    • 面包屑

如果有任何Yoast数据目前没有返回,请提出一个问题,以便我们可以将其添加到路线图。

快速安装

  • WordPress插件目录安装
  • 将此存储库的zip文件克隆或下载到您的WordPress插件目录中,并激活“WP GraphQL Yoast SEO”插件
  • 安装并激活WPGraphQL

Composer

composer require ashhitch/wp-graphql-yoast-seo

觉得这个有用吗?

Buy Me A Coffee

规范

请注意,如果您在WordPress设置中将“阻止搜索引擎”选项打开,则规范将不会返回。

V4重大更改

插件现在至少需要Yoast 14.0.0

V3重大更改

图片URL现在返回为mediaItem类型。

这适用于twitterImageopengraphImage

与Gatsby一起使用

查看配套的Gatsby插件,轻松添加元数据和JSON LD方案。

用法

要查询Yoast数据,只需将seo对象添加到您的查询中

文章类型数据

query GetPages {
    pages(first: 10) {
        edges {
            node {
                id
                title
                seo {
                    canonical
                    title
                    metaDesc
                    focuskw
                    metaRobotsNoindex
                    metaRobotsNofollow
                    opengraphAuthor
                    opengraphDescription
                    opengraphTitle
                    opengraphDescription
                    opengraphImage {
                        altText
                        sourceUrl
                        srcSet
                    }
                    opengraphUrl
                    opengraphSiteName
                    opengraphPublishedTime
                    opengraphModifiedTime
                    twitterTitle
                    twitterDescription
                    twitterImage {
                        altText
                        sourceUrl
                        srcSet
                    }
                    breadcrumbs {
                        url
                        text
                    }
                    cornerstone
                    schema {
                        pageType
                        articleType
                        raw
                    }
                    readingTime
                    fullHead
                }
                author {
                    node {
                        seo {
                            metaDesc
                            metaRobotsNofollow
                            metaRobotsNoindex
                            title
                            social {
                                youTube
                                wikipedia
                                twitter
                                soundCloud
                                pinterest
                                mySpace
                                linkedIn
                                instagram
                                facebook
                            }
                        }
                    }
                }
            }
        }
    }
}

文章分类法数据

query GetCategories {
    categories(first: 10) {
        edges {
            node {
                id
                seo {
                    fullHead
                    canonical
                    title
                    metaDesc
                    focuskw
                    metaRobotsNoindex
                    metaRobotsNofollow
                    opengraphAuthor
                    opengraphDescription
                    opengraphTitle
                    opengraphDescription
                    opengraphImage {
                        altText
                        sourceUrl
                        srcSet
                    }
                    twitterTitle
                    twitterDescription
                    twitterImage {
                        altText
                        sourceUrl
                        srcSet
                    }
                    breadcrumbs {
                        url
                        text
                    }
                }
                name
            }
        }
    }
}

用户数据

query GetUsers {
    users {
        nodes {
            seo {
                metaDesc
                metaRobotsNofollow
                metaRobotsNoindex
                title
                fullHead
                social {
                    youTube
                    wikipedia
                    twitter
                    soundCloud
                    pinterest
                    mySpace
                    linkedIn
                    instagram
                    facebook
                }
            }
        }
    }
}

边缘和页面信息数据

query GetPostsWithIsPrimary {
    posts {
        pageInfo {
            startCursor
            seo {
                schema {
                    raw
                }
            }
        }
        nodes {
            title
            slug
            categories {
                edges {
                    isPrimary
                    node {
                        name
                        count
                    }
                }
            }
        }
    }
}

Yoast配置数据

query GetSeoConfig {
    seo {
        meta {
            author {
                description
                title
            }
            date {
                description
                title
            }
            config {
                separator
            }
            homepage {
                description
                title
            }
            notFound {
                breadcrumb
                title
            }
        }
        webmaster {
            googleVerify
            yandexVerify
            msVerify
            baiduVerify
        }
        schema {
            siteName
            wordpressSiteName
            siteUrl
            inLanguage
            companyName
            companyOrPerson
            companyLogo {
                mediaItemUrl
            }
            logo {
                mediaItemUrl
            }
            personLogo {
                mediaItemUrl
            }
        }
        breadcrumbs {
            showBlogPage
            separator
            searchPrefix
            prefix
            homeText
            enabled
            boldLast
            archivePrefix
            notFoundText
        }
        social {
            facebook {
                url
                defaultImage {
                    mediaItemUrl
                }
            }
            instagram {
                url
            }
            linkedIn {
                url
            }
            mySpace {
                url
            }
            pinterest {
                url
                metaTag
            }
            twitter {
                cardType
                username
            }
            wikipedia {
                url
            }
            youTube {
                url
            }
            otherSocials
        }
        openGraph {
            frontPage {
                title
                description
                image {
                    altText
                    sourceUrl
                    mediaItemUrl
                }
            }
            defaultImage {
                altText
                sourceUrl
                mediaItemUrl
            }
        }
        contentTypes {
            post {
                title
                schemaType
                metaRobotsNoindex
                metaDesc
                schema {
                    raw
                }

                archive {
                    fullHead
                    archiveLink
                    breadcrumbTitle
                    hasArchive
                    metaDesc
                    metaRobotsNoindex
                    title
                }
            }
            page {
                metaDesc
                metaRobotsNoindex
                schemaType
                title
                schema {
                    raw
                }
            }
        }
        redirects {
            origin
            target
            format
            type
        }
    }
}

contentNode和nodeByUri

contentNode(id: "1", idType: DATABASE_ID) {
    id
    contentTypeName
    seo {
      title
      metaDesc
    }
  }
  node(id: "cG9zdDox",) {
    ... on NodeWithTitle {
      seo {
        title
        metaDesc
      }
    }

  }
  nodeByUri(uri: "/") {
    ... on NodeWithTitle {
      seo {
        title
        metaDesc
      }
    }
  }

支持

打开一个问题

Twitter: @ash_hitchcock

请注意:Yoast、WPGraphQL及其标志均为其各自所有者的版权。