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",
|
"dev": "next dev",
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
"lint": "next lint"
|
"lint": "eslint ."
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"next": "14.2.28",
|
"next": "16.2.6",
|
||||||
"react": "^18.3.1",
|
"react": "19.2.6",
|
||||||
"react-dom": "^18.3.1"
|
"react-dom": "19.2.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tailwindcss/postcss": "^4",
|
"@tailwindcss/postcss": "^4",
|
||||||
"@types/node": "^20",
|
"@types/node": "^20",
|
||||||
"@types/react": "^18",
|
"@types/react": "19.2.15",
|
||||||
"@types/react-dom": "^18",
|
"@types/react-dom": "19.2.3",
|
||||||
"eslint": "^8.57.0",
|
"eslint": "^9.0.0",
|
||||||
"eslint-config-next": "14.2.28",
|
"eslint-config-next": "16.2.6",
|
||||||
"tailwindcss": "^4",
|
"tailwindcss": "^4",
|
||||||
"typescript": "^5"
|
"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. */
|
/** Next 14: `params` è un oggetto sincrono. */
|
||||||
export default function BlogPost({ params }: { params: { slug: string } }) {
|
export default async function BlogPost({ params }: { params: Promise<{ slug: string }> }) {
|
||||||
const post = blogPosts.find((p) => p.slug === params.slug);
|
const {slug} = await params;
|
||||||
|
const post = blogPosts.find((p) => p.slug === slug);
|
||||||
|
|
||||||
if (!post) {
|
if (!post) {
|
||||||
return <div>Post non trovato</div>;
|
return <div>Post non trovato</div>;
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,12 @@ interface DocPage {
|
||||||
content: string,
|
content: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface DocPageProps {
|
||||||
|
params: Promise<{
|
||||||
|
slug: string[];
|
||||||
|
}>
|
||||||
|
}
|
||||||
|
|
||||||
const docs: DocPage[] = [
|
const docs: DocPage[] = [
|
||||||
{
|
{
|
||||||
path: ["intro"],
|
path: ["intro"],
|
||||||
|
|
@ -22,11 +28,11 @@ const docs: DocPage[] = [
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export default function DocPage({ params }: { params: { slug: string[] } }) {
|
export default async function DocPage({ params }: DocPageProps) {
|
||||||
const currentPath = params.slug;
|
const { slug } = await params;
|
||||||
console.log(currentPath);
|
|
||||||
|
|
||||||
const doc = docs.find(doc => doc.path.join("/") === currentPath.join("/"));
|
|
||||||
|
const doc = docs.find(doc => doc.path.join("/") === slug.join("/"));
|
||||||
|
|
||||||
if (!doc) {
|
if (!doc) {
|
||||||
return <div>Pagina non trovata</div>;
|
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">
|
<div className="max-w-4xl ma-auto p-8">
|
||||||
<h1 className="text-3xl font-bold mb-4">{doc.title}</h1>
|
<h1 className="text-3xl font-bold mb-4">{doc.title}</h1>
|
||||||
<p>{doc.content}</p>
|
<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>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -4,6 +4,8 @@
|
||||||
// @author: "villari.andrea@libero.it"
|
// @author: "villari.andrea@libero.it"
|
||||||
// @version: "1.0.0 2026-05-07"
|
// @version: "1.0.0 2026-05-07"
|
||||||
//====================================
|
//====================================
|
||||||
|
"use client"
|
||||||
|
|
||||||
|
|
||||||
export default function Navbar() {
|
export default function Navbar() {
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
"moduleResolution": "bundler",
|
"moduleResolution": "bundler",
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"isolatedModules": true,
|
"isolatedModules": true,
|
||||||
"jsx": "preserve",
|
"jsx": "react-jsx",
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"plugins": [
|
"plugins": [
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue