@eox/pages-theme-eox 1.0.0 → 1.1.1

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,90 @@ 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
+ `<span class="middle-align">
109
+ Powered by
110
+ <a href="https://hub.eox.at" target="_blank" class="left-margin small-margin"
111
+ ><img
112
+ src="https://hub.eox.at/hub/custom/logos/eoxhub.svg"
113
+ style="height: 25px" /></a
114
+ ></span>`,
115
+ copyright:
116
+ brandConfig.theme?.footer?.copyright ||
117
+ 'Copyright © 2014-present <a href="https://eox.at" target="_blank">EOX IT Services GmbH</a>',
118
+ },
107
119
  },
108
- },
109
- title: brandConfig.meta?.title,
110
- vite: {
111
- ssr: {
112
- noExternal: ["@eox/pages-theme-eox"],
120
+ title: brandConfig.meta?.title,
121
+ vite: {
122
+ ssr: {
123
+ noExternal: ["@eox/pages-theme-eox"],
124
+ },
113
125
  },
114
- },
115
- vue: {
116
- template: {
117
- compilerOptions: {
118
- isCustomElement: (tag) => {
119
- return tag.toLowerCase().includes("-");
126
+ vue: {
127
+ template: {
128
+ compilerOptions: {
129
+ isCustomElement: (tag) => {
130
+ return tag.toLowerCase().includes("-");
131
+ },
120
132
  },
121
133
  },
122
134
  },
123
- },
124
- });
135
+ };
136
+
137
+ if (brandConfig.i18n?.locale) {
138
+ const localeEntries = Object.entries(brandConfig.i18n.locale);
139
+ const currentLocale = brandConfig.i18n.currentLocale || "en";
140
+
141
+ if (localeEntries.length > 1) {
142
+ config.locales = Object.fromEntries(
143
+ localeEntries.map(([key, i18n]) => {
144
+ const isRoot = key === currentLocale;
145
+ return [
146
+ isRoot ? "root" : key,
147
+ {
148
+ label: key.toUpperCase(),
149
+ lang: key,
150
+ themeConfig: {
151
+ i18n,
152
+ ...(i18n.footer
153
+ ? { footer: { ...config.themeConfig.footer, ...i18n.footer } }
154
+ : {}),
155
+ },
156
+ },
157
+ ];
158
+ }),
159
+ );
160
+ } else {
161
+ const i18n =
162
+ brandConfig.i18n.locale[currentLocale] || localeEntries[0][1];
163
+ config.themeConfig.i18n = i18n;
164
+ if (i18n.footer) {
165
+ config.themeConfig.footer = {
166
+ ...config.themeConfig.footer,
167
+ ...i18n.footer,
168
+ };
169
+ }
170
+ }
171
+ } else if (brandConfig.i18n) {
172
+ config.themeConfig.i18n = brandConfig.i18n;
173
+ }
174
+
175
+ return config;
176
+ };