import { settings } from '@utils/config'; import { useRouter } from 'next/router'; export type BlogSettings = { /** * The number of posts per page. */ postsPerPage: number; }; export type CopyrightSettings = { /** * The copyright end year. */ end: string; /** * The copyright start year. */ start: string; }; export type LocaleSettings = { /** * The default locale. */ default: string; /** * The supported locales. */ supported: string[]; }; export type WebsiteSettings = { /** * The website name. */ name: string; /** * The website baseline. */ baseline: string; /** * The website copyright dates. */ copyright: CopyrightSettings; /** * The website admin email. */ email: string; /** * The website locales. */ locales: LocaleSettings; /** * The website url. */ url: string; }; export type UseSettingsReturn = { blog: BlogSettings; website: WebsiteSettings; }; /** * Retrieve the website and blog settings. * * @returns {UseSettingsReturn} - An object describing settings. */ const useSettings = (): UseSettingsReturn => { const { baseline, copyright, email, locales, name, postsPerPage, url } = settings; const router = useRouter(); const locale = router.locale || locales.defaultLocale; return { blog: { postsPerPage, }, website: { baseline: locale.startsWith('en') ? baseline.en : baseline.fr, copyright: { end: copyright.endYear, start: copyright.startYear, }, email, locales: { default: locales.defaultLocale, supported: locales.supported, }, name, url, }, }; }; export default useSettings; ponents/organisms/layout/posts-list.fixture.tsx?id=aa8c55e48f3cdbb52e3d24e6b2e71ac0f23ec13c'>treecommitdiffstats
path: root/src/components/organisms/layout/posts-list.fixture.tsx
blob: 97a746f43774b4612e674c8b3aebc34c73fdc2cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63