Skip to content

Commit

Permalink
fix(link): broken links and root fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiazom committed Oct 14, 2024
1 parent 9a105ee commit 96bad15
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/app/(main)/[lang]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const navigationManagerLink = {
_type: "link",
linkTitle: "Go to Navigation Manager",
linkType: LinkType.Internal,
internalLink: { _ref: "studio/structure/navigationManager" },
internalLink: { _ref: "studio/structure/siteSettings;navigationManager" },
};

const pagesLink = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/utils/linkTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const homeLink = {
linkTitle: "Return to home",
linkType: LinkType.Internal,
internalLink: {
_ref: "/",
_ref: "",
},
};

Expand Down
13 changes: 3 additions & 10 deletions src/utils/get.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,10 @@ import { ILink, LinkType } from "studio/lib/interfaces/navigation";
const hash = "#";

export const getHref = (link: ILink): string => {
switch (link?.linkType) {
switch (link.linkType) {
case LinkType.Internal:
if (link.internalLink?._ref) {
try {
return `${link.language ? `/${link.language}` : ""}/${link.internalLink._ref}${link.anchor ? `#${link.anchor}` : ""}`;
} catch (error) {
console.error("Error fetching page:", error);
return hash;
}
if (link.internalLink?._ref !== undefined) {
return `${link.language ? `/${link.language}` : ""}/${link.internalLink._ref}${link.anchor ? `#${link.anchor}` : ""}`;
}
return hash;
case LinkType.External:
Expand All @@ -20,7 +15,5 @@ export const getHref = (link: ILink): string => {
return `mailto:${link.email}`;
case LinkType.Phone:
return `tel:${link.phone}`;
default:
return hash;
}
};

0 comments on commit 96bad15

Please sign in to comment.