Skip to content

Commit

Permalink
Merge pull request #528 from iamvishnusankar/next-13/generate-static-…
Browse files Browse the repository at this point in the history
…params

[Example] Added app-dir example
  • Loading branch information
iamvishnusankar committed Nov 16, 2022
2 parents 41e25b8 + ab88f18 commit 13d44a2
Show file tree
Hide file tree
Showing 11 changed files with 131 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .eslintrc
@@ -1,3 +1,6 @@
{
"extends": "@corex"
"extends": "@corex",
"rules": {
"react/react-in-jsx-scope": "off"
}
}
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
node: ['17', '16', '14.18']
node: ['16', '17', '18', '19']
runs-on: ${{ matrix.platform }}
steps:
- name: Github Checkout
Expand Down
4 changes: 4 additions & 0 deletions examples/app-dir/.vscode/settings.json
@@ -0,0 +1,4 @@
{
"typescript.tsdk": "./node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true
}
20 changes: 20 additions & 0 deletions examples/app-dir/app/[dynamic]/page.tsx
@@ -0,0 +1,20 @@
const DynamicPage: React.FC<any> = ({ params }) => {
return (
<div>
<h1>DynamicPage Component</h1>
<pre>{JSON.stringify(params, null, 2)}</pre>
</div>
)
}

export default DynamicPage

/**
* @see https://beta.nextjs.org/docs/api-reference/generate-static-params
* @returns
*/
export async function generateStaticParams() {
return [...Array(10000)].map((_, index) => ({
dynamic: `page-${index}`,
}))
}
14 changes: 14 additions & 0 deletions examples/app-dir/app/layout.tsx
@@ -0,0 +1,14 @@
import React from 'react'

export default function RootLayout({
children,
}: {
children: React.ReactNode
}) {
return (
<html>
<head></head>
<body>{children}</body>
</html>
)
}
11 changes: 11 additions & 0 deletions examples/app-dir/app/page.tsx
@@ -0,0 +1,11 @@
import React from 'react'

const HomePage: React.FC = () => {
return (
<div>
<h1>HomePage Component</h1>
</div>
)
}

export default HomePage
5 changes: 5 additions & 0 deletions examples/app-dir/next-env.d.ts
@@ -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.
16 changes: 16 additions & 0 deletions examples/app-dir/next-sitemap.config.js
@@ -0,0 +1,16 @@
/** @type {import('next-sitemap').IConfig} */
const config = {
siteUrl: process.env.SITE_URL || 'https://example.com',
generateRobotsTxt: true,
sitemapSize: 1000,
// optional
robotsTxtOptions: {
additionalSitemaps: [
'https://example.com/my-custom-sitemap-1.xml',
'https://example.com/my-custom-sitemap-2.xml',
'https://example.com/my-custom-sitemap-3.xml',
],
},
}

export default config
8 changes: 8 additions & 0 deletions examples/app-dir/next.config.js
@@ -0,0 +1,8 @@
/**@type {import('next').NextConfig} */
const config = {
experimental: {
appDir: true,
},
}

export default config
23 changes: 23 additions & 0 deletions examples/app-dir/package.json
@@ -0,0 +1,23 @@
{
"name": "with-next-app-dir",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"private": true,
"type": "module",
"scripts": {
"dev": "next",
"build": "next build",
"postbuild": "next-sitemap"
},
"dependencies": {
"@types/react-dom": "^18.0.6",
"next": "^13.0.2",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/react": "^18.0.17",
"next-sitemap": "*"
}
}
25 changes: 25 additions & 0 deletions examples/app-dir/tsconfig.json
@@ -0,0 +1,25 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"incremental": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"plugins": [
{
"name": "next"
}
]
},
"include": ["next-env.d.ts", ".next/types/**/*.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}

0 comments on commit 13d44a2

Please sign in to comment.