diff --git a/package.json b/package.json index abe3872..43cb484 100644 --- a/package.json +++ b/package.json @@ -1,21 +1,20 @@ { "name": "bento-website", "private": true, - "version": "0.0.0", - "type": "module", + "version": "0.1.0", "scripts": { - "dev": "vite", - "build": "vite build", - "preview": "vite preview" + "dev": "next dev", + "build": "next build", + "start": "next start" }, "dependencies": { + "next": "^14.2.0", "react": "^18.2.0", - "react-dom": "^18.2.0" + "react-dom": "^18.2.0", + "react-markdown": "^10.1.0" }, "devDependencies": { "@types/react": "^18.2.66", - "@types/react-dom": "^18.2.22", - "@vitejs/plugin-react": "^4.2.1", - "vite": "^5.2.0" + "@types/react-dom": "^18.2.22" } } diff --git a/src/app/blog/[slug]/page.jsx b/src/app/blog/[slug]/page.jsx new file mode 100644 index 0000000..d928a65 --- /dev/null +++ b/src/app/blog/[slug]/page.jsx @@ -0,0 +1,76 @@ +import { notFound } from 'next/navigation' +import { fetchArticle } from '../../../lib/directus' + +const DIRECTUS_URL = 'https://cms.dexterlab.pl' +const BASE_URL = 'https://labai.pro' + +function blogPostingSchema(article) { + return { + '@context': 'https://schema.org', + '@type': 'BlogPosting', + '@id': `${BASE_URL}/blog/${article.Slug}`, + headline: article.Title, + url: `${BASE_URL}/blog/${article.Slug}`, + description: article.Excerpt || undefined, + datePublished: article.date_published || article.date_created, + dateModified: article.date_updated || article.date_published || article.date_created, + image: article.Cover_Image ? `${DIRECTUS_URL}/assets/${article.Cover_Image}` : undefined, + author: article.Author + ? { '@type': 'Person', name: article.Author } + : { '@type': 'Organization', name: 'Laboratorium AI' }, + publisher: { + '@type': 'Organization', + '@id': `${BASE_URL}/#organization`, + name: 'Laboratorium AI', + }, + mainEntityOfPage: { '@type': 'WebPage', '@id': `${BASE_URL}/blog/${article.Slug}` }, + } +} + +export const revalidate = 0 + +export async function generateMetadata({ params }) { + const article = await fetchArticle(params.slug) + if (!article) return {} + return { + title: `${article.Title} — Laboratorium AI`, + description: article.Excerpt || article.Title, + openGraph: { + title: article.Title, + images: article.Cover_Image ? [`${DIRECTUS_URL}/assets/${article.Cover_Image}`] : [], + }, + } +} + +export default async function ArticlePage({ params }) { + const article = await fetchArticle(params.slug) + if (!article) notFound() + + return ( +
+