@eox/pages-theme-eox 2.0.0-alpha.1 → 2.0.0-alpha.10

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.
Files changed (47) hide show
  1. package/.gitlab-ci.yml +4 -1
  2. package/README.md +75 -11
  3. package/cypress/support/mocks/authors.data.js +14 -0
  4. package/cypress/support/mocks/helpers.js +65 -4
  5. package/cypress.config.js +9 -0
  6. package/package.json +3 -1
  7. package/src/Layout.vue +14 -3
  8. package/src/components/BlogList.vue +74 -55
  9. package/src/components/BlogPost.vue +46 -24
  10. package/src/components/CTASection.vue +18 -4
  11. package/src/components/FeatureCard/Index.vue +113 -26
  12. package/src/components/FeatureCard/Poster.vue +25 -3
  13. package/src/components/FeatureSection.cy.js +16 -0
  14. package/src/components/FeatureSection.vue +3 -8
  15. package/src/components/FeaturesGallery.vue +34 -2
  16. package/src/components/Footer.cy.js +52 -2
  17. package/src/components/Footer.vue +17 -5
  18. package/src/components/HeroSection.cy.js +20 -0
  19. package/src/components/HeroSection.vue +139 -24
  20. package/src/components/ImageCarousel.vue +11 -2
  21. package/src/components/ImageElement.vue +16 -4
  22. package/src/components/ImageGallery.vue +29 -4
  23. package/src/components/LogoSection.vue +26 -3
  24. package/src/components/MobileNavDropdown.vue +13 -3
  25. package/src/components/NavBar.cy.js +15 -0
  26. package/src/components/NavBar.vue +149 -21
  27. package/src/components/NavDropdown.vue +12 -2
  28. package/src/components/OpenPositions.vue +292 -0
  29. package/src/components/TagList.vue +32 -14
  30. package/src/components/TeamPage.vue +34 -20
  31. package/src/components/TestimonialsSection.cy.js +2 -5
  32. package/src/components/TestimonialsSection.vue +119 -16
  33. package/src/components/TextSection.cy.js +115 -0
  34. package/src/components/TextSection.vue +396 -0
  35. package/src/helpers.js +182 -37
  36. package/src/helpers.test.js +181 -0
  37. package/src/index.js +4 -0
  38. package/src/pages/author/[author].md +1 -0
  39. package/src/pages/author/[author].paths.js +2 -2
  40. package/src/pages/blog.md +1 -0
  41. package/src/pages/tag/[tag].md +1 -0
  42. package/src/pages/tag.md +1 -0
  43. package/src/pages/team.md +2 -1
  44. package/src/posts.data.js +39 -1
  45. package/src/style.css +232 -11
  46. package/src/tagUtils.js +5 -5
  47. package/src/vitepressConfig.mjs +6 -3
package/src/helpers.js CHANGED
@@ -1,28 +1,157 @@
1
1
  import { watch } from "vue";
2
2
 
