Skip to content

Commit

Permalink
Merge branch 'master' into 208-feat-change-url-on-language-switch
Browse files Browse the repository at this point in the history
  • Loading branch information
ulfgebhardt authored Mar 26, 2024
2 parents 6e70e04 + 182d930 commit fb0b132
Show file tree
Hide file tree
Showing 20 changed files with 70 additions and 36 deletions.
2 changes: 0 additions & 2 deletions presenter/.env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,3 @@ PUBLIC_ENV__ENDPOINTS__GRAPHQL_URI=http://localhost:4000/
# META
PUBLIC_ENV__META__BASE_URL="http://localhost:3000"
PUBLIC_ENV__META__DEFAULT_AUTHOR="DreamMall Verlag GbR"
PUBLIC_ENV__META__DEFAULT_DESCRIPTION="Deine Reichweite Erweitern Alle Möglichkeiten Miteinander Ausschöpfen Lebensqualität Leben"
PUBLIC_ENV__META__DEFAULT_TITLE="DreamMall"
6 changes: 3 additions & 3 deletions presenter/renderer/utils.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { PageContext } from 'vike/types'

import { META } from '#src/env'
import i18n from '#plugins/i18n'

function getTitle(pageContext: PageContext) {
// The value exported by /pages/**/+title.js is available at pageContext.config.title
const val = pageContext.config.title
if (typeof val === 'string') return val
if (typeof val === 'function') return String(val(pageContext))
return META.DEFAULT_TITLE
return i18n.global.t('meta.defaultTitle')
}
function getDescription(pageContext: PageContext) {
const val = pageContext.config.description
if (typeof val === 'string') return val
if (typeof val === 'function') return val(pageContext)
return META.DEFAULT_DESCRIPTION
return i18n.global.t('meta.defaultDescription')
}

export { getTitle, getDescription }
3 changes: 0 additions & 3 deletions presenter/src/env.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ describe('env', () => {
expect(META).toEqual({
BASE_URL: 'http://localhost:3000',
DEFAULT_AUTHOR: 'DreamMall Verlag GbR',
DEFAULT_DESCRIPTION:
'Deine Reichweite Erweitern Alle Möglichkeiten Miteinander Ausschöpfen Lebensqualität Leben',
DEFAULT_TITLE: 'DreamMall',
})
})
})
3 changes: 0 additions & 3 deletions presenter/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ const META = {
BASE_URL: (import.meta.env.PUBLIC_ENV__META__BASE_URL ?? 'http://localhost:3000') as string,
DEFAULT_AUTHOR: (import.meta.env.PUBLIC_ENV__META__DEFAULT_AUTHOR ??
'DreamMall Verlag GbR') as string,
DEFAULT_DESCRIPTION: (import.meta.env.PUBLIC_ENV__META__DEFAULT_DESCRIPTION ??
'Deine Reichweite Erweitern Alle Möglichkeiten Miteinander Ausschöpfen Lebensqualität Leben') as string,
DEFAULT_TITLE: (import.meta.env.PUBLIC_ENV__META__DEFAULT_TITLE ?? 'DreamMall') as string,
}

