@@ -3,6 +3,8 @@ import { backend_url } from "../../data/conf.json";
3
3
import BaseLayout from " ../../layouts/baseLayout.astro" ;
4
4
import JobHeader from " ../../components/jobs/jobHeader.astro" ;
5
5
import OthersJobsCta from " ../../components/jobs/othersJobsCta.astro" ;
6
+ import dayjs from " dayjs" ;
7
+ import profileCategories from " ../../data/profileCategories.json" ;
6
8
7
9
export async function getStaticPaths() {
8
10
const response = await fetch (backend_url + " api/jobs/get-all-jobs" );
@@ -15,9 +17,59 @@ export async function getStaticPaths() {
15
17
}
16
18
17
19
const { job, nextJobs } = Astro .props ;
20
+
21
+ let seoSchema = {
22
+ " @context" : " https://schema.org/" ,
23
+ " @type" : " JobPosting" ,
24
+ description: ` <p>${job .title } \n\n ${job .description }</p> ` ,
25
+ datePosted: dayjs (job .pubDate ).format (" YYYY-MM-DD" ),
26
+ applicantLocationRequirements: {
27
+ " @type" : " Country" ,
28
+ name: " CUBA" ,
29
+ },
30
+ };
31
+
32
+ if (job .remote ) {
33
+ seoSchema [" jobLocationType" ] = " TELECOMMUTE" ;
34
+ }
35
+
36
+ if (job .presential && job .location ) {
37
+ seoSchema [" jobLocation" ] = {
38
+ " @type" : " Place" ,
39
+ name: job .location ,
40
+ };
41
+ }
42
+
43
+ if (job .organization ) {
44
+ seoSchema [" hiringOrganization" ] = {
45
+ " @type" : " Organization" ,
46
+ name: job .organization ,
47
+ };
48
+ if (job .organization_site ) {
49
+ seoSchema [" hiringOrganization" ][" sameAs" ] = job .organization_site ;
50
+ }
51
+ }
52
+
53
+ let jobTitle = job .categories .map ((category ) => profileCategories [category ].text ).join (" , " );
54
+ let jobType;
55
+
56
+ if (job .fulltime ) {
57
+ seoSchema [" employmentType" ] = " FULL_TIME" ;
58
+ jobType = " Full-time" ;
59
+ }
60
+ if (job .parttime ) {
61
+ seoSchema [" employmentType" ] = " PART_TIME" ;
62
+ jobType = " Part-time" ;
63
+ }
64
+ if (job .freelance ) {
65
+ seoSchema [" employmentType" ] = " CONTRACTOR" ;
66
+ jobType = " Freelance" ;
67
+ }
68
+
69
+ seoSchema [" title" ] = jobType ? jobType + " " + jobTitle : jobTitle ;
18
70
---
19
71
20
- <BaseLayout title ={ ` ${job .title } | CuCoders Jobs ` } >
72
+ <BaseLayout title ={ ` ${job .title } | CuCoders Jobs ` } seoSchema = { seoSchema } description = { job . description . slice ( 0 , 180 ) } >
21
73
<JobHeader job ={ job } />
22
74
<div
23
75
class =" bg-white border md:mx-auto mb-5 py-7 px-9 lg:max-w-[58rem] border-gray-200 rounded-lg dark:bg-gray-800 dark:border-gray-700 w-full"
0 commit comments