3
3
  /**
4
- * Track Matomo event with array of four primary components
4
+ * Normalizes a URL / path for tracking by:
5
+ * - Removing trailing slash (e.g. `/explore/` -> `/explore`, except for root `/`)
6
+ * - Stripping transient / high-cardinality UI params (e.g., coordinates `x`, `y`, `z`)
7
+ * - Sorting remaining query parameters alphabetically
5
8
  *
6
- * - Category (Required) – This describes the type of events you want to track. For example, Link Clicks, Videos, Outbound Links, and Form Events.
7
- * - Action (Required) – This is the specific action that is taken. For example, with the Video category, you might have a Play, Pause and Complete action.
8
- * - Name (Optional – Recommended) – This is usually the title of the element that is being interacted with, to aid with analysis. For example, it could be the name of a Video that was played or the specific form that is being submitted.
9
- * - Value (Optional) – This is a numeric value and is often added dynamically. It could be the cost of a product that is added to a cart, or the completion percentage of a video.
9
+ * @param {string} inputUrl - The URL or relative path to normalize
10
+ * @param {Object} [options] - Normalization options
11
+ * @param {Array<string>} [options.ignoredParams] - Query parameter keys to strip
12
+ * @param {boolean} [options.stripTrailingSlash=true] - Whether to strip trailing slashes
13
+ * @returns {string} Normalized URL / path
14
+ */
15
+ export const normalizeTrackingUrl = (inputUrl, options = {}) => {
16
+ if (!inputUrl || typeof inputUrl !== "string") return inputUrl;
17
+ const { ignoredParams = ["x", "y", "z"], stripTrailingSlash = true } =
18
+ options;
19
+
20
+ try {
21
+ const base =
22
+ typeof window !== "undefined" && window.location?.href
23
+ ? window.location.href
24
+ : "https://eox.at";
25
+ const url = new URL(inputUrl, base);
26
+ let pathname = url.pathname;
27
+
28
+ if (stripTrailingSlash && pathname.length > 1 && pathname.endsWith("/")) {
29
+ pathname = pathname.replace(/\/+$/, "");
30
+ }
31
+
32
+ const searchParams = new URLSearchParams(url.search);
33
+ for (const key of ignoredParams) {
34
+ searchParams.delete(key);
35
+ }
36
+ searchParams.sort();
37
+
38
+ const search = searchParams.toString();
39
+ const isRelativeInput = !/^https?:\/\//i.test(inputUrl);
40
+
41
+ if (isRelativeInput) {
42
+ return pathname + (search ? `?${search}` : "");
43
+ }
44
+ url.pathname = pathname;
45
+ url.search = search ? `?${search}` : "";
46
+ return url.toString();
47
+ } catch {
48
+ if (stripTrailingSlash && inputUrl.length > 1 && inputUrl.endsWith("/")) {
49
+ return inputUrl.replace(/\/+$/, "");
50
+ }
51
+ return inputUrl;
52
+ }
53
+ };
54
+
55
+ /**
56
+ * Track Matomo event with array or positional arguments of four primary components:
57
+ * Category, Action, Name (optional), Value (optional)
58
+ *
59
+ * Automatically normalizes any path parameters (e.g., Action or Name).
10
60
  *
11
61
  * See https://matomo.org/faq/reports/the-anatomy-of-an-event/
12
62
  *
13
- * @param {Array<string>} eventDetails
63
+ * @param {Array<string|number>|string} eventDetails - Array of event details or Category string
64
+ * @param {...*} rest - Remaining event details if passed positionally
65
+ */
66
+ export const trackEvent = (eventDetails, ...rest) => {
67
+ if (typeof window === "undefined") return;
68
+ const _paq = (window._paq = window._paq || []);
69
+
70
+ const details = Array.isArray(eventDetails)
71
+ ? [...eventDetails]
72
+ : [eventDetails, ...rest];
73
+
74
+ if (typeof details[1] === "string" && details[1].startsWith("/")) {
75
+ details[1] = normalizeTrackingUrl(details[1]);
76
+ }
77
+ if (typeof details[2] === "string" && details[2].startsWith("/")) {
78
+ details[2] = normalizeTrackingUrl(details[2]);
79
+ }
80
+
81
+ _paq.push(["trackEvent", ...details]);
82
+ };
83
+
84
+ /**
85
+ * Track page view with normalized URL and standardized document title.
86
+ *
87
+ * @param {Object|string} [options] - Router instance, options object, or path string
88
+ * @param {string} [options.path] - Custom path to track
89
+ * @param {string} [options.title] - Custom document title to track
90
+ * @param {Object} [options.route] - VitePress router route object
14
91
  */
