Query 库将所有文章中的旧文章别名替换为新文章别名
将所有文章中的旧文章别名替换为新文章别名
更改文章别名后,执行此 query 将所有内容转换为指向新 URL。
此 query 要求端点启用嵌套 Mutation。
query ExportData(
$oldPostSlug: String!
$newPostSlug: String!
) {
siteURL: optionValue(name: "siteurl")
oldPostURL: _strAppend(
after: $__siteURL,
append: $oldPostSlug
) @export(as: "oldPostURL")
newPostURL: _strAppend(
after: $__siteURL,
append: $newPostSlug
) @export(as: "newPostURL")
}
mutation ReplaceOldWithNewSlugInPosts
@depends(on: "ExportData")
{
posts(
filter: {
search: $oldPostURL
},
pagination: {
limit: -1
}
) {
id
rawContent
adaptedRawContent: _strReplace(
search: $oldPostURL
replaceWith: $newPostURL
in: $__rawContent
)
update(input: {
contentAs: { html: $__adaptedRawContent }
}) {
status
errors {
__typename
...on ErrorPayload {
message
}
}
post {
id
rawContent
}
}
}
}