diff --git a/src/app/[lang]/dictionaries.js b/src/app/[lang]/dictionaries.js index 69c8c55..7fc7850 100644 --- a/src/app/[lang]/dictionaries.js +++ b/src/app/[lang]/dictionaries.js @@ -1,8 +1,8 @@ import 'server-only'; const dictionaries = { - en: () => import('./dictionaries/en.json').then((module) => module.default), - es: () => import('./dictionaries/es.json').then((module) => module.default) + en: () => import('@/app/[lang]/dictionaries/en.json').then((module) => module.default), + es: () => import('@/app/[lang]/dictionaries/es.json').then((module) => module.default) }; export const getDictionary = async (locale) => { diff --git a/src/app/[lang]/not-found.js b/src/app/[lang]/not-found.js new file mode 100644 index 0000000..45b276d --- /dev/null +++ b/src/app/[lang]/not-found.js @@ -0,0 +1,5 @@ +import React from 'react'; + +export default function NotFound() { + return

404 Not Found custom

; +} diff --git a/src/app/[lang]/page.js b/src/app/[lang]/page.js index 2f3897e..3baaa7c 100644 --- a/src/app/[lang]/page.js +++ b/src/app/[lang]/page.js @@ -1,5 +1,5 @@ import React from 'react'; -import { getDictionary } from './dictionaries'; +import { getDictionary } from '@/app/[lang]/dictionaries'; export default async function Page({ params: { lang } }) { const dict = await getDictionary(lang); diff --git a/src/app/[lang]/speakers/[uniquepage]/page.js b/src/app/[lang]/speakers/[uniquepage]/page.js new file mode 100644 index 0000000..658837b --- /dev/null +++ b/src/app/[lang]/speakers/[uniquepage]/page.js @@ -0,0 +1,82 @@ +import React from 'react'; +import propTypes from 'prop-types'; +import { notFound } from 'next/navigation'; +import Image from 'next/image'; +import Link from 'next/link'; +import speakerslist from '@/data/speakers.json'; +import talksList from '@/data/talks.json'; +import Avatar from '@/app/[lang]/speakers/images/avatar.jpeg'; + +export async function generateStaticParams() { + return speakerslist.map((p) => ({ + uniquepage: p.id.toString() + })); +} + +const Speaker = ({ params: { uniquepage, lang } }) => { + const speaker = speakerslist.find((p) => p.id.toString() === uniquepage); + let talks = []; + + if (!speaker) { + console.info('speaker not found'); + notFound(); + } else { + talks = talksList.filter((talk) => talk.speakers.includes(speaker.id)); + } + + return ( + <> + Picture of the author +

+ {speaker.first_name} {speaker.last_name} +

+

{speaker.affiliation}

+

{speaker.country_residence}

+ +

{speaker.biography}

+ +

Talks

+ + {talks.map((talk) => ( + +

{talk.title}

+ + ))} + + ); +}; + +Speaker.propTypes = { + params: propTypes.shape({ + uniquepage: propTypes.string, + lang: propTypes.string + }) +}; + +export default Speaker; diff --git a/src/app/[lang]/speakers/images/avatar.jpeg b/src/app/[lang]/speakers/images/avatar.jpeg new file mode 100644 index 0000000..00f7cda Binary files /dev/null and b/src/app/[lang]/speakers/images/avatar.jpeg differ diff --git a/src/app/[lang]/speakers/page.js b/src/app/[lang]/speakers/page.js new file mode 100644 index 0000000..353e35a --- /dev/null +++ b/src/app/[lang]/speakers/page.js @@ -0,0 +1,34 @@ +'use client'; + +import React from 'react'; +import propTypes from 'prop-types'; +import Link from 'next/link'; +import speakerslist from '@/data/speakers.json'; + +const Speakers = ({ params: { lang } }) => { + return ( +
+ {speakerslist.map((speaker) => ( +
+ +

+ {speaker.first_name} {speaker.last_name} +

+

{speaker.affiliation}

+ + + {speaker.twitter} + +
+ ))} +
+ ); +}; + +Speakers.propTypes = { + params: propTypes.shape({ + lang: propTypes.string.isRequired + }).isRequired +}; + +export default Speakers; diff --git a/src/app/[lang]/talks/[uniquepage]/page.js b/src/app/[lang]/talks/[uniquepage]/page.js new file mode 100644 index 0000000..187ecf5 --- /dev/null +++ b/src/app/[lang]/talks/[uniquepage]/page.js @@ -0,0 +1,55 @@ +import React from 'react'; +import propTypes from 'prop-types'; +import talksList from '@/data/talks.json'; +import { notFound } from 'next/navigation'; + +export async function generateStaticParams() { + return talksList.map((p) => ({ + uniquepage: p.id.toString() + })); +} + +const UniquePage = ({ params: { uniquepage } }) => { + const talk = talksList.find((p) => p.id.toString() === uniquepage); + + if (!talk) { + console.log('talk not found'); + notFound(); + } + + return ( + <> +

{talk.title}

+ + +
+ + {talk.speakers.map((speaker) => ( +

{speaker}

+ ))} +

Authors

+ + +

{talk.description}

+ +

Summary

+

{talk.summary}

+ + ); +}; + +UniquePage.propTypes = { + params: propTypes.shape({ + uniquepage: propTypes.string.isRequired + }).isRequired +}; + +export default UniquePage; diff --git a/src/app/[lang]/talks/page.js b/src/app/[lang]/talks/page.js new file mode 100644 index 0000000..b357fda --- /dev/null +++ b/src/app/[lang]/talks/page.js @@ -0,0 +1,24 @@ +import React from 'react'; +import propTypes from 'prop-types'; +import talksList from '@/data/talks.json'; +import Link from 'next/link'; + +const Talks = ({ params: { lang } }) => { + return ( +
+ {talksList.map((talk) => ( + +

{talk.title}

+ + ))} +
+ ); +}; + +Talks.propTypes = { + params: propTypes.shape({ + lang: propTypes.string.isRequired + }).isRequired +}; + +export default Talks; diff --git a/src/data/speakers.json b/src/data/speakers.json new file mode 100644 index 0000000..3cd8f4c --- /dev/null +++ b/src/data/speakers.json @@ -0,0 +1,34 @@ +[ + { + "id": "john-doe", + "first_name": "John", + "last_name": "Doe", + "email": "bYQJ9@example.com", + "photo": "https://i.pravatar.cc/300", + "biography": "I am John Doe. I am an amazing speaker.", + "affiliation": "Acme Inc.", + "facebook": "https://www.facebook.com/johndoe", + "twitter": "@johndoe", + "linkedin": "https://www.linkedin.com/in/johndoe", + "github": "https://github.com/johndoe", + "website": "https://johndoe.com", + "country_origin": "USA", + "country_residence": "USA" + }, + { + "id": "jane-doe", + "first_name": "Jane", + "last_name": "Doe", + "email": "bYQJ9@example.com", + "photo": "https://i.pravatar.cc/300", + "biography": "I am Jane Doe. I am an amazing speaker.", + "affiliation": "Acme Inc.", + "facebook": "https://www.facebook.com/johndoe", + "twitter": "@johndoe", + "linkedin": "https://www.linkedin.com/in/johndoe", + "github": "https://github.com/janedenoe", + "website": "https://janedenoe.com", + "country_origin": "Colombia", + "country_residence": "Canada" + } +] diff --git a/src/data/talks.json b/src/data/talks.json new file mode 100644 index 0000000..88e1fa7 --- /dev/null +++ b/src/data/talks.json @@ -0,0 +1,35 @@ +[ + { + "id": 1, + "title": "This is the title", + "speakers": [ + "john-doe" + ], + "written_language": "English", + "spoken_language": "English", + "submission": "Talk", + "description": "This is the description", + "summary": "This is the summary", + "tags": [ + "tag1", + "tag2" + ], + "video_url": "https://www.youtube.com/watch?v=123" + }, + { + "id": 2, + "title": "This is the title", + "speakers": [ + "john-doe", + "jane-doe" + ], + "written_language": "English", + "spoken_language": "Spanish", + "submission": "Workshop", + "description": "This is the description", + "summary": "This is the summary", + "tags": [ + "tag1" + ] + } +] diff --git a/src/middleware.js b/src/middleware.js index 4853dc3..fb3dd0a 100644 --- a/src/middleware.js +++ b/src/middleware.js @@ -5,8 +5,6 @@ export function middleware(request) { // Check if there is any supported locale in the pathname const { pathname } = request.nextUrl; - console.log('pathname', pathname); - const pathnameHasLocale = locales.some( (locale) => pathname.startsWith(`/${locale}/`) || pathname === `/${locale}` );