Skip to content

Commit

Permalink
Revert "Fix default robots overriding" (#1193)
Browse files Browse the repository at this point in the history
  • Loading branch information
garmeeh authored Apr 1, 2023
1 parent db70100 commit 6be0302
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/meta/__tests__/buildTags.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ it('correctly sets nofollow default', () => {
'meta[content="index,follow"]',
);
const noindexnofollow = container.querySelectorAll(
'meta[content="index,nofollow"]',
'meta[content="noindex,nofollow"]',
);

expect(Array.from(indexfollow).length).toBe(0);
Expand All @@ -945,8 +945,8 @@ it('correctly read noindex & nofollow false', () => {
'meta[content="noindex,nofollow"]',
);

expect(Array.from(indexfollow).length).toBe(1);
expect(Array.from(noindexnofollow).length).toBe(0);
expect(Array.from(indexfollow).length).toBe(0);
expect(Array.from(noindexnofollow).length).toBe(1);
});

it('correctly read all robots props', () => {
Expand Down
19 changes: 13 additions & 6 deletions src/meta/buildTags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@ const buildTags = (config: BuildTagsParams) => {
}

const noindex =
config.noindex != null
? config.noindex
: config.dangerouslySetAllPagesToNoIndex || defaults.noindex;
config.noindex ||
defaults.noindex ||
config.dangerouslySetAllPagesToNoIndex;
const nofollow =
config.nofollow != null
? config.nofollow
: config.dangerouslySetAllPagesToNoFollow || defaults.nofollow;
config.nofollow ||
defaults.nofollow ||
config.dangerouslySetAllPagesToNoFollow;

let robotsParams = '';
if (config.robotsProps) {
Expand All @@ -152,6 +152,13 @@ const buildTags = (config: BuildTagsParams) => {
}

if (noindex || nofollow) {
if (config.dangerouslySetAllPagesToNoIndex) {
defaults.noindex = true;
}
if (config.dangerouslySetAllPagesToNoFollow) {
defaults.nofollow = true;
}

tagsToRender.push(
<meta
key="robots"
Expand Down

0 comments on commit 6be0302

Please sign in to comment.