@uniweb/kit 0.4.8 → 0.4.9
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 +2 -2
- package/src/components/Link/Link.jsx +21 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/kit",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.9",
|
|
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.
|
|
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()
|
|
@@ -195,15 +197,31 @@ export function Link({
|
|
|
195
197
|
}
|
|
196
198
|
}
|
|
197
199
|
|
|
198
|
-
// Auto-generate title if not provided
|
|
199
|
-
const linkTitle = title || generateTitle(linkHref, localize)
|
|
200
|
-
|
|
201
200
|
// Determine if this should be a download
|
|
202
201
|
const isDownload = download || isFileUrl(linkHref)
|
|
203
202
|
|
|
204
203
|
// Determine if external
|
|
205
204
|
const isExternal = isExternalUrl(linkHref)
|
|
206
205
|
|
|
206
|
+
// Auto-generate title if not provided
|
|
207
|
+
const linkTitle = title || generateTitle(linkHref, localize)
|
|
208
|
+
|
|
209
|
+
// Internal links with reload: render <a> with basePath prefix
|
|
210
|
+
// Used for locale switches that need a full page reload
|
|
211
|
+
if (reload && !isExternal && !isDownload) {
|
|
212
|
+
const basePath = website?.basePath || ''
|
|
213
|
+
return (
|
|
214
|
+
<a
|
|
215
|
+
href={basePath + linkHref}
|
|
216
|
+
title={linkTitle}
|
|
217
|
+
className={className}
|
|
218
|
+
{...props}
|
|
219
|
+
>
|
|
220
|
+
{children}
|
|
221
|
+
</a>
|
|
222
|
+
)
|
|
223
|
+
}
|
|
224
|
+
|
|
207
225
|
// File downloads
|
|
208
226
|
if (isDownload) {
|
|
209
227
|
return (
|