Skip to content

Commit d3023b1

Browse files
committed
Change language graphql to be read from url instead of cookie so it works with open graph
1 parent ce81f8e commit d3023b1

File tree

4 files changed

+21
-25
lines changed

4 files changed

+21
-25
lines changed

frontend/user/src/routes/[lang]/+page.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
import graphql from '$lib/utilities/api.js'
22
import { error } from '@sveltejs/kit';
33

4-
export const load = async ({ fetch, parent }) => {
5-
const { selectedLanguage } = await parent();
6-
const english = selectedLanguage === 'en';
4+
export const load = async ({ fetch, params }) => {
5+
const spanish = params.lang === 'es';
76

87
const query = `
98
query mainPageImages {
109
mainPageImages {
1110
filename
1211
imageUrl
13-
altText: ${english ? 'altTextEn' : 'altTextEs'}
12+
altText: ${spanish ? 'altTextEs' : 'altTextEn'}
1413
mainImageConfig {
15-
description: ${english ? 'descriptionEn' : 'descriptionEs'}
14+
description: ${spanish ? 'descriptionEs' : 'descriptionEn'}
1615
descriptionFont
1716
descriptionAlignment
1817
descriptionFontSize

frontend/user/src/routes/[lang]/esculturas/+page.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
import graphql from "$lib/utilities/api";
22
import { error } from "@sveltejs/kit";
33

4-
export const load = async ({ fetch, parent }) => {
5-
const { selectedLanguage } = await parent();
6-
const english = selectedLanguage === 'en';
4+
export const load = async ({ fetch, params }) => {
5+
const spanish = params.lang === 'es';
76

87
const query = `
98
query {
109
sculptures {
1110
filename
1211
imageUrl
13-
altText: ${english ? 'altTextEn' : 'altTextEs'}
12+
altText: ${spanish ? 'altTextEs' : 'altTextEn'}
1413
sculptureData {
15-
description: ${english ? 'descriptionEn' : 'descriptionEs'}
14+
description: ${spanish ? 'descriptionEs' : 'descriptionEn'}
1615
bgColor
1716
}
1817
desktopConfig {

frontend/user/src/routes/[lang]/proyectos/+page.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
import graphql from '$lib/utilities/api.js'
22
import { error } from '@sveltejs/kit';
33

4-
export const load = async ({ fetch, parent }) => {
5-
const { selectedLanguage } = await parent();
6-
const english = selectedLanguage == 'en';
4+
export const load = async ({ fetch, params }) => {
5+
const spanish = params.lang == 'es';
76

87
const query = `
98
query projects {
109
projects {
1110
id
12-
name: ${english ? 'nameEn' : 'nameEs'}
11+
name: ${spanish ? 'nameEs' : 'nameEn'}
1312
thumbnail {
1413
filename
1514
imageUrl
16-
altText: ${english ? 'altTextEn' : 'altTextEs'}
15+
altText: ${spanish ? 'altTextEs' : 'altTextEn'}
1716
altTextEn
1817
}
1918
}

frontend/user/src/routes/[lang]/proyectos/[ProyectoID]/+page.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
11
import graphql from '$lib/utilities/api.js'
22
import { error } from '@sveltejs/kit';
33

4-
export const load = async ({ params, fetch, parent }) => {
5-
const { selectedLanguage } = await parent();
6-
const english = selectedLanguage === 'en';
4+
export const load = async ({ params, fetch }) => {
5+
const spanish = params.lang === 'es';
76

87
const query = `
98
query getProject($id: Int!) {
109
project(id: $id) {
1110
id
12-
name: ${english ? 'nameEn' : 'nameEs'}
13-
description: ${english ? 'descriptionEn' : 'descriptionEs'}
11+
name: ${spanish ? 'nameEs' : 'nameEn'}
12+
description: ${spanish ? 'descriptionEs' : 'descriptionEn'}
1413
area
1514
thumbnail {
1615
filename
1716
imageUrl
18-
altText: ${english ? 'altTextEs' : 'altTextEs'}
17+
altText: ${spanish ? 'altTextEs' : 'altTextEn'}
1918
}
2019
spaces {
2120
id
2221
name
2322
images {
2423
filename
2524
imageUrl
26-
altText: ${english ? 'altTextEs' : 'altTextEn'}
27-
description: ${english ? 'descriptionEn' : 'descriptionEs'}
25+
altText: ${spanish ? 'altTextEs' : 'altTextEn'}
26+
description: ${spanish ? 'descriptionEs' : 'descriptionEn'}
2827
descriptionFont
2928
bgColor
3029
phoneConfig {
@@ -76,12 +75,12 @@ export const load = async ({ params, fetch, parent }) => {
7675

7776
const projectId = Number(params.ProyectoID);
7877

79-
if (!Number.isInteger(projectId)) error(404, english ? 'Project not found' : "Proyecto inexistente");
78+
if (!Number.isInteger(projectId)) error(404, spanish ? "Proyecto inexistente" : 'Project not found');
8079

8180
const data = await graphql(query, { id: projectId }, fetch);
8281

8382
const projectData = data?.project;
84-
if (!projectData) error(404, english ? 'Project not found' : "Proyecto inexistente");
83+
if (!projectData) error(404, spanish ? "Proyecto inexistente" : 'Project not found');
8584

8685
const currentProjectIndex: number = data.projects.findIndex((project: { id: number }) => project.id === projectData.id);
8786

0 commit comments

Comments
 (0)