@eox/pages-theme-eox 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,70 +4,71 @@
4
4
  * @param {object} brandConfig The brand config
5
5
  * @returns
6
6
  */
7
- export const generate = (brandConfig) => ({
8
- appearance: false,
9
- cleanUrls: true,
10
- description: brandConfig.meta?.description,
11
- head: [
12
- ["link", { rel: "icon", href: brandConfig.meta?.favicon }],
13
- // Open Graph / Facebook
14
- ["meta", { property: "og:type", content: "website" }],
15
- [
16
- "meta",
17
- {
18
- property: "og:url",
19
- content: brandConfig.home,
20
- },
21
- ],
22
- ["meta", { property: "og:title", content: brandConfig.meta?.title }],
23
- [
24
- "meta",
25
- {
26
- property: "og:description",
27
- content: brandConfig.meta?.description,
28
- },
29
- ],
30
- // TODO
31
- // [
32
- // "meta",
33
- // {
34
- // property: "og:image",
35
- // content:
36
- // "https://earthcode.esa.int/img/EarthCODE_Herobanner_1920x1080.jpg",
37
- // },
38
- // ],
39
- // Twitter
40
- ["meta", { property: "twitter:card", content: "summary_large_image" }],
41
- [
42
- "meta",
43
- {
44
- property: "twitter:url",
45
- content: brandConfig.home,
46
- },
47
- ],
48
- ["meta", { property: "twitter:title", content: brandConfig.meta?.title }],
49
- [
50
- "meta",
51
- {
52
- property: "twitter:description",
53
- content: brandConfig.meta?.description,
54
- },
55
- ],
56
- // TODO
57
- // [
58
- // "meta",
59
- // {
60
- // property: "twitter:image",
61
- // content:
62
- // "https://earthcode.esa.int/img/EarthCODE_Herobanner_1920x1080.jpg",
63
- // },
64
- // ],
65
- ...(brandConfig.analytics
66
- ? [
67
- [
68
- "script",
69
- {},
70
- `
7
+ export const generate = (brandConfig) => {
8
+ const config = {
9
+ appearance: false,
10
+ cleanUrls: true,
11
+ description: brandConfig.meta?.description,
12
+ head: [
13
+ ["link", { rel: "icon", href: brandConfig.meta?.favicon }],
14
+ // Open Graph / Facebook
15
+ ["meta", { property: "og:type", content: "website" }],
16
+ [
17
+ "meta",
18
+ {
19
+ property: "og:url",
20
+ content: brandConfig.home,
21
+ },
22
+ ],
23
+ ["meta", { property: "og:title", content: brandConfig.meta?.title }],
24
+ [
25
+ "meta",
26
+ {
27
+ property: "og:description",
28
+ content: brandConfig.meta?.description,
29
+ },
30
+ ],
31
+ // TODO
32
+ // [
33
+ // "meta",
34
+ // {
35
+ // property: "og:image",
36
+ // content:
37
+ // "https://earthcode.esa.int/img/EarthCODE_Herobanner_1920x1080.jpg",
38
+ // },
39
+ // ],
40
+ // Twitter
41
+ ["meta", { property: "twitter:card", content: "summary_large_image" }],
42
+ [
43
+ "meta",
44
+ {
45
+ property: "twitter:url",
46
+ content: brandConfig.home,
47
+ },
48
+ ],
49
+ ["meta", { property: "twitter:title", content: brandConfig.meta?.title }],
50
+ [
51
+ "meta",
52
+ {
53
+ property: "twitter:description",
54
+ content: brandConfig.meta?.description,
55
+ },
56
+ ],
57
+ // TODO
58
+ // [
59
+ // "meta",
60
+ // {
61
+ // property: "twitter:image",
62
+ // content:
63
+ // "https://earthcode.esa.int/img/EarthCODE_Herobanner_1920x1080.jpg",
64
+ // },
65
+ // ],
66
+ ...(brandConfig.analytics
67
+ ? [
68
+ [
69
+ "script",
70
+ {},
71
+ `
71
72
  var _paq = (window._paq = window._paq || []);
72
73
  /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
73
74
  _paq.push(["requireCookieConsent"]);
@@ -86,39 +87,84 @@ export const generate = (brandConfig) => ({
86
87
  s.parentNode.insertBefore(g, s);
87
88
  })();
88
89
  `,
89
- ],
90
- ]
91
- : []),
92
- ],
93
- srcExclude: ["README.md"],
94
- themeConfig: {
95
- siteTitle: false,
96
- theme: {
97
- primaryColor: brandConfig.theme?.primary_color,
98
- secondaryColor:
99
- brandConfig.theme?.secondary_color || brandConfig.theme?.primary_color,
100
- brandConfig,
101
- },
102
- logo: { light: brandConfig.logo, dark: brandConfig.logo_dark },
103
- footer: {
104
- message: `Powered by <img src="https://cockpit.hub.eox.at/storage/uploads/eoxhub/eoxhub_icon.svg" style="display: inline; height: 20px; transform: translateY(5px)" />`,
105
- copyright:
106
- 'Copyright © 2014-present <a href="https://eox.at" target="_blank">EOX IT Services GmbH</a>',
90
+ ],
91
+ ]
92
+ : []),
93
+ ],
94
+ srcExclude: ["README.md"],
95
+ themeConfig: {
96
+ siteTitle: false,
97
+ theme: {
98
+ primaryColor: brandConfig.theme?.primary_color,
99
+ secondaryColor:
100
+ brandConfig.theme?.secondary_color ||
101
+ brandConfig.theme?.primary_color,
102
+ brandConfig,
103
+ },
104
+ logo: { light: brandConfig.logo, dark: brandConfig.logo_dark },
105
+ footer: {
106
+ message:
107
+ brandConfig.theme?.footer?.message ||
108
+ `Powered by <img src="https://cockpit.hub.eox.at/storage/uploads/eoxhub/eoxhub_icon.svg" style="display: inline; height: 20px; transform: translateY(5px)" />`,
109
+ copyright:
110
+ brandConfig.theme?.footer?.copyright ||
111
+ 'Copyright © 2014-present <a href="https://eox.at" target="_blank">EOX IT Services GmbH</a>',
112
+ },
107
113
  },
108
- },
109
- title: brandConfig.meta?.title,
110
- vite: {
111
- ssr: {
112
- noExternal: ["@eox/pages-theme-eox"],
114
+ title: brandConfig.meta?.title,
115
+ vite: {
116
+ ssr: {
117
+ noExternal: ["@eox/pages-theme-eox"],
118
+ },
113
119
  },
114
- },
115
- vue: {
116
- template: {
117
- compilerOptions: {
118
- isCustomElement: (tag) => {
119
- return tag.toLowerCase().includes("-");
120
+ vue: {
121
+ template: {
122
+ compilerOptions: {
123
+ isCustomElement: (tag) => {
124
+ return tag.toLowerCase().includes("-");
125
+ },
120
126
  },
121
127
  },
122
128
  },
123
- },
124
- });
129
+ };
130
+
131
+ if (brandConfig.i18n?.locale) {
132
+ const localeEntries = Object.entries(brandConfig.i18n.locale);
133
+ const currentLocale = brandConfig.i18n.currentLocale || "en";
134
+
135
+ if (localeEntries.length > 1) {
136
+ config.locales = Object.fromEntries(
137
+ localeEntries.map(([key, i18n]) => {
138
+ const isRoot = key === currentLocale;
139
+ return [
140
+ isRoot ? "root" : key,
141
+ {
142
+ label: key.toUpperCase(),
143
+ lang: key,
144
+ themeConfig: {
145
+ i18n,
146
+ ...(i18n.footer
147
+ ? { footer: { ...config.themeConfig.footer, ...i18n.footer } }
148
+ : {}),
149
+ },
150
+ },
151
+ ];
152
+ }),
153
+ );
154
+ } else {
155
+ const i18n =
156
+ brandConfig.i18n.locale[currentLocale] || localeEntries[0][1];
157
+ config.themeConfig.i18n = i18n;
158
+ if (i18n.footer) {
159
+ config.themeConfig.footer = {
160
+ ...config.themeConfig.footer,
161
+ ...i18n.footer,
162
+ };
163
+ }
164
+ }
165
+ } else if (brandConfig.i18n) {
166
+ config.themeConfig.i18n = brandConfig.i18n;
167
+ }
168
+
169
+ return config;
170
+ };