@luciodale/docs-ui-kit 0.2.0 → 0.2.1

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": "@luciodale/docs-ui-kit",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Astro component library for documentation sites. Dark theme, orange accent.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  import type { SiteConfig } from "../types/config";
3
+ import { withBase } from "../utils/base-path";
3
4
  import GithubIcon from "./GithubIcon.astro";
4
5
  import LinkedInIcon from "./LinkedInIcon.astro";
5
6
 
@@ -17,7 +18,7 @@ const copyright = config.copyright ?? config.title;
17
18
  <div class="flex flex-col md:flex-row items-center gap-6 md:gap-4">
18
19
  <div class="flex items-center gap-3 md:w-1/3">
19
20
  {config.logoSrc && (
20
- <a href="/">
21
+ <a href={withBase("/")}>
21
22
  <img
22
23
  src={config.logoSrc}
23
24
  alt={config.logoAlt ?? config.title}
@@ -33,7 +34,7 @@ const copyright = config.copyright ?? config.title;
33
34
  <div class="flex gap-6 md:w-1/3 justify-center">
34
35
  {config.navLinks.map((link) => (
35
36
  <a
36
- href={link.href}
37
+ href={withBase(link.href)}
37
38
  class="text-white/40 text-sm hover:text-white/70 transition-colors"
38
39
  >
39
40
  {link.label}
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  import type { SiteConfig } from "../types/config";
3
+ import { withBase } from "../utils/base-path";
3
4
  import GithubIcon from "./GithubIcon.astro";
4
5
  import SearchModal from "./SearchModal.astro";
5
6
 
@@ -13,7 +14,7 @@ const { config, currentPath } = Astro.props;
13
14
 
14
15
  <header class="sticky top-0 z-50 h-16 border-b border-white/10 bg-black/80 backdrop-blur-md">
15
16
  <div class="max-w-7xl h-full mx-auto px-6 md:px-8 flex items-center justify-between">
16
- <a href="/" class="flex items-center gap-3 text-white hover:opacity-80 transition-opacity">
17
+ <a href={withBase("/")} class="flex items-center gap-3 text-white hover:opacity-80 transition-opacity">
17
18
  {config.logoSrc ? (
18
19
  <img src={config.logoSrc} alt={config.logoAlt ?? config.title} class="h-7" />
19
20
  ) : (
@@ -24,7 +25,7 @@ const { config, currentPath } = Astro.props;
24
25
  <nav class="hidden md:flex items-center gap-6">
25
26
  {config.navLinks.map((link) => (
26
27
  <a
27
- href={link.href}
28
+ href={withBase(link.href)}
28
29
  class:list={[
29
30
  "text-sm font-medium transition-colors duration-150",
30
31
  currentPath.startsWith(link.href)
@@ -108,7 +109,7 @@ const { config, currentPath } = Astro.props;
108
109
  <div class="px-6 py-4 flex flex-col gap-3 border-b border-white/10">
109
110
  {config.navLinks.map((link) => (
110
111
  <a
111
- href={link.href}
112
+ href={withBase(link.href)}
112
113
  class:list={[
113
114
  "text-sm font-medium transition-colors",
114
115
  currentPath.startsWith(link.href)
@@ -131,7 +132,7 @@ const { config, currentPath } = Astro.props;
131
132
  <div class="flex flex-col">
132
133
  {section.links.map((link) => (
133
134
  <a
134
- href={link.href}
135
+ href={withBase(link.href)}
135
136
  class:list={[
136
137
  "block py-1.5 pl-3 text-sm border-l-2 transition-colors",
137
138
  currentPath === link.href
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  import type { SidebarSection } from "../types/config";
3
+ import { withBase } from "../utils/base-path";
3
4
 
4
5
  type Props = {
5
6
  section: SidebarSection;
@@ -24,7 +25,7 @@ const { section, currentPath } = Astro.props;
24
25
  <div class="flex flex-col mt-2">
25
26
  {section.links.map((link) => (
26
27
  <a
27
- href={link.href}
28
+ href={withBase(link.href)}
28
29
  class:list={[
29
30
  "block py-1.5 pl-3 text-sm border-l-2 transition-colors",
30
31
  currentPath === link.href
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Prepends the Astro base path to an internal href.
3
+ * External URLs (http/https) are returned as-is.
4
+ */
5
+ export function withBase(href: string): string {
6
+ if (href.startsWith("http://") || href.startsWith("https://")) return href;
7
+ const base = (import.meta.env.BASE_URL ?? "/").replace(/\/$/, "");
8
+ if (!base || base === "/") return href;
9
+ return `${base}${href.startsWith("/") ? href : `/${href}`}`;
10
+ }