Skip to content

Commit 4c7805c

Browse files
committed
Optimize seo for individual projects
1 parent 7f51ce5 commit 4c7805c

File tree

6 files changed

+39
-45
lines changed

6 files changed

+39
-45
lines changed

components/Project.vue

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
<script setup lang="ts">
2-
import { useRoute } from 'vue-router';
2+
import { useSetMetaData } from '~/composables/onPageMetaData';
3+
import { Project } from '../types'
34
4-
const { locale } = useI18n();
5-
6-
const route = useRoute();
7-
const { id } = route.params;
8-
9-
const { data: project } = await useFetch(() => `/api/projects?id=${id}`);
10-
if (!project.value) {
11-
throw createError({ statusCode: 404, fatal: true})
12-
}
5+
const { locale, t } = useI18n();
136
7+
const props = defineProps<{
8+
project: Project
9+
}>();
10+
11+
watch(props.project, () : void => {
12+
useSetMetaData(props.project.title, props.project.briefDescription);
13+
}, { immediate: true, deep: true});
14+
1415
1516
const toolTitle = ref('');
1617
@@ -25,13 +26,7 @@
2526
default :
2627
}
2728
}
28-
29-
// Try to find a better solution!
30-
watch(() => route.name, (newValue, oldValue) => {
31-
if(newValue === 'index' && oldValue !== 'index') {
32-
location.reload();
33-
}
34-
});
29+
3530
3631
</script>
3732

