aggiornamento a [slug]/page.tsx e a [...slug]/page.tsx
This commit is contained in:
parent
4bb0dcdcd5
commit
ad52596f4b
6 changed files with 1519 additions and 869 deletions
2343
package-lock.json
generated
2343
package-lock.json
generated
File diff suppressed because it is too large
Load diff
20
package.json
20
package.json
|
|
@ -6,21 +6,25 @@
|
|||
"dev": "next dev",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"lint": "next lint"
|
||||
"lint": "eslint ."
|
||||
},
|
||||
"dependencies": {
|
||||
"next": "14.2.28",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1"
|
||||
"next": "16.2.6",
|
||||
"react": "19.2.6",
|
||||
"react-dom": "19.2.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/postcss": "^4",
|
||||
"@types/node": "^20",
|
||||
"@types/react": "^18",
|
||||
"@types/react-dom": "^18",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-config-next": "14.2.28",
|
||||
"@types/react": "19.2.15",
|
||||
"@types/react-dom": "19.2.3",
|
||||
"eslint": "^9.0.0",
|
||||
"eslint-config-next": "16.2.6",
|
||||
"tailwindcss": "^4",
|
||||
"typescript": "^5"
|
||||
},
|
||||
"overrides": {
|
||||
"@types/react": "19.2.15",
|
||||
"@types/react-dom": "19.2.3"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,8 +24,9 @@ const blogPosts: Post[] = [
|
|||
];
|
||||
|
||||
/** Next 14: `params` è un oggetto sincrono. */
|
||||
export default function BlogPost({ params }: { params: { slug: string } }) {
|
||||
const post = blogPosts.find((p) => p.slug === params.slug);
|
||||
export default async function BlogPost({ params }: { params: Promise<{ slug: string }> }) {
|
||||
const {slug} = await params;
|
||||
const post = blogPosts.find((p) => p.slug === slug);
|
||||
|
||||
if (!post) {
|
||||
return <div>Post non trovato</div>;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,12 @@ interface DocPage {
|
|||
content: string,
|
||||
}
|
||||
|
||||
interface DocPageProps {
|
||||
params: Promise<{
|
||||
slug: string[];
|
||||
}>
|
||||
}
|
||||
|
||||
const docs: DocPage[] = [
|
||||
{
|
||||
path: ["intro"],
|
||||
|
|
@ -22,11 +28,11 @@ const docs: DocPage[] = [
|
|||
},
|
||||
];
|
||||
|
||||
export default function DocPage({ params }: { params: { slug: string[] } }) {
|
||||
const currentPath = params.slug;
|
||||
console.log(currentPath);
|
||||
export default async function DocPage({ params }: DocPageProps) {
|
||||
const { slug } = await params;
|
||||
|
||||
const doc = docs.find(doc => doc.path.join("/") === currentPath.join("/"));
|
||||
|
||||
const doc = docs.find(doc => doc.path.join("/") === slug.join("/"));
|
||||
|
||||
if (!doc) {
|
||||
return <div>Pagina non trovata</div>;
|
||||
|
|
@ -36,7 +42,7 @@ export default function DocPage({ params }: { params: { slug: string[] } }) {
|
|||
<div className="max-w-4xl ma-auto p-8">
|
||||
<h1 className="text-3xl font-bold mb-4">{doc.title}</h1>
|
||||
<p>{doc.content}</p>
|
||||
<div className="mt-r text-sm text-gray-500">Path: /{currentPath.join("/")}</div>
|
||||
<div className="mt-r text-sm text-gray-500">Path: /{slug.join("/")}</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
@ -4,6 +4,8 @@
|
|||
// @author: "villari.andrea@libero.it"
|
||||
// @version: "1.0.0 2026-05-07"
|
||||
//====================================
|
||||
"use client"
|
||||
|
||||
|
||||
export default function Navbar() {
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
"moduleResolution": "bundler",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"jsx": "preserve",
|
||||
"jsx": "react-jsx",
|
||||
"incremental": true,
|
||||
"plugins": [
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue