Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove keyoverride attribute from additional link tags #1473

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ If you are using **`pages`** directory then `NextSeo` is **exactly what you need
- [dangerouslySetAllPagesToNoFollow](#dangerouslysetallpagestonofollow)
- [robotsProps](#robotsprops)
- [Twitter](#twitter)
- [facebook](#facebook)
- [Facebook](#facebook)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably changes by doctoc

- [Canonical URL](#canonical-url)
- [Alternate](#alternate)
- [Additional Meta Tags](#additional-meta-tags)
Expand Down
34 changes: 34 additions & 0 deletions src/meta/__tests__/buildTags.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -976,3 +976,37 @@ it('correctly read all robots props', () => {
expect(Array.from(content).length).toBe(0);
expect(Array.from(contentOverride).length).toBe(1);
});

it('additional link tags are set', () => {
const overrideProps: BuildTagsParams = {
...SEO,
additionalLinkTags: [
{
rel: 'apple-touch-icon',
href: 'https://www.test.ie/touch-icon-ipad.jpg',
sizes: '76x76',
keyOverride: '76x76',
},
{
rel: 'apple-touch-icon',
href: 'https://www.test.ie/touch-icon-ipad.jpg',
sizes: '120x120',
keyOverride: '120x120',
},
{
rel: 'icon',
href: 'https://www.test.ie/favicon.ico',
},
],
};
const tags = buildTags(overrideProps);
const { container } = render(<>{React.Children.toArray(tags)}</>);
const appleTouchIconTags = container.querySelectorAll(
'link[rel="apple-touch-icon"]',
);
expect(Array.from(appleTouchIconTags).length).toBe(2);
expect(appleTouchIconTags[0]).not.toHaveAttribute('keyoverride');

const iconTags = container.querySelectorAll('link[rel="icon"]');
expect(Array.from(iconTags).length).toBe(1);
});
4 changes: 2 additions & 2 deletions src/meta/buildTags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ const buildTags = (config: BuildTagsParams) => {

if (config.additionalLinkTags?.length) {
config.additionalLinkTags.forEach(tag => {
const { crossOrigin: tagCrossOrigin, ...rest } = tag;
const { crossOrigin: tagCrossOrigin, keyOverride, ...rest } = tag;
const crossOrigin: 'anonymous' | 'use-credentials' | '' | undefined =
tagCrossOrigin === 'anonymous' ||
tagCrossOrigin === 'use-credentials' ||
Expand All @@ -669,7 +669,7 @@ const buildTags = (config: BuildTagsParams) => {

tagsToRender.push(
<link
key={`link${rest.keyOverride ?? rest.href}${rest.rel}`}
key={`link${keyOverride ?? rest.href}${rest.rel}`}
{...rest}
crossOrigin={crossOrigin}
/>,
Expand Down