diff --git a/src/meta/__tests__/buildTags.spec.tsx b/src/meta/__tests__/buildTags.spec.tsx index 3ecca75b..49228967 100644 --- a/src/meta/__tests__/buildTags.spec.tsx +++ b/src/meta/__tests__/buildTags.spec.tsx @@ -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); @@ -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', () => { diff --git a/src/meta/buildTags.tsx b/src/meta/buildTags.tsx index 0c7065af..0560ea10 100644 --- a/src/meta/buildTags.tsx +++ b/src/meta/buildTags.tsx @@ -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) { @@ -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(