@uniweb/kit 0.4.8 → 0.4.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniweb/kit",
3
- "version": "0.4.8",
3
+ "version": "0.4.10",
4
4
  "description": "Standard component library for Uniweb foundations",
5
5
  "type": "module",
6
6
  "exports": {
@@ -39,7 +39,7 @@
39
39
  "fuse.js": "^7.0.0",
40
40
  "shiki": "^3.0.0",
41
41
  "tailwind-merge": "^2.6.0",
42
- "@uniweb/core": "0.3.8"
42
+ "@uniweb/core": "0.3.9"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "react": "^18.0.0 || ^19.0.0",
@@ -140,6 +140,7 @@ function generateTitle(href, localize) {
140
140
  * @param {string} [props.target] - Link target (_blank, _self, etc.)
141
141
  * @param {string} [props.className] - CSS classes
142
142
  * @param {boolean} [props.download] - Force download behavior
143
+ * @param {boolean} [props.reload] - Force full page reload (renders <a> with basePath prefix)
143
144
  * @param {React.ReactNode} props.children - Link content
144
145
  *
145
146
  * @example
@@ -162,6 +163,7 @@ export function Link({
162
163
  download,
163
164
  className,
164
165
  children,
166
+ reload,
165
167
  ...props
166
168
  }) {
167
169
  const { website, localize, makeHref, getRoutingComponents } = useWebsite()
@@ -178,7 +180,9 @@ export function Link({
178
180
  }
179
181
 
180
182
  // Add locale prefix for internal links in non-default locales
181
- if (linkHref.startsWith('/') && !isExternalUrl(linkHref)) {
183
+ // Skip when reload is true — the caller provides a fully-resolved URL
184
+ // (e.g., getLocaleUrl() already includes the target locale prefix)
185
+ if (!reload && linkHref.startsWith('/') && !isExternalUrl(linkHref)) {
182
186
  if (website?.hasMultipleLocales?.()) {
183
187
  const activeLocale = website.getActiveLocale()
184
188
  const defaultLocale = website.getDefaultLocale()
@@ -195,15 +199,31 @@ export function Link({
195
199
  }
196
200
  }
197
201
 
198
- // Auto-generate title if not provided
199
- const linkTitle = title || generateTitle(linkHref, localize)
200
-
201
202
  // Determine if this should be a download
202
203
  const isDownload = download || isFileUrl(linkHref)
203
204
 
204
205
  // Determine if external
205
206
  const isExternal = isExternalUrl(linkHref)
206
207
 
208
+ // Auto-generate title if not provided
209
+ const linkTitle = title || generateTitle(linkHref, localize)
210
+
211
+ // Internal links with reload: render <a> with basePath prefix
212
+ // Used for locale switches that need a full page reload
213
+ if (reload && !isExternal && !isDownload) {
214
+ const basePath = website?.basePath || ''
215
+ return (
216
+ <a
217
+ href={basePath + linkHref}
218
+ title={linkTitle}
219
+ className={className}
220
+ {...props}
221
+ >
222
+ {children}
223
+ </a>
224
+ )
225
+ }
226
+
207
227
  // File downloads
208
228
  if (isDownload) {
209
229
  return (