Skip to content

Commit

Permalink
Remove app dir for buildTags (#1191)
Browse files Browse the repository at this point in the history
  • Loading branch information
garmeeh authored Apr 1, 2023
1 parent 6be0302 commit aca05ca
Show file tree
Hide file tree
Showing 7 changed files with 7,225 additions and 10,214 deletions.
4 changes: 2 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ const customJestConfig = {
// setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
// if using TypeScript with a baseUrl set to the root directory then you need the below for alias' to work
testRegex: '(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js|jsx)$',
modulePaths: ['.'],
moduleDirectories: ['node_modules', '.'],
modulePaths: ['<rootDir>'],
moduleDirectories: ['node_modules', '<rootDir>'],
moduleFileExtensions: ['ts', 'tsx', 'js'],
collectCoverageFrom: [
'src/**/*.{js,jsx,ts,tsx}',
Expand Down
21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,26 +71,27 @@
"@babel/preset-typescript": "^7.16.7",
"@cypress/schema-tools": "^4.7.9",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@types/jest": "^27.4.0",
"@testing-library/react": "^14.0.0",
"@types/jest": "^29.5.0",
"@types/node": "^18.11.7",
"@types/react": "^17.0.43",
"@types/react-dom": "^17.0.14",
"babel-jest": "^27.4.6",
"cypress": "^10.10.0",
"@types/react": "^18.0.31",
"@types/react-dom": "^18.0.11",
"babel-jest": "^29.5.0",
"cypress": "^12.9.0",
"cypress-testing-library": "^4.0.0",
"doctoc": "^2.1.0",
"husky": "4.3.8",
"jest": "^27.4.7",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"lint-staged": "11.1.1",
"microbundle": "^0.14.2",
"next": "^13.0.0",
"npm-run-all": "4.1.5",
"prettier": "2.5.1",
"prettier": "2.8.7",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"rimraf": "3.0.2",
"typescript": "^4.5.5"
"rimraf": "4.4.1",
"typescript": "^5.0.3"
},
"husky": {
"hooks": {
Expand Down
2 changes: 1 addition & 1 deletion src/jsonld/product.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export interface ProductJsonLdProps extends JsonLdProps {
purchaseDate?: string;
releaseDate?: string;
award?: string;
category?: string
category?: string;
}

function ProductJsonLd({
Expand Down
14 changes: 13 additions & 1 deletion src/meta/buildTags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -650,8 +650,20 @@ const buildTags = (config: BuildTagsParams) => {

if (config.additionalLinkTags?.length) {
config.additionalLinkTags.forEach(tag => {
const { crossOrigin: tagCrossOrigin, ...rest } = tag;
const crossOrigin: 'anonymous' | 'use-credentials' | '' | undefined =
tagCrossOrigin === 'anonymous' ||
tagCrossOrigin === 'use-credentials' ||
tagCrossOrigin === ''
? tagCrossOrigin
: undefined;

tagsToRender.push(
<link key={`link${tag.keyOverride ?? tag.href}${tag.rel}`} {...tag} />,
<link
key={`link${rest.keyOverride ?? rest.href}${rest.rel}`}
{...rest}
crossOrigin={crossOrigin}
/>,
);
});
}
Expand Down
59 changes: 18 additions & 41 deletions src/meta/nextSEO.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import buildTags from './buildTags';

import { NextSeoProps } from '../types';
import { WithHead } from './withHead';
Expand All @@ -21,49 +20,27 @@ export const NextSeo = ({
mobileAlternate,
languageAlternates,
additionalLinkTags,
useAppDir = false,
}: NextSeoProps) => {
return (
<>
{useAppDir ? (
buildTags({
title,
themeColor,
noindex,
nofollow,
robotsProps,
description,
canonical,
facebook,
openGraph,
additionalMetaTags,
twitter,
titleTemplate,
defaultTitle,
mobileAlternate,
languageAlternates,
additionalLinkTags,
})
) : (
<WithHead
title={title}
themeColor={themeColor}
noindex={noindex}
nofollow={nofollow}
robotsProps={robotsProps}
description={description}
canonical={canonical}
facebook={facebook}
openGraph={openGraph}
additionalMetaTags={additionalMetaTags}
twitter={twitter}
titleTemplate={titleTemplate}
defaultTitle={defaultTitle}
mobileAlternate={mobileAlternate}
languageAlternates={languageAlternates}
additionalLinkTags={additionalLinkTags}
/>
)}
<WithHead
title={title}
themeColor={themeColor}
noindex={noindex}
nofollow={nofollow}
robotsProps={robotsProps}
description={description}
canonical={canonical}
facebook={facebook}
openGraph={openGraph}
additionalMetaTags={additionalMetaTags}
twitter={twitter}
titleTemplate={titleTemplate}
defaultTitle={defaultTitle}
mobileAlternate={mobileAlternate}
languageAlternates={languageAlternates}
additionalLinkTags={additionalLinkTags}
/>
</>
);
};
14 changes: 9 additions & 5 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,16 +305,21 @@ interface LanguageAlternate {
href: string;
}

interface LinkTag {
export interface LinkTag {
rel: string;
href: string;
sizes?: string;
hrefLang?: string;
media?: string;
sizes?: string;
type?: string;
color?: string;
keyOverride?: string;
as?: string;
crossOrigin?: string;
imagesrcset?: string;
imagesizes?: string;
referrerpolicy?: string;
integrity?: string;
keyOverride?: string;
color?: string;
}

export interface BaseMetaTag {
Expand Down Expand Up @@ -466,7 +471,6 @@ export interface NextSeoProps {
additionalMetaTags?: ReadonlyArray<MetaTag>;
additionalLinkTags?: ReadonlyArray<LinkTag>;
children?: never;
useAppDir?: boolean;
}

export interface DefaultSeoProps {
Expand Down
Loading

0 comments on commit aca05ca

Please sign in to comment.