@uniweb/kit 0.4.7 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniweb/kit",
3
- "version": "0.4.7",
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.7"
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,9 +163,10 @@ export function Link({
162
163
  download,
163
164
  className,
164
165
  children,
166
+ reload,
165
167
  ...props
166
168
  }) {
167
- const { localize, makeHref, getRoutingComponents } = useWebsite()
169
+ const { website, localize, makeHref, getRoutingComponents } = useWebsite()
168
170
  const RouterLink = getRoutingComponents()?.Link
169
171
 
170
172
  // Normalize href
@@ -177,8 +179,23 @@ export function Link({
177
179
  linkHref = makeHref(linkHref)
178
180
  }
179
181
 
180
- // Auto-generate title if not provided
181
- const linkTitle = title || generateTitle(linkHref, localize)
182
+ // Add locale prefix for internal links in non-default locales
183
+ if (linkHref.startsWith('/') && !isExternalUrl(linkHref)) {
184
+ if (website?.hasMultipleLocales?.()) {
185
+ const activeLocale = website.getActiveLocale()
186
+ const defaultLocale = website.getDefaultLocale()
187
+ if (activeLocale && activeLocale !== defaultLocale) {
188
+ // Translate route slug for current locale (e.g., /about → /acerca-de)
189
+ if (website.translateRoute) {
190
+ linkHref = website.translateRoute(linkHref, activeLocale)
191
+ }
192
+ const prefix = `/${activeLocale}`
193
+ if (!linkHref.startsWith(`${prefix}/`) && linkHref !== prefix) {
194
+ linkHref = linkHref === '/' ? `${prefix}/` : `${prefix}${linkHref}`
195
+ }
196
+ }
197
+ }
198
+ }
182
199
 
183
200
  // Determine if this should be a download
184
201
  const isDownload = download || isFileUrl(linkHref)
@@ -186,6 +203,25 @@ export function Link({
186
203
  // Determine if external
187
204
  const isExternal = isExternalUrl(linkHref)
188
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
+
189
225
  // File downloads
190
226
  if (isDownload) {
191
227
  return (