export { AUTH, ENDPOINTS, META }
19 changes: 14 additions & 5 deletions presenter/src/locales/de.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"about": {},
"auth": {
"content": "Logge ein..."
"content": "Logge ein...",
"title": "DreamMall {'|'} Authentifizierung"
},
"dataProtection": {
"euDispute": {
Expand All @@ -26,7 +27,8 @@
"revocation": {
"content": "Nur mit Ihrer ausdrücklichen Einwilligung sind einige Vorgänge der Datenverarbeitung möglich. Ein Widerruf Ihrer bereits erteilten Einwilligung ist jederzeit möglich. Für den Widerruf genügt eine formlose Mitteilung per E-Mail. Die Rechtmäßigkeit der bis zum Widerruf erfolgten Datenverarbeitung bleibt vom Widerruf unberührt.",
"headline": "Widerruf Ihrer Einwilligung zur Datenverarbeitung"
}
},
"title": "DreamMall {'|'} Datenschutz"
},
"error": {
"404": {
Expand All @@ -36,7 +38,8 @@
"500": {
"h1": "500 Interner Fehler",
"text": "Etwas ist schief gegangen."
}
},
"title": "DreamMall {'|'} Fehler"
},
"home": {
"aboutSection": {
Expand Down Expand Up @@ -161,7 +164,8 @@
"content": "Umsatzsteuer-Identifikationsnummer gemäß § 27 a Umsatzsteuergesetz:",
"headline": "Umsatzsteuer-ID",
"id": "DE356946303"
}
},
"title": "DreamMall {'|'} Impressum"
},
"menu": {
"eMail": "E-Mail",
Expand Down Expand Up @@ -202,14 +206,19 @@
"sitemap": "Sitemap"
}
},
"meta": {
"defaultDescription": "Deine Reichweite Erweitern Alle Möglichkeiten Miteinander Ausschöpfen Lebensqualität Leben",
"defaultTitle": "DreamMall"
},
"optin": {
"error": {
"link": "Erneut eintragen",
"text": "Bei der Bestätigung ist ein Fehler aufgetreten. Bitte tragen Sie sich erneut in den Newsletter ein."
},
"success": {
"text": "Sie haben Ihr Newsletterabbonoment erfolgreich bestätigt. Sie werden in Kürze auf die Startseite weitergeleitet."
}
},
"title": "DreamMall {'|'} Newsletter"
},
"validation": {
"fieldNoEmail": "Dieses Feld muss eine Email-Adresse sein.",
Expand Down
19 changes: 14 additions & 5 deletions presenter/src/locales/en.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"about": {},
"auth": {
"content": "Logging in..."
"content": "Logging in...",
"title": "DreamMall {'|'} Authentication"
},
"dataProtection": {
"euDispute": {
Expand All @@ -26,7 +27,8 @@
"revocation": {
"content": "Some data processing operations are only possible with your express consent. You can withdraw your consent at any time. An informal notification by e-mail is sufficient for the revocation. The legality of the data processing carried out until the revocation remains unaffected by the revocation.",
"headline": "Withdrawal of your consent to data processing"
}
},
"title": "DreamMall {'|'} Privacy Policy"
},
"error": {
"404": {
Expand All @@ -36,7 +38,8 @@
"500": {
"h1": "500 Internal error",
"text": "Something went wrong."
}
},
"title": "DreamMall {'|'} Error"
},
"home": {
"aboutSection": {
Expand Down Expand Up @@ -161,7 +164,8 @@
"content": "Sales tax identification number according to § 27 a sales tax law:",
"headline": "Sales tax ID",
"id": "DE356946303"
}
},
"title": "DreamMall {'|'} Imprint"
},
"menu": {
"eMail": "E-Mail",
Expand Down Expand Up @@ -202,14 +206,19 @@
"sitemap": "Sitemap"
}
},
"meta": {
"defaultDescription": "Expanding your reach making the most of opportunities enhance quality of life together",
"defaultTitle": "DreamMall"
},
"optin": {
"error": {
"link": "Register again",
"text": "An error occurred during confirmation. Please subscribe to the newsletter again."
},
"success": {
"text": "You have successfully confirmed your newsletter subscription. You will be redirected to the start page shortly."
}
},
"title": "DreamMall {'|'} Newsletter"
},
"validation": {
"fieldNoEmail": "This field must be an email address",
Expand Down
4 changes: 3 additions & 1 deletion presenter/src/pages/_error/+title.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export const title = 'DreamMall | Fehler'
import i18n from '#plugins/i18n'

export const title = () => i18n.global.t('error.title')
4 changes: 3 additions & 1 deletion presenter/src/pages/_error/Page.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import { describe, it, expect, beforeEach } from 'vitest'
import { Component, h } from 'vue'
import { VApp } from 'vuetify/components'

import i18n from '#plugins/i18n'

import ErrorPage from './+Page.vue'
import { title } from './+title'

describe('ErrorPage', () => {
it('title returns correct title', () => {
expect(title).toBe('DreamMall | Fehler')
expect(title()).toBe(i18n.global.t('error.title'))
})
describe('500 Error', () => {
const WrapperUndefined = () => {
Expand Down
4 changes: 3 additions & 1 deletion presenter/src/pages/auth/+title.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export const title = 'DreamMall | Authentifizierung'
import i18n from '#plugins/i18n'

export const title = () => i18n.global.t('auth.title')
3 changes: 2 additions & 1 deletion presenter/src/pages/auth/Page.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { describe, it, expect, beforeEach, vi } from 'vitest'
import { Component, h } from 'vue'
import { VApp } from 'vuetify/components'

import i18n from '#plugins/i18n'
import { useAuthStore } from '#stores/authStore'
import { authService } from '#tests/mock.authService'

Expand Down Expand Up @@ -51,7 +52,7 @@ describe('AuthPage', () => {
})

it('title returns correct title', () => {
expect(title).toBe('DreamMall | Authentifizierung')
expect(title()).toBe(i18n.global.t('auth.title'))
})

it('renders', () => {
Expand Down
4 changes: 3 additions & 1 deletion presenter/src/pages/datenschutz/+title.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export const title = 'DreamMall | Datenschutz'
import i18n from '#plugins/i18n'

export const title = () => i18n.global.t('dataProtection.title')
4 changes: 3 additions & 1 deletion presenter/src/pages/datenschutz/Page.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { describe, it, expect } from 'vitest'
import { Component, h } from 'vue'
import { VApp } from 'vuetify/components'

import i18n from '#plugins/i18n'

import DataPrivacyPage from './+Page.vue'
import { title } from './+title'

Expand All @@ -14,7 +16,7 @@ describe('DataPrivacyPage', () => {
})

it('title returns correct title', () => {
expect(title).toBe('DreamMall | Datenschutz')
expect(title()).toBe(i18n.global.t('dataProtection.title'))
})

it('renders', () => {
Expand Down
4 changes: 3 additions & 1 deletion presenter/src/pages/impressum/+title.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export const title = 'DreamMall | Impressum'
import i18n from '#plugins/i18n'

export const title = () => i18n.global.t('impress.title')
4 changes: 3 additions & 1 deletion presenter/src/pages/impressum/Page.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { describe, it, expect } from 'vitest'
import { Component, h } from 'vue'
import { VApp } from 'vuetify/components'

import i18n from '#plugins/i18n'

import ImpressumPage from './+Page.vue'
import { title } from './+title'

Expand All @@ -14,7 +16,7 @@ describe('ImpressumPage', () => {
})

it('title returns correct title', () => {
expect(title).toBe('DreamMall | Impressum')
expect(title()).toBe(i18n.global.t('impress.title'))
})

it('renders', () => {
Expand Down
4 changes: 2 additions & 2 deletions presenter/src/pages/index/+title.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { META } from '#src/env'
import i18n from '#plugins/i18n'

export const title = META.DEFAULT_TITLE
export const title = () => i18n.global.t('meta.defaultTitle')
4 changes: 3 additions & 1 deletion presenter/src/pages/index/Page.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { describe, it, expect } from 'vitest'
import { Component, h } from 'vue'
import { VApp } from 'vuetify/components'

import i18n from '#plugins/i18n'

import IndexPage from './+Page.vue'
import { title } from './+title'

Expand All @@ -14,7 +16,7 @@ describe('IndexPage', () => {
})

it('title returns default title', () => {
expect(title).toBe('DreamMall')
expect(title()).toBe(i18n.global.t('meta.defaultTitle'))
})

it('renders', () => {
Expand Down
5 changes: 4 additions & 1 deletion presenter/src/pages/optin/+title.ts
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
export const title = 'DreamMall | Newsletter'
import i18n from '#plugins/i18n'

// 'DreamMall | Newsletter'
export const title = () => i18n.global.t('optin.title')
3 changes: 2 additions & 1 deletion presenter/src/pages/optin/Page.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Component, h } from 'vue'
import { VApp } from 'vuetify/components'

import { confirmNewsletter } from '#mutations/confirmNewsletter'
import i18n from '#plugins/i18n'
import { mockClient } from '#tests/mock.apolloClient'

import OptinPage from './+Page.vue'
Expand Down Expand Up @@ -45,7 +46,7 @@ describe('OptinPage', () => {
})

it('title returns correct title', () => {
expect(title).toBe('DreamMall | Newsletter')
expect(title()).toBe(i18n.global.t('optin.title'))
})

it('route returns `/optin/@code', () => {
Expand Down
4 changes: 3 additions & 1 deletion presenter/src/pages/silent-refresh/+title.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export const title = 'DreamMall | Authentifizierung'
import i18n from '#plugins/i18n'

export const title = () => i18n.global.t('auth.title')
3 changes: 2 additions & 1 deletion presenter/src/pages/silent-refresh/Page.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest'
import { Component, h } from 'vue'
import { VApp } from 'vuetify/components'

import i18n from '#plugins/i18n'
import { authService } from '#tests/mock.authService'

import SilentRefreshPage from './+Page.vue'
Expand Down Expand Up @@ -31,7 +32,7 @@ describe('SilentRefreshPage', () => {
})

it('title returns correct title', () => {
expect(title).toBe('DreamMall | Authentifizierung')
expect(title()).toBe(i18n.global.t('auth.title'))
})

it('renders', () => {
Expand Down

0 comments on commit fb0b132

Please sign in to comment.