data/db.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const zoolDeveloper = 'https://www.figma.com/file/5Ndy1AFfl9WDCWYOsNxFDE/MyPortf
3131
export default [
3232
{
3333
id: 1,
34-
title: 'réservia',
34+
title: 'Réservia',
3535
type: 'portfolio.project1.type',
3636
briefDescription: 'portfolio.project1.brief_description',
3737
mainDescription: "portfolio.project1.main_description",
@@ -51,7 +51,7 @@ export default [
5151
},
5252
{
5353
id: 2,
54-
title: 'ohmyfood',
54+
title: 'Ohmyfood',
5555
type: 'portfolio.project2.type',
5656
briefDescription: 'portfolio.project2.brief_description',
5757
mainDescription: 'portfolio.project2.main_description',
@@ -72,7 +72,7 @@ export default [
7272
},
7373
{
7474
id: 3,
75-
title: 'la chouette agence',
75+
title: 'La chouette agence',
7676
type: 'portfolio.project3.type',
7777
briefDescription: 'portfolio.project3.brief_description',
7878
mainDescription: 'portfolio.project3.main_description',
@@ -94,7 +94,7 @@ export default [
9494
},
9595
{
9696
id: 4,
97-
title: 'orinoco',
97+
title: 'Orinoco',
9898
type: 'portfolio.project4.type',
9999
briefDescription: 'portfolio.project4.brief_description',
100100
mainDescription: 'portfolio.project4.main_description',
@@ -117,7 +117,7 @@ export default [
117117
},
118118
{
119119
id: 5,
120-
title: 'hot takes',
120+
title: 'Hot Takes',
121121
type: 'portfolio.project5.type',
122122
briefDescription: 'portfolio.project5.brief_description',
123123
mainDescription: 'portfolio.project5.main_description',
@@ -138,7 +138,7 @@ export default [
138138
},
139139
{
140140
id: 6,
141-
title: 'groupomania',
141+
title: 'Groupomania',
142142
type: 'portfolio.project6.type',
143143
briefDescription: 'portfolio.project6.brief_description',
144144
mainDescription: 'portfolio.project6.main_description',
@@ -161,7 +161,7 @@ export default [
161161
},
162162
{
163163
id: 7,
164-
title: 'task tracker',
164+
title: 'Task Tracker',
165165
type: 'portfolio.project7.type',
166166
briefDescription: 'portfolio.project7.brief_description',
167167
mainDescription: 'portfolio.project7.main_description',
@@ -181,7 +181,7 @@ export default [
181181
},
182182
{
183183
id: 8,
184-
title: 'the jungle house',
184+
title: 'The Jungle House',
185185
type: 'portfolio.project8.type',
186186
briefDescription: 'portfolio.project8.brief_description',
187187
mainDescription: 'portfolio.project8.main_description',
@@ -201,7 +201,7 @@ export default [
201201
},
202202
{
203203
id: 9,
204-
title: 'weather app',
204+
title: 'Weather App',
205205
type: 'portfolio.project9.type',
206206
briefDescription: 'portfolio.project9.brief_description',
207207
mainDescription: 'portfolio.project9.main_description',
@@ -221,7 +221,7 @@ export default [
221221
},
222222
{
223223
id: 10,
224-
title: 'tenzies game',
224+
title: 'Tenzies Game',
225225
type: 'portfolio.project10.type',
226226
briefDescription: 'portfolio.project10.brief_description',
227227
mainDescription: 'portfolio.project10.main_description',
@@ -241,7 +241,7 @@ export default [
241241
},
242242
{
243243
id: 11,
244-
title: 'mp house location',
244+
title: 'MP House Location',
245245
type: 'portfolio.project11.type',
246246
briefDescription: 'portfolio.project11.brief_description',
247247
mainDescription: 'portfolio.project11.main_description',
@@ -263,7 +263,7 @@ export default [
263263
},
264264
{
265265
id: 12,
266-
title: 'zool developer',
266+
title: 'Zool Developer',
267267
type: 'portfolio.project12.type',
268268
briefDescription: 'portfolio.project12.brief_description',
269269
mainDescription: 'portfolio.project12.main_description',

locales/ar.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@
2929
"tools_alt_desc": "أيقونة",
3030
"download_resume": "تحميل السيرة الذاتية ",
3131
"portfolio": {
32-
"meta": {
33-
"page_title": "معلومات المشروع",
34-
"page_description": "ستجد هنا معلومات مفصلة عن كل مشروع"
35-
},
3632
"heading": {
3733
"main": "أعمالي",
3834
"navigational_title": "مشاريع الويب | التصاميم",

locales/en.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@
2929
"tools_alt_desc": "icon",
3030
"download_resume": "Download my resume",
3131
"portfolio": {
32-
"meta": {
33-
"page_title": "Project information",
34-
"page_description": "Here you will find detailed information about each project"
35-
},
3632
"heading": {
3733
"main": "Portfolio",
3834
"navigational_title": "Web Projects | Designs",

locales/fr.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@
2929
"tools_alt_desc": "îcone",
3030
"download_resume": "Télécharger mon CV",
3131
"portfolio": {
32-
"meta": {
33-
"page_title": "Informations du projet",
34-
"page_description": "Vous trouverez ici les informations de chaque projet de manière détaillé"
35-
},
3632
"heading": {
3733
"main": "Portfolio",
3834
"navigational_title": "Projets web | Designs",

pages/projects/[id].vue

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
11
<script setup lang="ts">
2-
import { useSetMetaData } from '~/composables/onPageMetaData';
2+
import { useRoute } from 'vue-router';
33
44
const { locale, t } = useI18n();
55
6-
onMounted(() => {
7-
useSetMetaData('portfolio.meta.page_title', 'portfolio.meta.page_description')
6+
const route = useRoute();
7+
const { id } = route.params;
8+
9+
const { data: project } = await useFetch(() => `/api/projects?id=${id}`);
10+
if (!project.value) {
11+
throw createError({ statusCode: 404, fatal: true})
12+
}
13+
14+
// Try to find a better solution!
15+
watch(() => route.name, (newValue, oldValue): void => {
16+
if(newValue === 'index' && oldValue !== 'index') {
17+
location.reload();
18+
}
819
});
920
1021
</script>
1122

1223
<template>
1324
<main :class="{'lang-ar': locale === 'ar'}">
14-
<Project />
25+
<Project :project="project" />
1526
</main>
1627
</template>
1728

0 commit comments

Comments
 (0)