wip: started the comments
This commit is contained in:
parent
890944ab64
commit
9eae498ef8
6 changed files with 93 additions and 6 deletions
BIN
README.pdf
Normal file
BIN
README.pdf
Normal file
Binary file not shown.
17
src/components/Comment.tsx
Normal file
17
src/components/Comment.tsx
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
import Mdown from './Mdown'
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
author: string
|
||||||
|
content: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function Comment({ author, content }: Props) {
|
||||||
|
return (
|
||||||
|
<div className="bg-[#161718] w-xl max-w-4/5 p-5 flex flex-col gap-5 rounded-xl self-center hover:shadow-xl/20 hover:shadow-white transition-shadow mb-5">
|
||||||
|
<h1 className="text-white text-xl font-bold">{author}</h1>
|
||||||
|
<div className=" flex flex-col space-y-1 text-[#9e9b97]">
|
||||||
|
<Mdown>{content}</Mdown>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -33,9 +33,11 @@ export default function Header() {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="px-2">
|
<div className="px-2">
|
||||||
|
<Link to="/comments">
|
||||||
{lang == 'fr'
|
{lang == 'fr'
|
||||||
? "[WIP] Livre d'Or"
|
? "[WIP] Livre d'Or"
|
||||||
: '[WIP] Golden Book'}
|
: '[WIP] Golden Book'}
|
||||||
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<button className="cursor-pointer" onClick={toggleLang}>
|
<button className="cursor-pointer" onClick={toggleLang}>
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import { Route as rootRouteImport } from './routes/__root'
|
||||||
import { Route as IndexRouteImport } from './routes/index'
|
import { Route as IndexRouteImport } from './routes/index'
|
||||||
import { Route as ProjectsIndexRouteImport } from './routes/projects/index'
|
import { Route as ProjectsIndexRouteImport } from './routes/projects/index'
|
||||||
import { Route as LessonsIndexRouteImport } from './routes/lessons/index'
|
import { Route as LessonsIndexRouteImport } from './routes/lessons/index'
|
||||||
|
import { Route as CommentsIndexRouteImport } from './routes/comments/index'
|
||||||
import { Route as LessonsLessonNameRouteImport } from './routes/lessons/$lessonName'
|
import { Route as LessonsLessonNameRouteImport } from './routes/lessons/$lessonName'
|
||||||
|
|
||||||
const IndexRoute = IndexRouteImport.update({
|
const IndexRoute = IndexRouteImport.update({
|
||||||
|
|
@ -29,6 +30,11 @@ const LessonsIndexRoute = LessonsIndexRouteImport.update({
|
||||||
path: '/lessons/',
|
path: '/lessons/',
|
||||||
getParentRoute: () => rootRouteImport,
|
getParentRoute: () => rootRouteImport,
|
||||||
} as any)
|
} as any)
|
||||||
|
const CommentsIndexRoute = CommentsIndexRouteImport.update({
|
||||||
|
id: '/comments/',
|
||||||
|
path: '/comments/',
|
||||||
|
getParentRoute: () => rootRouteImport,
|
||||||
|
} as any)
|
||||||
const LessonsLessonNameRoute = LessonsLessonNameRouteImport.update({
|
const LessonsLessonNameRoute = LessonsLessonNameRouteImport.update({
|
||||||
id: '/lessons/$lessonName',
|
id: '/lessons/$lessonName',
|
||||||
path: '/lessons/$lessonName',
|
path: '/lessons/$lessonName',
|
||||||
|
|
@ -38,12 +44,14 @@ const LessonsLessonNameRoute = LessonsLessonNameRouteImport.update({
|
||||||
export interface FileRoutesByFullPath {
|
export interface FileRoutesByFullPath {
|
||||||
'/': typeof IndexRoute
|
'/': typeof IndexRoute
|
||||||
'/lessons/$lessonName': typeof LessonsLessonNameRoute
|
'/lessons/$lessonName': typeof LessonsLessonNameRoute
|
||||||
|
'/comments': typeof CommentsIndexRoute
|
||||||
'/lessons': typeof LessonsIndexRoute
|
'/lessons': typeof LessonsIndexRoute
|
||||||
'/projects': typeof ProjectsIndexRoute
|
'/projects': typeof ProjectsIndexRoute
|
||||||
}
|
}
|
||||||
export interface FileRoutesByTo {
|
export interface FileRoutesByTo {
|
||||||
'/': typeof IndexRoute
|
'/': typeof IndexRoute
|
||||||
'/lessons/$lessonName': typeof LessonsLessonNameRoute
|
'/lessons/$lessonName': typeof LessonsLessonNameRoute
|
||||||
|
'/comments': typeof CommentsIndexRoute
|
||||||
'/lessons': typeof LessonsIndexRoute
|
'/lessons': typeof LessonsIndexRoute
|
||||||
'/projects': typeof ProjectsIndexRoute
|
'/projects': typeof ProjectsIndexRoute
|
||||||
}
|
}
|
||||||
|
|
@ -51,20 +59,33 @@ export interface FileRoutesById {
|
||||||
__root__: typeof rootRouteImport
|
__root__: typeof rootRouteImport
|
||||||
'/': typeof IndexRoute
|
'/': typeof IndexRoute
|
||||||
'/lessons/$lessonName': typeof LessonsLessonNameRoute
|
'/lessons/$lessonName': typeof LessonsLessonNameRoute
|
||||||
|
'/comments/': typeof CommentsIndexRoute
|
||||||
'/lessons/': typeof LessonsIndexRoute
|
'/lessons/': typeof LessonsIndexRoute
|
||||||
'/projects/': typeof ProjectsIndexRoute
|
'/projects/': typeof ProjectsIndexRoute
|
||||||
}
|
}
|
||||||
export interface FileRouteTypes {
|
export interface FileRouteTypes {
|
||||||
fileRoutesByFullPath: FileRoutesByFullPath
|
fileRoutesByFullPath: FileRoutesByFullPath
|
||||||
fullPaths: '/' | '/lessons/$lessonName' | '/lessons' | '/projects'
|
fullPaths:
|
||||||
|
| '/'
|
||||||
|
| '/lessons/$lessonName'
|
||||||
|
| '/comments'
|
||||||
|
| '/lessons'
|
||||||
|
| '/projects'
|
||||||
fileRoutesByTo: FileRoutesByTo
|
fileRoutesByTo: FileRoutesByTo
|
||||||
to: '/' | '/lessons/$lessonName' | '/lessons' | '/projects'
|
to: '/' | '/lessons/$lessonName' | '/comments' | '/lessons' | '/projects'
|
||||||
id: '__root__' | '/' | '/lessons/$lessonName' | '/lessons/' | '/projects/'
|
id:
|
||||||
|
| '__root__'
|
||||||
|
| '/'
|
||||||
|
| '/lessons/$lessonName'
|
||||||
|
| '/comments/'
|
||||||
|
| '/lessons/'
|
||||||
|
| '/projects/'
|
||||||
fileRoutesById: FileRoutesById
|
fileRoutesById: FileRoutesById
|
||||||
}
|
}
|
||||||
export interface RootRouteChildren {
|
export interface RootRouteChildren {
|
||||||
IndexRoute: typeof IndexRoute
|
IndexRoute: typeof IndexRoute
|
||||||
LessonsLessonNameRoute: typeof LessonsLessonNameRoute
|
LessonsLessonNameRoute: typeof LessonsLessonNameRoute
|
||||||
|
CommentsIndexRoute: typeof CommentsIndexRoute
|
||||||
LessonsIndexRoute: typeof LessonsIndexRoute
|
LessonsIndexRoute: typeof LessonsIndexRoute
|
||||||
ProjectsIndexRoute: typeof ProjectsIndexRoute
|
ProjectsIndexRoute: typeof ProjectsIndexRoute
|
||||||
}
|
}
|
||||||
|
|
@ -92,6 +113,13 @@ declare module '@tanstack/react-router' {
|
||||||
preLoaderRoute: typeof LessonsIndexRouteImport
|
preLoaderRoute: typeof LessonsIndexRouteImport
|
||||||
parentRoute: typeof rootRouteImport
|
parentRoute: typeof rootRouteImport
|
||||||
}
|
}
|
||||||
|
'/comments/': {
|
||||||
|
id: '/comments/'
|
||||||
|
path: '/comments'
|
||||||
|
fullPath: '/comments'
|
||||||
|
preLoaderRoute: typeof CommentsIndexRouteImport
|
||||||
|
parentRoute: typeof rootRouteImport
|
||||||
|
}
|
||||||
'/lessons/$lessonName': {
|
'/lessons/$lessonName': {
|
||||||
id: '/lessons/$lessonName'
|
id: '/lessons/$lessonName'
|
||||||
path: '/lessons/$lessonName'
|
path: '/lessons/$lessonName'
|
||||||
|
|
@ -105,6 +133,7 @@ declare module '@tanstack/react-router' {
|
||||||
const rootRouteChildren: RootRouteChildren = {
|
const rootRouteChildren: RootRouteChildren = {
|
||||||
IndexRoute: IndexRoute,
|
IndexRoute: IndexRoute,
|
||||||
LessonsLessonNameRoute: LessonsLessonNameRoute,
|
LessonsLessonNameRoute: LessonsLessonNameRoute,
|
||||||
|
CommentsIndexRoute: CommentsIndexRoute,
|
||||||
LessonsIndexRoute: LessonsIndexRoute,
|
LessonsIndexRoute: LessonsIndexRoute,
|
||||||
ProjectsIndexRoute: ProjectsIndexRoute,
|
ProjectsIndexRoute: ProjectsIndexRoute,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
35
src/routes/comments/index.tsx
Normal file
35
src/routes/comments/index.tsx
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
import Comment from '@/components/Comment'
|
||||||
|
import type { CommentType } from '@/types/comments'
|
||||||
|
import { createFileRoute } from '@tanstack/react-router'
|
||||||
|
|
||||||
|
// ===================
|
||||||
|
// =====< UTILS >=====
|
||||||
|
// ===================
|
||||||
|
|
||||||
|
async function fetchData(): Promise<CommentType[]> {
|
||||||
|
let data = await fetch(`${import.meta.env.VITE_API}/comments`)
|
||||||
|
return await data.json()
|
||||||
|
}
|
||||||
|
|
||||||
|
// =======================
|
||||||
|
// =====< COMPONENT >=====
|
||||||
|
// =======================
|
||||||
|
|
||||||
|
export const Route = createFileRoute('/comments/')({
|
||||||
|
loader: async () => fetchData(),
|
||||||
|
component: Comments,
|
||||||
|
})
|
||||||
|
|
||||||
|
export default function Comments() {
|
||||||
|
let data = Route.useLoaderData()
|
||||||
|
|
||||||
|
const items = data.map((e, i) => (
|
||||||
|
<Comment author={e.author} content={e.content} key={i} />
|
||||||
|
))
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="bg-[url(/public/bg.jpeg)] bg-cover bg-no-repeat bg-center min-h-screen">
|
||||||
|
<div className="flex flex-col pt-10">{items}</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
4
src/types/comments.tsx
Normal file
4
src/types/comments.tsx
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
export type CommentType = {
|
||||||
|
author: string
|
||||||
|
content: string
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue