@eox/pages-theme-eox 2.0.0-alpha.4 → 2.0.0-alpha.5

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-eox",
3
- "version": "2.0.0-alpha.4",
3
+ "version": "2.0.0-alpha.5",
4
4
  "type": "module",
5
5
  "description": "Vitepress Theme with EOX branding",
6
6
  "main": "src/index.js",
@@ -208,6 +208,10 @@ function getCoverImageUrl(coverImage) {
208
208
  if (coverImage.startsWith("http") || coverImage.startsWith("//")) {
209
209
  return coverImage;
210
210
  }
211
+ const base = withBase("/");
212
+ if (base && base !== "/" && coverImage.startsWith(base)) {
213
+ return coverImage;
214
+ }
211
215
  const path = coverImage.startsWith("/")
212
216
  ? coverImage
213
217
  : `/images/${coverImage}`;
@@ -151,6 +151,10 @@ function getCoverImageUrl(coverImage) {
151
151
  if (coverImage.startsWith("http") || coverImage.startsWith("//")) {
152
152
  return coverImage;
153
153
  }
154
+ const base = withBase("/");
155
+ if (base && base !== "/" && coverImage.startsWith(base)) {
156
+ return coverImage;
157
+ }
154
158
  const path = coverImage.startsWith("/")
155
159
  ? coverImage
156
160
  : `/images/${coverImage}`;
@@ -67,6 +67,8 @@ const props = defineProps([
67
67
  function resolveLink(link) {
68
68
  if (!link) return "";
69
69
  if (link.startsWith("http") || link.startsWith("//")) return link;
70
+ const base = withBase("/");
71
+ if (base && base !== "/" && link.startsWith(base)) return link;
70
72
  return link.startsWith("/") ? withBase(link) : withBase("/" + link);
71
73
  }
72
74
 
@@ -57,6 +57,8 @@ const props = defineProps({
57
57
  function resolveUrl(url) {
58
58
  if (!url) return "";
59
59
  if (url.startsWith("http") || url.startsWith("//")) return url;
60
+ const base = withBase("/");
61
+ if (base && base !== "/" && url.startsWith(base)) return url;
60
62
  return url.startsWith("/") ? withBase(url) : withBase("/" + url);
61
63
  }
62
64
 
@@ -45,6 +45,8 @@ const props = defineProps({
45
45
  function resolveUrl(url) {
46
46
  if (!url) return "";
47
47
  if (url.startsWith("http") || url.startsWith("//")) return url;
48
+ const base = withBase("/");
49
+ if (base && base !== "/" && url.startsWith(base)) return url;
48
50
  return url.startsWith("/") ? withBase(url) : withBase("/" + url);
49
51
  }
50
52
 
@@ -63,30 +63,28 @@ const resolveCardComponent = (variant) => {
63
63
 
64
64
  const { page, site } = useData();
65
65
 
66
+ function resolveUrl(url) {
67
+ if (!url) return "";
68
+ if (url.startsWith("http") || url.startsWith("//")) return url;
69
+ const base = withBase("/");
70
+ if (base && base !== "/" && url.startsWith(base)) return url;
71
+ return url.startsWith("/") ? withBase(url) : withBase("/" + url);
72
+ }
73
+
66
74
  function normalizeFeature(feature) {
67
75
  return {
68
76
  ...feature,
69
- image:
70
- feature.image && feature.image.startsWith("/")
71
- ? withBase(feature.image)
72
- : feature.image,
77
+ image: resolveUrl(feature.image),
73
78
  link: feature.link
74
79
  ? {
75
80
  ...feature.link,
76
- href:
77
- feature.link.href && feature.link.href.startsWith("/")
78
- ? withBase(feature.link.href)
79
- : feature.link.href,
81
+ href: resolveUrl(feature.link.href),
80
82
  }
81
83
  : undefined,
82
84
  secondaryLink: feature.secondaryLink
83
85
  ? {
84
86
  ...feature.secondaryLink,
85
- href:
86
- feature.secondaryLink.href &&
87
- feature.secondaryLink.href.startsWith("/")
88
- ? withBase(feature.secondaryLink.href)
89
- : feature.secondaryLink.href,
87
+ href: resolveUrl(feature.secondaryLink.href),
90
88
  }
91
89
  : undefined,
92
90
  };
@@ -94,6 +94,8 @@ const activeIndex = ref(0);
94
94
  function resolveUrl(url) {
95
95
  if (!url) return "";
96
96
  if (url.startsWith("http") || url.startsWith("//")) return url;
97
+ const base = withBase("/");
98
+ if (base && base !== "/" && url.startsWith(base)) return url;
97
99
  return url.startsWith("/") ? withBase(url) : withBase("/" + url);
98
100
  }
99
101
 
@@ -107,6 +107,8 @@ const props = defineProps({
107
107
  function resolveUrl(url) {
108
108
  if (!url) return "";
109
109
  if (url.startsWith("http") || url.startsWith("//")) return url;
110
+ const base = withBase("/");
111
+ if (base && base !== "/" && url.startsWith(base)) return url;
110
112
  return url.startsWith("/") ? withBase(url) : withBase("/" + url);
111
113
  }
112
114
 
@@ -196,6 +196,8 @@ const lightboxIndex = ref(null);
196
196
  function resolveUrl(url) {
197
197
  if (!url) return "";
198
198
  if (url.startsWith("http") || url.startsWith("//")) return url;
199
+ const base = withBase("/");
200
+ if (base && base !== "/" && url.startsWith(base)) return url;
199
201
  return url.startsWith("/") ? withBase(url) : withBase("/" + url);
200
202
  }
201
203
 
@@ -25,6 +25,8 @@ const logoRow = useTemplateRef("logo-row");
25
25
  function resolveUrl(url) {
26
26
  if (!url) return "";
27
27
  if (url.startsWith("http") || url.startsWith("//")) return url;
28
+ const base = withBase("/");
29
+ if (base && base !== "/" && url.startsWith(base)) return url;
28
30
  return url.startsWith("/") ? withBase(url) : withBase("/" + url);
29
31
  }
30
32
 
@@ -239,7 +239,7 @@ const langs = computed(() => {
239
239
  }
240
240
  return Object.entries(locales).map(([id, locale]) => {
241
241
  const currentPath = route.path;
242
- const base = withBase("");
242
+ const base = withBase("/");
243
243
  let pathRelativeToBase = currentPath;
244
244
  if (base !== "/" && currentPath.startsWith(base)) {
245
245
  pathRelativeToBase = currentPath.substring(base.length);