15
- export const trackEvent = (eventDetails) => {
16
- if (!import.meta.env.SSR) {
17
- _paq.push(["trackEvent", ...eventDetails]);
92
+ export const trackPageView = (options = {}) => {
93
+ if (typeof window === "undefined") return;
94
+ const _paq = (window._paq = window._paq || []);
95
+
96
+ let rawPath = "";
97
+ let rawTitle = "";
98
+
99
+ if (typeof options === "string") {
100
+ rawPath = options;
101
+ } else if (options && typeof options === "object") {
102
+ if (options.route) {
103
+ rawPath = options.route.path;
104
+ rawTitle = options.route.data?.title;
105
+ } else {
106
+ rawPath =
107
+ options.path ||
108
+ options.customUrl ||
109
+ (typeof window !== "undefined"
110
+ ? window.location.pathname + window.location.search
111
+ : "");
112
+ rawTitle =
113
+ options.title ||
114
+ options.customTitle ||
115
+ (typeof document !== "undefined" ? document.title : "");
116
+ }
18
117
  }
118
+
119
+ const normalizedUrl = normalizeTrackingUrl(rawPath);
120
+ if (normalizedUrl) {
121
+ _paq.push(["setCustomUrl", normalizedUrl]);
122
+ }
123
+ if (rawTitle) {
124
+ _paq.push(["setDocumentTitle", rawTitle.trim()]);
125
+ }
126
+ _paq.push(["trackPageView"]);
127
+ _paq.push(["enableLinkTracking"]);
128
+ };
129
+
130
+ /**
131
+ * Track site search keyword query in Matomo.
132
+ *
133
+ * @param {string} keyword - Searched term
134
+ * @param {string|boolean} [category=false] - Search category (e.g. 'stories', 'indicators')
135
+ * @param {number} [resultsCount=0] - Number of search results found
136
+ */
137
+ export const trackSiteSearch = (
138
+ keyword,
139
+ category = false,
140
+ resultsCount = 0,
141
+ ) => {
142
+ if (typeof window === "undefined") return;
143
+ const _paq = (window._paq = window._paq || []);
144
+ _paq.push(["trackSiteSearch", keyword, category, resultsCount]);
19
145
  };
20
146
 
21
147
  /**
22
148
  * Accept cookies
23
149
  */
24
150
  export const acceptCookies = (router) => {
25
- _paq.push(["rememberCookieConsentGiven"]);
151
+ if (typeof window !== "undefined") {
152
+ const _paq = (window._paq = window._paq || []);
153
+ _paq.push(["rememberCookieConsentGiven"]);
154
+ }
26
155
  showBanner(false);
27
156
  enableTracking(true, router);
28
157
  };
@@ -31,8 +160,11 @@ export const acceptCookies = (router) => {
31
160
  * Decline cookies
32
161
  */
33
162
  export const declineCookies = (router) => {
34
- _paq.push(["forgetCookieConsentGiven"]);
35
- _paq.push(["optUserOut"]);
163
+ if (typeof window !== "undefined") {
164
+ const _paq = (window._paq = window._paq || []);
165
+ _paq.push(["forgetCookieConsentGiven"]);
166
+ _paq.push(["optUserOut"]);
167
+ }
36
168
  showBanner(false);
37
169
  enableTracking(false, router);
38
170
  };
@@ -60,17 +192,24 @@ export const enableTracking = (enabled, router) => {
60
192
  };
61
193
 
62
194
  /**
63
- * Track page scrolling depth
195
+ * Track page scrolling depth with normalized path and numeric depth values.
64
196
  *
65
197
  * @param enabled Boolean
198
+ * @param router VitePress router
66
199
  */
67
200
  export const trackPageScrolling = (enabled, router) => {
68
201
  function getScrollPercent() {
69
- const h = document.documentElement,
70
- b = document.body,
71
- st = "scrollTop",
72
- sh = "scrollHeight";
73
- return ((h[st] || b[st]) / ((h[sh] || b[sh]) - h.clientHeight)) * 100;
202
+ try {
203
+ const h = document.documentElement,
204
+ b = document.body,
205
+ st = "scrollTop",
206
+ sh = "scrollHeight";
207
+ const scrollable = (h[sh] || b[sh]) - h.clientHeight;
208
+ if (scrollable <= 0) return 0;
209
+ return ((h[st] || b[st]) / scrollable) * 100;
210
+ } catch {
211
+ return 0;
212
+ }
74
213
  }
75
214
  const scrollTargets = {
76
215
  25: [],
@@ -79,17 +218,18 @@ export const trackPageScrolling = (enabled, router) => {
79
218
  100: [],
80
219
  };
81
220
  const scrollListener = () => {
221
+ const currentPath = normalizeTrackingUrl(router.route.path);
82
222
  Object.keys(scrollTargets).forEach((target) => {
83
223
  if (
84
- getScrollPercent() >= parseInt(target) &&
85
- !scrollTargets[target].includes(router.route.path)
224
+ getScrollPercent() >= parseInt(target, 10) &&
225
+ !scrollTargets[target].includes(currentPath)
86
226
  ) {
87
- scrollTargets[target].push(router.route.path);
227
+ scrollTargets[target].push(currentPath);
88
228
  trackEvent([
89
229
  "Interaction",
90
230
  "Scroll Depth",
91
- router.route.path,
92
- `${target}%`,
231
+ currentPath,
232
+ parseInt(target, 10),
93
233
  ]);
94
234
  }
95
235
  });
@@ -102,19 +242,16 @@ export const trackPageScrolling = (enabled, router) => {
102
242
  };
103
243
 
104
244
  /**
105
- * Track user navigation from one page to another
245
+ * Track user navigation from one page to another with normalized URLs.
106
246
  *
107
- * @param enabled Boolean
247
+ * @param router VitePress router
108
248
  */
109
249
  export const trackRouterNavigation = (router) => {
110
250
  const trackNavigation = () => {
111
- if (!document.cookie.includes("mtm_cookie_consent")) {
112
- return;
113
- }
114
- _paq.push(["setCustomUrl", router.route.path]);
115
- _paq.push(["setDocumentTitle", router.route.data.title]);
116
- _paq.push(["trackPageView"]);
117
- _paq.push(["enableLinkTracking"]);
251
+ trackPageView({
252
+ path: router.route.path,
253
+ title: router.route.data?.title,
254
+ });
118
255
  };
119
256
  watch(() => router.route.data.relativePath, trackNavigation, {
120
257
  immediate: true,
@@ -146,6 +283,8 @@ export const getFlatList = (items) => {
146
283
  * @returns {boolean}
147
284
  */
148
285
  export const isActive = (item, path) => {
286
+ if (!item || !path) return false;
287
+
149
288
  if (item.activeMatch) {
150
289
  try {
151
290
  return new RegExp(item.activeMatch).test(path);
@@ -155,20 +294,26 @@ export const isActive = (item, path) => {
155
294
  }
156
295
  }
157
296
 
158
- if (item.items) {
159
- return item.items.some((sub) => isActive(sub, path));
297
+ if (item.items && item.items.some((sub) => isActive(sub, path))) {
298
+ return true;
160
299
  }
161
300
 
162
301
  if (item.link) {
163
- const linkPath = item.link.replace(/\.html$/, "").replace(/\/$/, "");
164
- const currentPath = path.replace(/\.html$/, "").replace(/\/$/, "");
302
+ const normalize = (p) =>
303
+ decodeURI(p)
304
+ .replace(/[?#].*$/, "")
305
+ .replace(/\.html$/, "")
306
+ .replace(/\/$/, "");
307
+
308
+ const linkPath = normalize(item.link);
309
+ const currentPath = normalize(path);
165
310
 
166
311
  if (linkPath === currentPath) return true;
167
312
 
168
313
  // Special case for home page to avoid matching everything
169
314
  if (linkPath === "") return currentPath === "";
170
315
 
171
- return currentPath.startsWith(linkPath);
316
+ return currentPath === linkPath || currentPath.startsWith(linkPath + "/");
172
317
  }
173
318
 
174
319
  return false;
@@ -0,0 +1,181 @@
1
+ import { describe, it, beforeEach } from "node:test";
2
+ import assert from "node:assert/strict";
3
+ import {
4
+ normalizeTrackingUrl,
5
+ trackPageView,
6
+ trackEvent,
7
+ trackSiteSearch,
8
+ formatPrice,
9
+ t,
10
+ isActive,
11
+ } from "./helpers.js";
12
+
13
+ describe("normalizeTrackingUrl", () => {
14
+ it("strips trailing slashes from path", () => {
15
+ assert.equal(normalizeTrackingUrl("/explore/"), "/explore");
16
+ assert.equal(normalizeTrackingUrl("/explore"), "/explore");
17
+ assert.equal(normalizeTrackingUrl("/story/"), "/story");
18
+ assert.equal(normalizeTrackingUrl("/news_updates/"), "/news_updates");
19
+ });
20
+
21
+ it("keeps single root slash as /", () => {
22
+ assert.equal(normalizeTrackingUrl("/"), "/");
23
+ assert.equal(normalizeTrackingUrl(""), "");
24
+ });
25
+
26
+ it("removes volatile map coordinate parameters (x, y, z) and keeps template/zoom/datetime", () => {
27
+ assert.equal(
28
+ normalizeTrackingUrl("/explore/?x=15.0000&y=48.0000&z=4.0000"),
29
+ "/explore",
30
+ );
31
+ assert.equal(
32
+ normalizeTrackingUrl(
33
+ "/explore/?x=15.0000&y=48.0000&z=4.0000&template=expert&indicator=N11&datetime=2024-08-16&zoom=5",
34
+ ),
35
+ "/explore?datetime=2024-08-16&indicator=N11&template=expert&zoom=5",
36
+ );
37
+ });
38
+
39
+ it("preserves semantic content query params and sorts them", () => {
40
+ assert.equal(
41
+ normalizeTrackingUrl("/story/?page=2&id=sea-ice-extent"),
42
+ "/story?id=sea-ice-extent&page=2",
43
+ );
44
+ assert.equal(
45
+ normalizeTrackingUrl("/story/?id=sea-ice-extent&page=2"),
46
+ "/story?id=sea-ice-extent&page=2",
47
+ );
48
+ });
49
+
50
+ it("normalizes full URLs", () => {
51
+ assert.equal(
52
+ normalizeTrackingUrl("https://eodash.eox.at/explore/"),
53
+ "https://eodash.eox.at/explore",
54
+ );
55
+ assert.equal(
56
+ normalizeTrackingUrl(
57
+ "https://eodash.eox.at/explore/?x=12&y=34&indicator=TEST",
58
+ ),
59
+ "https://eodash.eox.at/explore?indicator=TEST",
60
+ );
61
+ });
62
+ });
63
+
64
+ describe("trackEvent", () => {
65
+ beforeEach(() => {
66
+ globalThis._paq = [];
67
+ globalThis.window = globalThis;
68
+ });
69
+
70
+ it("pushes array payload to _paq and normalizes path arguments", () => {
71
+ trackEvent(["Interaction", "Scroll Depth", "/explore/", 50]);
72
+ assert.deepEqual(globalThis._paq, [
73
+ ["trackEvent", "Interaction", "Scroll Depth", "/explore", 50],
74
+ ]);
75
+ });
76
+
77
+ it("supports positional arguments", () => {
78
+ trackEvent("CTA", "/click-link/", "Button Text");
79
+ assert.deepEqual(globalThis._paq, [
80
+ ["trackEvent", "CTA", "/click-link", "Button Text"],
81
+ ]);
82
+ });
83
+ });
84
+
85
+ describe("trackPageView", () => {
86
+ beforeEach(() => {
87
+ globalThis._paq = [];
88
+ globalThis.window = globalThis;
89
+ globalThis.document = { title: "Default Title" };
90
+ });
91
+
92
+ it("normalizes URL and sets document title before tracking page view", () => {
93
+ trackPageView({
94
+ path: "/explore/?x=10&indicator=AIR",
95
+ title: "Explore Indicators",
96
+ });
97
+ assert.deepEqual(globalThis._paq, [
98
+ ["setCustomUrl", "/explore?indicator=AIR"],
99
+ ["setDocumentTitle", "Explore Indicators"],
100
+ ["trackPageView"],
101
+ ["enableLinkTracking"],
102
+ ]);
103
+ });
104
+
105
+ it("accepts router route object", () => {
106
+ trackPageView({
107
+ route: {
108
+ path: "/story/",
109
+ data: { title: "Climate Story" },
110
+ },
111
+ });
112
+ assert.deepEqual(globalThis._paq, [
113
+ ["setCustomUrl", "/story"],
114
+ ["setDocumentTitle", "Climate Story"],
115
+ ["trackPageView"],
116
+ ["enableLinkTracking"],
117
+ ]);
118
+ });
119
+ });
120
+
121
+ describe("trackSiteSearch", () => {
122
+ beforeEach(() => {
123
+ globalThis._paq = [];
124
+ globalThis.window = globalThis;
125
+ });
126
+
127
+ it("pushes trackSiteSearch event with keyword, category, and result count", () => {
128
+ trackSiteSearch("methane", "indicators", 5);
129
+ assert.deepEqual(globalThis._paq, [
130
+ ["trackSiteSearch", "methane", "indicators", 5],
131
+ ]);
132
+ });
133
+ });
134
+
135
+ describe("existing helpers", () => {
136
+ it("formats prices correctly", () => {
137
+ assert.equal(formatPrice(12000, "en"), "€ 12,000.-");
138
+ assert.equal(formatPrice(49.99, "de"), "€ 49,99");
139
+ });
140
+
141
+ it("translates i18n keys with fallback", () => {
142
+ assert.equal(t("nav.home", { nav: { home: "Home Page" } }), "Home Page");
143
+ assert.equal(
144
+ t("nav.unknown", { nav: { home: "Home Page" } }),
145
+ "nav.unknown",
146
+ );
147
+ assert.equal(t("Imprint", { Imprint: "Impressum" }), "Impressum");
148
+ assert.equal(t("Imprint", {}), "Imprint");
149
+ });
150
+
151
+ it("checks isActive links correctly", () => {
152
+ assert.equal(isActive({ link: "/explore/" }, "/explore"), true);
153
+ assert.equal(isActive({ link: "/explore" }, "/explore/"), true);
154
+ assert.equal(isActive({ link: "/explore" }, "/explore/subpage"), true);
155
+ assert.equal(isActive({ link: "/explore" }, "/explore-other"), false);
156
+ assert.equal(isActive({ link: "/explore" }, "/explore?tab=1#sec"), true);
157
+ assert.equal(isActive({ link: "/" }, "/"), true);
158
+ assert.equal(isActive({ link: "/" }, "/explore"), false);
159
+
160
+ // Parent dropdown with items
161
+ const parentDropdown = {
162
+ text: "Expertise",
163
+ items: [
164
+ { text: "Data Management", link: "/expertise/data-management" },
165
+ { text: "Data Visualization", link: "/expertise/data-visualization" },
166
+ ],
167
+ };
168
+ assert.equal(isActive(parentDropdown, "/expertise/data-management"), true);
169
+ assert.equal(isActive(parentDropdown, "/expertise/data-management/"), true);
170
+ assert.equal(isActive(parentDropdown, "/solutions"), false);
171
+
172
+ // Parent with both link and items
173
+ const parentWithLinkAndItems = {
174
+ text: "Products",
175
+ link: "/products",
176
+ items: [{ text: "Product A", link: "/products/a" }],
177
+ };
178
+ assert.equal(isActive(parentWithLinkAndItems, "/products/a"), true);
179
+ assert.equal(isActive(parentWithLinkAndItems, "/products"), true);
180
+ });
181
+ });
package/src/index.js CHANGED
@@ -23,6 +23,8 @@ import BlogList from "./components/BlogList.vue";
23
23
  import TeamPage from "./components/TeamPage.vue";
24
24
  import SectionHeader from "./components/SectionHeader.vue";
25
25
  import TestimonialsSection from "./components/TestimonialsSection.vue";
26
+ import TextSection from "./components/TextSection.vue";
27
+ import OpenPositions from "./components/OpenPositions.vue";
26
28
  import Layout from "./Layout.vue";
27
29
  import "./style.css";
28
30
 
@@ -55,6 +57,8 @@ export default {
55
57
  app.component("TeamPage", TeamPage);
56
58
  app.component("SectionHeader", SectionHeader);
57
59
  app.component("TestimonialsSection", TestimonialsSection);
60
+ app.component("TextSection", TextSection);
61
+ app.component("OpenPositions", OpenPositions);
58
62
 
59
63
  router.onAfterRouteChanged = () => {
60
64
  if (!import.meta.env.SSR) {
@@ -1,4 +1,5 @@
1
1
  ---
2
2
  layout: blog
3
3
  title: Author posts
4
+ hero: true
4
5
  ---
@@ -19,7 +19,7 @@ export default {
19
19
  const yaml = frontmatterMatch[1];
20
20
 
21
21
  // 1. Match inline array or string style author
22
- const authorMatch = yaml.match(/author:\s*(.*?)\r?\n/);
22
+ const authorMatch = yaml.match(/author:[ \t]+(.*?)\r?\n/);
23
23
  if (authorMatch) {
24
24
  const val = authorMatch[1].trim();
25
25
  if (val.startsWith("[") && val.endsWith("]")) {
@@ -30,7 +30,7 @@ export default {
30
30
  const clean = a.trim().replace(/['"]/g, "").toLowerCase();
31
31
  if (clean) allAuthors.add(clean);
32
32
  });
33
- } else if (val) {
33
+ } else if (val && !val.startsWith("-")) {
34
34
  const clean = val.replace(/['"]/g, "").toLowerCase();
35
35
  if (clean) allAuthors.add(clean);
36
36
  }
package/src/pages/blog.md CHANGED
@@ -1,4 +1,5 @@
1
1
  ---
2
2
  layout: blog
3
3
  title: Blog
4
+ hero: true
4
5
  ---
@@ -1,4 +1,5 @@
1
1
  ---
2
2
  layout: blog
3
3
  title: Tag list
4
+ hero: true
4
5
  ---
package/src/pages/tag.md CHANGED
@@ -1,4 +1,5 @@
1
1
  ---
2
2
  layout: tags
3
3
  title: Tags
4
+ hero: true
4
5
  ---
package/src/pages/team.md CHANGED
@@ -1,4 +1,5 @@
1
1
  ---
2
2
  layout: team
3
- title: Team
3
+ title: Our Team
4
+ hero: true
4
5
  ---
package/src/posts.data.js CHANGED
@@ -62,6 +62,44 @@ function getExcerpt(src, maxLength = 200) {
62
62
  return text;
63
63
  }
64
64
 
65
+ function resolvePostUrl(page) {
66
+ if (!page.url) return "";
67
+ const cleanUrls = global.VITEPRESS_CONFIG?.cleanUrls ?? true;
68
+
69
+ const relFile = page.url.replace(/^\//, "").replace(/\.html$/, "") + ".md";
70
+
71
+ // 1. Check VitePress rewrites map first if available
72
+ const rewritten = global.VITEPRESS_CONFIG?.rewrites?.map?.[relFile];
73
+ if (rewritten) {
74
+ return (
75
+ "/" +
76
+ rewritten
77
+ .replace(/(^|\/)index\.md$/, "$1")
78
+ .replace(/\.md$/, cleanUrls ? "" : ".html")
79
+ );
80
+ }
81
+
82
+ // 2. If it is in _posts/, compute fallback rewrite based on frontmatter date and slug
83
+ if (page.url.startsWith("/_posts/")) {
84
+ const baseName = page.url.replace(/^\/_posts\//, "").replace(/\.html$/, "");
85
+ const slug = baseName
86
+ .toLowerCase()
87
+ .replace(/[^a-z0-9]+/g, "-")
88
+ .replace(/^-+|-+$/g, "");
89
+
90
+ const dateStr = String(page.frontmatter?.date || "");
91
+ const dateMatch = dateStr.match(/^(\d{4})-(\d{2})/);
92
+ if (dateMatch) {
93
+ const [, year, month] = dateMatch;
94
+ return `/${year}/${month}/${slug}${cleanUrls ? "" : ".html"}`;
95
+ } else {
96
+ return `/blog/${slug}${cleanUrls ? "" : ".html"}`;
97
+ }
98
+ }
99
+
100
+ return page.url;
101
+ }
102
+
65
103
  export default createContentLoader("_posts/*.md", {
66
104
  includeSrc: true,
67
105
  transform(rawData) {
@@ -78,7 +116,7 @@ export default createContentLoader("_posts/*.md", {
78
116
 
79
117
  return {
80
118
  title: page.frontmatter.title || "",
81
- url: page.url,
119
+ url: resolvePostUrl(page),
82
120
  date: page.frontmatter.date || "",
83
121
  authors,
84
122
  tags: page.frontmatter.tags || [],