File tree 6 files changed +74
-10
lines changed
6 files changed +74
-10
lines changed Original file line number Diff line number Diff line change 1
1
import Head from "next/head" ;
2
2
3
- export default function TabTitle ( props : { title : string } ) {
3
+ export default function TabTitle ( props : {
4
+ title : string ;
5
+ ogTitle ?: string ;
6
+ type ?: string ;
7
+ image ?: string ;
8
+ description ?: string ;
9
+ } ) {
4
10
return (
5
11
< Head >
6
12
< title > { `CLIC | ${ props . title } ` } </ title >
13
+ < meta property = "og:title" content = { props . ogTitle || props . title } />
14
+ < meta property = "og:type" content = { props . type || "website" } />
15
+ { typeof props . image === "string" ? (
16
+ < meta property = "og:image" content = { props . image } />
17
+ ) : (
18
+ < > </ >
19
+ ) }
20
+ { typeof props . description === "string" ? (
21
+ < meta property = "og:description" content = { props . description } />
22
+ ) : (
23
+ < > </ >
24
+ ) }
7
25
</ Head >
8
26
) ;
9
27
}
Original file line number Diff line number Diff line change 1
1
import { TranslationTable , getTranslation } from "./locales" ;
2
2
import { Association , Commission , SocialLink } from "./types/aliases" ;
3
- import { Schema } from "./types/schema" ;
3
+ import { Schema , components } from "./types/schema" ;
4
4
import {
5
5
createDirectus ,
6
6
readItems ,
@@ -140,3 +140,19 @@ export function cleanTranslations<T extends { [key: string]: any }>(
140
140
return rec ( await f ( context ) , context . locale ) ;
141
141
} ;
142
142
}
143
+
144
+ /**
145
+ * Computes the full URL to access an image returned by the Directus instance,
146
+ * or `undefined` if no image is given.
147
+ * @param image the image object returned by directus
148
+ * @returns the full URL of the image, if any
149
+ */
150
+ export function getDirectusImageUrl (
151
+ image : string | components [ "schemas" ] [ "Files" ] | null | undefined
152
+ ) : string | undefined {
153
+ return image
154
+ ? `${ DIRECTUS_URL } /assets/${
155
+ typeof image === "string" ? image : image . filename_disk
156
+ } `
157
+ : undefined ;
158
+ }
Original file line number Diff line number Diff line change 1
1
import AssociationDescription from "@/components/AssociationDescription" ;
2
2
import PoleDescription from "@/components/PoleDescription" ;
3
3
import TabTitle from "@/components/TabTitle" ;
4
- import { directus , populateLayoutProps } from "@/directus" ;
4
+ import { directus , getDirectusImageUrl , populateLayoutProps } from "@/directus" ;
5
5
import {
6
6
capitalize ,
7
7
getTranslation ,
@@ -48,7 +48,14 @@ export default function AssociationPage(
48
48
49
49
return (
50
50
< div className = { styles . main } >
51
- < TabTitle title = { capitalize ( tt [ "association" ] ) } />
51
+ < TabTitle
52
+ title = { capitalize ( tt [ "association" ] ) }
53
+ ogTitle = { props . association . name || undefined }
54
+ description = { tt [ "slogan" ] }
55
+ image = { getDirectusImageUrl (
56
+ getTranslation ( props . association , router . locale ) . banner
57
+ ) }
58
+ />
52
59
53
60
< div className = { styles . center } >
54
61
< AssociationDescription
Original file line number Diff line number Diff line change @@ -2,7 +2,12 @@ import DirectusImage from "@/components/DirectusImage";
2
2
import MembersList from "@/components/MembersList" ;
3
3
import SocialsList from "@/components/SocialsList" ;
4
4
import TabTitle from "@/components/TabTitle" ;
5
- import { LayoutProps , directus , populateLayoutProps } from "@/directus" ;
5
+ import {
6
+ LayoutProps ,
7
+ directus ,
8
+ getDirectusImageUrl ,
9
+ populateLayoutProps ,
10
+ } from "@/directus" ;
6
11
import { getTranslation , locale , queryTranslations } from "@/locales" ;
7
12
import markdownStyle from "@/styles/Markdown.module.scss" ;
8
13
import styles from "@/styles/Page.module.scss" ;
@@ -25,7 +30,11 @@ export default function Page(
25
30
26
31
return (
27
32
< div className = { styles . main } >
28
- < TabTitle title = { props . commission . name || "" } />
33
+ < TabTitle
34
+ title = { props . commission . name || "" }
35
+ description = { translation . small_description || undefined }
36
+ image = { getDirectusImageUrl ( translation . banner ) }
37
+ />
29
38
30
39
< div className = { styles . center } >
31
40
< DirectusImage
Original file line number Diff line number Diff line change @@ -10,7 +10,12 @@ import NewsCard from "@/components/NewsCard";
10
10
import PartnersList from "@/components/PartnersList" ;
11
11
import SocialsList from "@/components/SocialsList" ;
12
12
import TabTitle from "@/components/TabTitle" ;
13
- import { LayoutProps , directus , populateLayoutProps } from "@/directus" ;
13
+ import {
14
+ LayoutProps ,
15
+ directus ,
16
+ getDirectusImageUrl ,
17
+ populateLayoutProps ,
18
+ } from "@/directus" ;
14
19
import {
15
20
getTranslation ,
16
21
queryTranslations ,
@@ -55,7 +60,12 @@ export default function Home(
55
60
56
61
return (
57
62
< >
58
- < TabTitle title = { tt [ "slogan" ] } />
63
+ < TabTitle
64
+ title = { tt [ "slogan" ] }
65
+ ogTitle = { props . association . name || undefined }
66
+ description = { tt [ "slogan" ] }
67
+ image = { getDirectusImageUrl ( translation . banner ) }
68
+ />
59
69
< Background className = { styles . background } name = "background" />
60
70
< div className = { styles . divLogo } >
61
71
< DirectusImage
Original file line number Diff line number Diff line change 1
1
import CommissionCard from "@/components/CommissionCard" ;
2
2
import DirectusImage from "@/components/DirectusImage" ;
3
3
import TabTitle from "@/components/TabTitle" ;
4
- import { directus , populateLayoutProps } from "@/directus" ;
4
+ import { directus , getDirectusImageUrl , populateLayoutProps } from "@/directus" ;
5
5
import {
6
6
capitalize ,
7
7
formatDate ,
@@ -26,7 +26,11 @@ export default function Page(
26
26
27
27
return (
28
28
< div className = { styles . main } >
29
- < TabTitle title = { translation . title || "" } />
29
+ < TabTitle
30
+ title = { translation . title || "" }
31
+ description = { translation . description }
32
+ image = { getDirectusImageUrl ( translation . banner ) }
33
+ />
30
34
31
35
< div className = { styles . center } >
32
36
< DirectusImage
You can’t perform that action at this time.
0 commit comments