Skip to content

Commit

Permalink
fix: seo with yoast disabled (#820)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasio authored Jul 23, 2024
1 parent e969f38 commit c73d000
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .changeset/young-planes-jog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@headstartwp/core": patch
"@headstartwp/next": patch
---

Fix: SEO with yoast disabled
11 changes: 5 additions & 6 deletions packages/next/src/rsc/data/seo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ const { all: merge } = deepmerge;

function isPostEntity(data: Entity | QueriedObject): data is PostEntity {
return (
typeof (data as PostEntity).yoast_head !== 'undefined' &&
typeof (data as PostEntity).yoast_head_json !== 'undefined' &&
typeof (data as PostEntity).title !== 'undefined'
typeof (data as PostEntity).title !== 'undefined' &&
typeof (data as PostEntity).type !== 'undefined'
);
}

Expand Down Expand Up @@ -67,7 +66,7 @@ function getMetadataForPostEntity(post: PostEntity, config: HeadlessConfig): Met
return {
title: post.title.rendered,
alternates: {
canonical: convertUrl(post.link, hostUrl, sourceUrl),
canonical: post.link ? convertUrl(post.link, hostUrl, sourceUrl) : undefined,
},
};
}
Expand All @@ -78,7 +77,7 @@ function getMetadataForAuthorEntity(author: AuthorEntity, config: HeadlessConfig
return {
title: `${author.name} Archives`,
alternates: {
canonical: convertUrl(author.url, hostUrl, sourceUrl),
canonical: author.link ? convertUrl(author.link, hostUrl, sourceUrl) : undefined,
},
};
}
Expand All @@ -96,7 +95,7 @@ function getMetatadataForTermEntity(term: TermEntity, config: HeadlessConfig): M
return {
title: `${term.name} Archives`,
alternates: {
canonical: convertUrl(term.link, hostUrl, sourceUrl),
canonical: term.link ? convertUrl(term.link, hostUrl, sourceUrl) : undefined,
},
};
}
Expand Down

0 comments on commit c73d000

Please sign in to comment.