플러그인 데이터 쿼리Slim SEO
Slim SEO
Slim SEO 플러그인의 데이터를 다루는 쿼리 예시입니다.
SEO 메타데이터 가져오기
메타 필드를 사용하여 SEO 메타데이터를 쿼리할 수 있습니다:
query GetPost($postId: ID!) {
post(by: { id: $postId }) {
id
title
slimSeoMeta: metaValue(key: "slim_seo")
metaTitle: _objectProperty(object: $__slimSeoMeta, by: { key: "title" }, failIfNonExistingKeyOrPath: false)
metaDesc: _objectProperty(object: $__slimSeoMeta, by: { key: "description" }, failIfNonExistingKeyOrPath: false)
fbImage: _objectProperty(object: $__slimSeoMeta, by: { key: "facebook_image" }, failIfNonExistingKeyOrPath: false)
twitterImage: _objectProperty(object: $__slimSeoMeta, by: { key: "twitter_image" }, failIfNonExistingKeyOrPath: false)
canonical: _objectProperty(object: $__slimSeoMeta, by: { key: "canonical" }, failIfNonExistingKeyOrPath: false)
}
}SEO 메타데이터 업데이트
메타 뮤테이션을 사용하여 SEO 메타데이터를 업데이트할 수 있습니다:
mutation UpdatePost($postId: ID!) {
updateCustomPostMetas(inputs: [
{
id: $postId,
key: "slim_seo",
value: {
title: "New title",
description: "New description",
facebook_image: "https://example.com/social-image.jpg",
twitter_image: "https://example.com/social-image.jpg",
canonical: "https://example.com/canonical-url"
}
}
]) {
status
errors {
__typename
...on ErrorPayload {
message
}
}
customPost {
__typename
id
slimSeoMeta: metaValue(key: "slim_seo")
metaTitle: _objectProperty(object: $__slimSeoMeta, by: { key: "title" }, failIfNonExistingKeyOrPath: false)
metaDesc: _objectProperty(object: $__slimSeoMeta, by: { key: "description" }, failIfNonExistingKeyOrPath: false)
fbImage: _objectProperty(object: $__slimSeoMeta, by: { key: "facebook_image" }, failIfNonExistingKeyOrPath: false)
twitterImage: _objectProperty(object: $__slimSeoMeta, by: { key: "twitter_image" }, failIfNonExistingKeyOrPath: false)
canonical: _objectProperty(object: $__slimSeoMeta, by: { key: "canonical" }, failIfNonExistingKeyOrPath: false)
}
}
}Prev