Skip to content

Commit

Permalink
clean up meta
Browse files Browse the repository at this point in the history
  • Loading branch information
Mogge committed Mar 27, 2024
1 parent 920c6d4 commit d06eed8
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 16 deletions.
4 changes: 1 addition & 3 deletions frontend/.env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,4 @@ PUBLIC_ENV__ENDPOINTS__GRAPHQL_URI=http://localhost:4000/

# META
PUBLIC_ENV__META__BASE_URL="http://localhost:3000"
PUBLIC_ENV__META__DEFAULT_AUTHOR="IT Team 4 Change"
PUBLIC_ENV__META__DEFAULT_DESCRIPTION="IT4C Frontend Boilerplate"
PUBLIC_ENV__META__DEFAULT_TITLE="IT4C"
PUBLIC_ENV__META__DEFAULT_AUTHOR="DreamMall Verlag GbR"
7 changes: 4 additions & 3 deletions frontend/renderer/utils.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
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 }
4 changes: 1 addition & 3 deletions frontend/src/env.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ describe('env', () => {
it('has correct default values', () => {
expect(META).toEqual({
BASE_URL: 'http://localhost:3000',
DEFAULT_AUTHOR: 'IT Team 4 Change',
DEFAULT_DESCRIPTION: 'IT4C Frontend Boilerplate',
DEFAULT_TITLE: 'IT4C',
DEFAULT_AUTHOR: 'DreamMall Verlag GbR',
})
})
})
5 changes: 1 addition & 4 deletions frontend/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ const ENDPOINTS = {
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 ??
'IT Team 4 Change') as string,
DEFAULT_DESCRIPTION: (import.meta.env.PUBLIC_ENV__META__DEFAULT_DESCRIPTION ??
'IT4C Frontend Boilerplate') as string,
DEFAULT_TITLE: (import.meta.env.PUBLIC_ENV__META__DEFAULT_TITLE ?? 'IT4C') as string,
'DreamMall Verlag GbR') as string,
}

export { AUTH, ENDPOINTS, META }
4 changes: 4 additions & 0 deletions frontend/src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,9 @@
"about": "Über",
"app": "Anwendung",
"home": "Daheim"
},
"meta": {
"defaultDescription": "Deine Reichweite Erweitern Alle Möglichkeiten Miteinander Ausschöpfen Lebensqualität Leben",
"defaultTitle": "DreamMall"
}
}
4 changes: 4 additions & 0 deletions frontend/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,9 @@
"about": "About",
"app": "App",
"home": "Home"
},
"meta": {
"defaultDescription": "Expanding your reach making the most of opportunities enhance quality of life together",
"defaultTitle": "DreamMall"
}
}
4 changes: 2 additions & 2 deletions frontend/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')
2 changes: 1 addition & 1 deletion frontend/src/pages/index/Page.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('IndexPage', () => {
})

it('title returns default title', () => {
expect(title).toBe('IT4C')
expect(title()).toBe('DreamMall')
})

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

0 comments on commit d06eed8

Please sign in to comment.