forked from vercel/turborepo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
partially support next metadata (vercel#3464)
This adds support for metadata in pages and layouts. Full metadata support also needs support for implicit metadata with files named `icon.ico` etc. This PR also improves the test suite and adds a basic test case for app dir support
- Loading branch information
Showing
28 changed files
with
359 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
crates/next-dev-tests/tests/integration/next/app/basic/app/layout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default function RootLayout({ children }: { children: any }) { | ||
return ( | ||
<html> | ||
<body>{children}</body> | ||
</html> | ||
); | ||
} |
9 changes: 9 additions & 0 deletions
9
crates/next-dev-tests/tests/integration/next/app/basic/app/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Test from "./test"; | ||
|
||
export default function Page() { | ||
return ( | ||
<div> | ||
<Test /> | ||
</div> | ||
); | ||
} |
12 changes: 12 additions & 0 deletions
12
crates/next-dev-tests/tests/integration/next/app/basic/app/test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
"use client"; | ||
|
||
import { useEffect } from "react"; | ||
|
||
export default function Test() { | ||
useEffect(() => { | ||
import("@turbo/pack-test-harness").then(() => { | ||
it("should run", () => {}); | ||
}); | ||
return () => {}; | ||
}, []); | ||
} |
5 changes: 5 additions & 0 deletions
5
crates/next-dev-tests/tests/integration/next/app/basic/next.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
experimental: { | ||
appDir: true, | ||
}, | ||
}; |
17 changes: 17 additions & 0 deletions
17
crates/next-dev-tests/tests/integration/next/app/metadata/app/layout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export default function RootLayout({ children }: { children: any }) { | ||
return ( | ||
<html> | ||
<body>{children}</body> | ||
</html> | ||
); | ||
} | ||
|
||
export const metadata = { | ||
icons: { | ||
icon: new URL("./triangle-black.png", import.meta.url).pathname, | ||
}, | ||
title: { | ||
absolute: "RootLayout absolute", | ||
template: "%s - RootLayout", | ||
}, | ||
}; |
19 changes: 19 additions & 0 deletions
19
crates/next-dev-tests/tests/integration/next/app/metadata/app/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import type React from "react"; | ||
import Test from "./test"; | ||
|
||
export default function Page(): React.ReactElement { | ||
return ( | ||
<div> | ||
<Test /> | ||
</div> | ||
); | ||
} | ||
|
||
export async function generateMetadata({ params }) { | ||
return { | ||
title: "Page", | ||
openGraph: { | ||
images: new URL("./triangle-black.png", import.meta.url).pathname, | ||
}, | ||
}; | ||
} |
22 changes: 22 additions & 0 deletions
22
crates/next-dev-tests/tests/integration/next/app/metadata/app/test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
"use client"; | ||
|
||
import type React from "react"; | ||
import { useEffect } from "react"; | ||
|
||
export default function Test(): React.ReactElement | null { | ||
useEffect(() => { | ||
import("@turbo/pack-test-harness").then(() => { | ||
it("should have the correct title set", () => { | ||
expect(document.title).toBe("Page - RootLayout"); | ||
let iconMeta = document.querySelector("link[rel=icon]"); | ||
expect(iconMeta).toHaveProperty("href"); | ||
expect(iconMeta.href).toMatch(/\/_next\/static\/assets/); | ||
let ogImageMeta = document.querySelector("meta[property='og:image']"); | ||
expect(ogImageMeta).toHaveProperty("content"); | ||
expect(ogImageMeta.content).toMatch(/\/_next\/static\/assets/); | ||
}); | ||
}); | ||
return () => {}; | ||
}, []); | ||
return null; | ||
} |
Binary file added
BIN
+4.19 KB
crates/next-dev-tests/tests/integration/next/app/metadata/app/triangle-black.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions
5
crates/next-dev-tests/tests/integration/next/app/metadata/next-env.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/// <reference types="next" /> | ||
/// <reference types="next/image-types/global" /> | ||
|
||
// NOTE: This file should not be edited | ||
// see https://nextjs.org/docs/basic-features/typescript for more information. |
5 changes: 5 additions & 0 deletions
5
crates/next-dev-tests/tests/integration/next/app/metadata/next.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
experimental: { | ||
appDir: true, | ||
}, | ||
}; |
26 changes: 26 additions & 0 deletions
26
crates/next-dev-tests/tests/integration/next/app/metadata/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"lib": ["dom", "dom.iterable", "esnext"], | ||
"allowJs": true, | ||
"skipLibCheck": true, | ||
"strict": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"noEmit": true, | ||
"esModuleInterop": true, | ||
"module": "esnext", | ||
"moduleResolution": "node", | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"jsx": "preserve", | ||
"incremental": true, | ||
"baseUrl": ".", | ||
"plugins": [ | ||
{ | ||
"name": "next" | ||
} | ||
] | ||
}, | ||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], | ||
"exclude": ["node_modules"] | ||
} |
Oops, something went wrong.