@eox/pages-theme-esa 0.4.0 → 0.5.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eox/pages-theme-esa",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "type": "module",
5
5
  "description": "Vitepress Theme with ESA branding",
6
6
  "main": "src/index.js",
package/src/Layout.vue CHANGED
@@ -1,5 +1,5 @@
1
1
  <script setup>
2
- import { onMounted } from "vue";
2
+ import { onMounted, watch } from "vue";
3
3
  import { useData, useRouter } from "vitepress";
4
4
  import DefaultTheme from "vitepress/theme";
5
5
  import { applyShadowDomEventListener } from "./helpers";
@@ -10,19 +10,22 @@ const router = useRouter();
10
10
 
11
11
  onMounted(async () => {
12
12
  setTimeout(() => {
13
- document.querySelector("esa-cookies").addEventListener("accept", () => {
14
- _paq.push(["rememberCookieConsentGiven"]);
15
- });
16
- document.querySelector("esa-cookies").addEventListener("decline", () => {
17
- _paq.push(["forgetCookieConsentGiven"]);
18
- _paq.push(["optUserOut"]);
19
- });
13
+ const cookieBanner = document.querySelector("esa-cookies");
14
+ if (cookieBanner) {
15
+ cookieBanner.addEventListener("accept", () => {
16
+ _paq.push(["rememberCookieConsentGiven"]);
17
+ });
18
+ cookieBanner.addEventListener("decline", () => {
19
+ _paq.push(["forgetCookieConsentGiven"]);
20
+ _paq.push(["optUserOut"]);
21
+ });
20
22
 
21
- if (
22
- !document.cookie.includes("mtm_cookie_consent") &&
23
- !document.cookie.includes("mtm_consent_removed")
24
- ) {
25
- document.querySelector("esa-cookies").style.display = "block";
23
+ if (
24
+ !document.cookie.includes("mtm_cookie_consent") &&
25
+ !document.cookie.includes("mtm_consent_removed")
26
+ ) {
27
+ cookieBanner.style.display = "block";
28
+ }
26
29
  }
27
30
 
28
31
  // TRACK PAGE SCROLL
@@ -60,6 +63,18 @@ onMounted(async () => {
60
63
  }
61
64
  };
62
65
 
66
+ watch(
67
+ () => router.route.data.relativePath,
68
+ () => {
69
+ if (!window._paq) return;
70
+ _paq.push(["setCustomUrl", router.route.path]);
71
+ _paq.push(["setDocumentTitle", router.route.data.title]);
72
+ _paq.push(["trackPageView"]);
73
+ _paq.push(["enableLinkTracking"]);
74
+ },
75
+ { immediate: true },
76
+ );
77
+
63
78
  applyShadowDomEventListener(
64
79
  [
65
80
  "esa-menu",
@@ -86,13 +101,13 @@ onMounted(async () => {
86
101
  <ClientOnly>
87
102
  <slot name="layout-top"></slot>
88
103
  <esa-menu
89
- .menuItems="theme.nav.map(n => ({title: n.text, href: n.link}))"
104
+ .menuItems="theme.nav.map((n) => ({ title: n.text, href: n.link }))"
90
105
  :enable-login="theme.login"
91
106
  ></esa-menu>
92
107
  <esa-header></esa-header>
93
108
  <esa-navbar
94
109
  :brand-title="site.title"
95
- .menuItems="theme.nav.map(n => ({title: n.text, href: n.link}))"
110
+ .menuItems="theme.nav.map((n) => ({ title: n.text, href: n.link }))"
96
111
  :enable-login="theme.login"
97
112
  ></esa-navbar>
98
113
  </ClientOnly>
@@ -104,92 +119,90 @@ onMounted(async () => {
104
119
  :title="frontmatter.hero.text"
105
120
  :background-image="frontmatter.hero.image"
106
121
  :underline="frontmatter.hero.tagline"
107
- cta
108
- :cta-link="frontmatter.hero.actions[0].link"
109
- :cta-text="frontmatter.hero.actions[0].text"
122
+ :cta="frontmatter.hero.actions?.[0]"
123
+ :cta-link="frontmatter.hero.actions?.[0]?.link"
124
+ :cta-text="frontmatter.hero.actions?.[0]?.text"
110
125
  ></esa-cover>
111
126
  </ClientOnly>
112
127
  </template>
113
128
  <template #layout-bottom>
114
129
  <ClientOnly>
115
130
  <esa-gateway
116
- .items='[
117
- {
118
- title: "ESA Vision",
119
- links: [
120
- {
121
- name: "EO Science Strategy",
122
- href: "https://doi.org/10.5281/zenodo.13819557",
123
- },
124
- ],
125
- },
126
- {
127
- title: "ESA EO Programme",
128
- links: [
129
- {
130
- name: "Observing the Earth",
131
- href: "https://www.esa.int/Applications/Observing_the_Earth",
132
- },
133
- {
134
- name: "Science for Society",
135
- href: "https://eo4society.esa.int",
136
- },
137
- ],
138
- },
139
- {
140
- title: "Research at ESA",
141
- links: [
142
-
131
+ .items="[
143
132
  {
144
- name: "Earth System Science Hub",
145
- href: "https://sciencehub.esa.int",
133
+ title: 'ESA Vision',
134
+ links: [
135
+ {
136
+ name: 'EO Science Strategy',
137
+ href: 'https://doi.org/10.5281/zenodo.13819557',
138
+ },
139
+ ],
146
140
  },
147
- ],
148
- },
149
- {
150
- title: "Opportunities",
151
- links: [
152
-
153
141
  {
154
- name: "Network of Resources",
155
- href: "https://nor-discover.org",
142
+ title: 'ESA EO Programme',
143
+ links: [
144
+ {
145
+ name: 'Observing the Earth',
146
+ href: 'https://www.esa.int/Applications/Observing_the_Earth',
147
+ },
148
+ {
149
+ name: 'Science for Society',
150
+ href: 'https://eo4society.esa.int',
151
+ },
152
+ ],
156
153
  },
157
- ],
158
- },
159
- ]'
154
+ {
155
+ title: 'Research at ESA',
156
+ links: [
157
+ {
158
+ name: 'Earth System Science Hub',
159
+ href: 'https://sciencehub.esa.int',
160
+ },
161
+ ],
162
+ },
163
+ {
164
+ title: 'Opportunities',
165
+ links: [
166
+ {
167
+ name: 'Network of Resources',
168
+ href: 'https://nor-discover.org',
169
+ },
170
+ ],
171
+ },
172
+ ]"
160
173
  ></esa-gateway>
161
174
  <esa-footer
162
175
  title="Get in touch"
163
176
  description="Join ESA's initiative to ensure long-term preservation and accessibility of research data, code, and documentation for a global scientific community."
164
- contact-link="mailto:earthcode@esa.int"
177
+ contact-link="mailto:earth-code@esa.int"
165
178
  .footerItems="[
166
- [
167
- {
168
- href: 'https://www.esa.int/',
169
- title: 'ESA Portal',
170
- },
171
- {
172
- href: 'https://www.esa.int/About_Us/Corporate_news',
173
- title: 'About ESA',
174
- },
175
- ],
176
- [
177
- {
178
- href: 'https://www.esa.int/Services/Terms_and_conditions',
179
- title: 'Terms and Conditions',
180
- },
181
- {
182
- href: 'https://www.esa.int/Services/Cookies_notice',
183
- title: 'Cookies Notice',
184
- },
185
- ],
186
- [
187
- {
188
- href: 'https://www.esa.int/Services/Privacy_notice',
189
- title: 'Privacy Notice',
190
- },
191
- ],
192
- ]"
179
+ [
180
+ {
181
+ href: 'https://www.esa.int/',
182
+ title: 'ESA Portal',
183
+ },
184
+ {
185
+ href: 'https://www.esa.int/About_Us/Corporate_news',
186
+ title: 'About ESA',
187
+ },
188
+ ],
189
+ [
190
+ {
191
+ href: 'https://www.esa.int/Services/Terms_and_conditions',
192
+ title: 'Terms and Conditions',
193
+ },
194
+ {
195
+ href: 'https://www.esa.int/Services/Cookies_notice',
196
+ title: 'Cookies Notice',
197
+ },
198
+ ],
199
+ [
200
+ {
201
+ href: 'https://www.esa.int/Services/Privacy_notice',
202
+ title: 'Privacy Notice',
203
+ },
204
+ ],
205
+ ]"
193
206
  ></esa-footer>
194
207
  <esa-cookies
195
208
  link="https://www.esa.int/Services/Cookies_notice"
@@ -1,13 +1,19 @@
1
1
  <script setup>
2
2
  import { data as blogposts } from "../blogposts.data.js";
3
+
4
+ const props = defineProps({
5
+ maxPosts: { type: Number, default: Infinity },
6
+ });
3
7
  </script>
4
8
 
5
9
  <template>
6
10
  <esa-cards>
7
11
  <esa-card
8
- v-for="(blogpost, index) in blogposts.sort((a, b) =>
9
- new Date(a.frontmatter.date) < new Date(b.frontmatter.date) ? 1 : -1,
10
- )"
12
+ v-for="(blogpost, index) in blogposts
13
+ .sort((a, b) =>
14
+ new Date(a.frontmatter.date) < new Date(b.frontmatter.date) ? 1 : -1,
15
+ )
16
+ .slice(0, props.maxPosts)"
11
17
  :feature="blogpost.frontmatter.feature"
12
18
  overline="Story"
13
19
  :image="blogpost.frontmatter.image"