Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #103 from zarathustra323/content-redirect-to
Browse files Browse the repository at this point in the history
Use `mutations.Website.redirectTo` in `redirectTo` resolver
  • Loading branch information
zarathustra323 authored Jun 10, 2021
2 parents f1ad20b + 4c4b1e0 commit d68cf98
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ interface Content @requiresProject(fields: ["type"]) {
siteContext(input: ContentSiteContextInput = {}): ContentSiteContext! @projection(localField: "_id", needs: ["type", "linkUrl", "mutations.Website.slug", "mutations.Website.primarySection", "mutations.Website.primaryCategory", "mutations.Website.alias", "mutations.Website.canonicalUrl", "mutations.Website.noIndex"])
# Determines if this content item should redirect to another location.
redirectTo: String @projection(localField: "type", needs: ["linkUrl"])
redirectTo: String @projection(localField: "type", needs: ["linkUrl", "mutations.Website.redirectTo"])
# Returns related, published content based on input flags
relatedContent(input: ContentRelatedContentInput = {}): ContentConnection! @projection(localField: "_id", needs: ["relatedTo", "mutations.Website.primarySection"])
userRegistration: ContentUserRegistration! @projection(localField: "mutations.Website.requiresAccessLevels", needs: ["mutations.Website.requiresRegistration"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,8 @@ module.exports = {

redirectTo: (content) => {
const { type, linkUrl } = content;
const redirectTo = get(content, 'mutations.Website.redirectTo');
if (redirectTo) return redirectTo;

const types = ['Promotion', 'TextAd'];
if (!types.includes(type)) return null;
Expand Down

0 comments on commit d68cf98

Please sign in to comment.