Skip to content
This repository was archived by the owner on Mar 13, 2023. It is now read-only.

Commit d5a973b

Browse files
committed
✨ Affichage de l'auteur de l'article si celui si est suggere
1 parent 3c2e580 commit d5a973b

File tree

5 files changed

+88
-46
lines changed

5 files changed

+88
-46
lines changed

public/js/app.js

Lines changed: 23 additions & 7 deletions
Large diffs are not rendered by default.
Lines changed: 44 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from "react";
1+
import React, { useEffect, useState } from "react";
22
import { InertiaLink } from "@inertiajs/inertia-react";
33
// eslint-disable-next-line import/no-duplicates
44
import { format } from "date-fns";
@@ -11,38 +11,48 @@ interface Props {
1111
post: PostType;
1212
}
1313

14-
export default ({ post }: Props) => (
15-
<div className="w-full">
16-
<InertiaLink
17-
className="block rounded-lg bg-white h-75 shadow-md hover:shadow-lg overflow-hidden"
18-
href={`/blog/${post.slug}`}
19-
>
20-
<img
21-
src={post.image}
22-
className="object-cover w-full h-45 lg:h-40"
23-
alt={post.title}
24-
/>
25-
<div className="p-4 flex flex-col justify-between">
26-
<div className="space-y-1">
27-
<span className="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium leading-4 bg-green-100 text-green-800">
28-
{post.category.name}
29-
</span>
30-
<span className="h-10 flex text-truncate">
31-
<h4 className="text-sm text-gray-700 font-medium text-wrap">{post.title}</h4>
14+
export default ({ post }: Props) => {
15+
const [author, setAuthor] = useState(post.creator);
16+
17+
useEffect(() => {
18+
if (post.propose) {
19+
setAuthor(post.propose);
20+
}
21+
}, []);
22+
23+
return (
24+
<div className="w-full">
25+
<InertiaLink
26+
className="block rounded-lg bg-white h-75 shadow-md hover:shadow-lg overflow-hidden"
27+
href={`/blog/${post.slug}`}
28+
>
29+
<img
30+
src={post.image}
31+
className="object-cover w-full h-45 lg:h-40"
32+
alt={post.title}
33+
/>
34+
<div className="p-4 flex flex-col justify-between">
35+
<div className="space-y-1">
36+
<span className="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium leading-4 bg-green-100 text-green-800">
37+
{post.category.name}
38+
</span>
39+
<span className="h-10 flex text-truncate">
40+
<h4 className="text-sm text-gray-700 font-medium text-wrap">{post.title}</h4>
41+
</span>
42+
</div>
43+
<span className="flex mt-6 items-center">
44+
<img
45+
src={author.picture}
46+
className="h-12 w-12 rounded-full mr-4"
47+
alt={author.full_name}
48+
/>
49+
<span className="flex flex-col">
50+
<span className="text-sm text-gray-600">{author.full_name}</span>
51+
<small className="text-xs text-gray-400 capitalize">Le {format(new Date(post.published_at), "dd MMMM, y", { locale: fr })}</small>
52+
</span>
3253
</span>
3354
</div>
34-
<span className="flex mt-6 items-center">
35-
<img
36-
src={post.creator?.picture}
37-
className="h-12 w-12 rounded-full mr-4"
38-
alt={post.creator?.full_name}
39-
/>
40-
<span className="flex flex-col">
41-
<span className="text-sm text-gray-600">{post.creator?.full_name}</span>
42-
<small className="text-xs text-gray-400 capitalize">Le {format(new Date(post.published_at), "dd MMMM, y", { locale: fr })}</small>
43-
</span>
44-
</span>
45-
</div>
46-
</InertiaLink>
47-
</div>
48-
);
55+
</InertiaLink>
56+
</div>
57+
);
58+
};

resources/assets/ts/pages/blog/Post.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect } from "react";
1+
import React, { useEffect, useState } from "react";
22
import { usePage } from "@inertiajs/inertia-react";
33
import ReactMarkdown from "react-markdown/with-html";
44
import hljs from "highlight.js";
@@ -14,9 +14,14 @@ import { popupCenter } from "@/utils/helpers";
1414

1515
const Post = () => {
1616
const { post } = usePage();
17+
const [author, setAuthor] = useState(post.creator);
1718

1819
useEffect(() => {
1920
updateCodeSyntaxHighlighting();
21+
22+
if (post.propose) {
23+
setAuthor(post.propose);
24+
}
2025
}, []);
2126

2227
function share(e: React.SyntheticEvent, provider: string) {
@@ -82,12 +87,12 @@ const Post = () => {
8287
<div className="flex items-center justify-between mb-8 lg:mb-10">
8388
<span className="flex items-center">
8489
<img
85-
src={post.creator.picture}
90+
src={author.picture}
8691
className="h-14 w-14 rounded-full mr-4"
87-
alt={post.creator.full_name}
92+
alt={author.full_name}
8893
/>
8994
<span className="flex flex-col">
90-
<span className="text-lg text-gray-600">{post.creator.full_name}</span>
95+
<span className="text-lg text-gray-600">{author.full_name}</span>
9196
<small className="text-xs text-gray-400 capitalize">Publié Le {format(new Date(post.published_at), "dd MMMM, y", { locale: fr })}</small>
9297
</span>
9398
</span>

resources/assets/ts/utils/types.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export type PostType = {
8080
visits: number;
8181
image: string;
8282
status_classname: string;
83-
creator?: User;
83+
creator: User;
8484
propose?: User;
8585
category: CategoryType;
8686
published_at: Date;

resources/views/app.blade.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1">
77
<meta name="crsf-token" content="{{ csrf_token() }}">
88
<meta name="author" content="Arthur Monney">
9+
<!-- Meta -->
10+
<meta property="og:url" content="{{ $ }}" />
11+
<meta property="og:title" content="Accueil | Goshen Tabernacle" />
12+
<meta property="og:image" content="https://goshen-tabernacle.com/images/goshen.png" />
13+
<meta property="og:description" content="Bienvenue chez Goshen Tabernacle, L&#039;église c&#039;est plus qu&#039;un lieu, c&#039;est chacun de nous. Dans cette nouvelle saison, année de récolte, nous croyons qu&#039;..." />
14+
<meta property="og:type" content="article" />
15+
16+
<meta name="twitter:url" content="https://goshen-tabernacle.com" />
17+
<meta name="twitter:title" content="Accueil | Goshen Tabernacle" />
18+
<meta name="twitter:description" content="Bienvenue chez Goshen Tabernacle, L&#039;église c&#039;est plus qu&#039;un lieu, c&#039;est chacun de nous. Dans cette nouvelle saison, année de récolte, nous croyons qu&#039;..." />
19+
<meta name="twitter:image" content="https://goshen-tabernacle.com/images/goshen.png" />
920
<!-- Favicon -->
1021
<link rel="apple-touch-icon" href="{{ asset('img/favicons/apple-touch-icon.png') }}" sizes="180x180">
1122
<link rel="icon" type="image/png" href="{{ asset('img/favicons/favicon-32x32.png') }}" sizes="32x32">

0 commit comments

Comments
 (0)