Skip to content

Commit

Permalink
Merge pull request #23 from kjloveless/updates
Browse files Browse the repository at this point in the history
fix nav link for root domain
  • Loading branch information
kjloveless authored Oct 13, 2024
2 parents 93153a6 + 58fe265 commit a3ebb84
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
7 changes: 3 additions & 4 deletions islands/link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ export function Link(
{ href, ...props }: JSX.HTMLAttributes<HTMLAnchorElement>,
) {
if (
IS_BROWSER && typeof href === "string" && typeof window !== "undefined" &&
window.location.hostname !== "localhost"
IS_BROWSER && typeof href === "string" && typeof window !== "undefined"
) {
const { subdomain, domain } = getDomain(window.location.hostname);
console.log(subdomain, domain);
const { domain, subdomain } = getDomain(globalThis.location.hostname);
console.log(subdomain && true);
if (subdomain) {
return <a href={`https://${domain}${href}`} {...props} />;
} else {
Expand Down
2 changes: 0 additions & 2 deletions islands/theme-toggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ export function ThemeToggle() {
} else {
document.documentElement.classList.add("dark");
}

console.log(theme.value);
}}
>
<Icons.sun className="rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" />
Expand Down
3 changes: 3 additions & 0 deletions util/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ export function cn(...inputs: ClassValue[]) {

export function getDomain(hostname: string) {
const domainParts = hostname.split(".");
if (domainParts.length <= 2) {
return { domain: hostname, subdomain: undefined };
}

const domain = `${domainParts[domainParts.length - 1]}
${domainParts[domainParts.length]}`;
Expand Down

0 comments on commit a3ebb84

Please sign in to comment.