use next/link for internal links, even if absolute from the cms
This commit is contained in:
@@ -2,7 +2,9 @@ import { graphql, unmaskFragment } from "@/gql";
|
||||
import { type FeaturedBlockFragment } from "@/gql/graphql";
|
||||
import Link from "next/link";
|
||||
import { Image } from "@/components/general/Image";
|
||||
import { RichText } from "@/components/general/RichText";
|
||||
import { ImageFragmentDefinition } from "@/lib/common";
|
||||
import { internalHref } from "@/lib/links";
|
||||
import styles from "./featuredBlock.module.scss";
|
||||
|
||||
const FeaturedBlockFragmentDefinition = graphql(`
|
||||
@@ -44,6 +46,9 @@ export const FeaturedBlock = ({
|
||||
);
|
||||
// TODO: fetch image from target page
|
||||
|
||||
const pageUrl = block.featuredPage.url;
|
||||
const featuredHref = pageUrl ? internalHref(pageUrl) ?? pageUrl : "#";
|
||||
|
||||
return (
|
||||
<div
|
||||
className={styles.featuredBlock}
|
||||
@@ -51,8 +56,10 @@ export const FeaturedBlock = ({
|
||||
>
|
||||
<div className={styles.text}>
|
||||
<h2>{block.title}</h2>
|
||||
<div dangerouslySetInnerHTML={{ __html: block.featuredBlockText }} />
|
||||
<Link href={block.featuredPage.url ?? "#"}>
|
||||
<div>
|
||||
<RichText content={block.featuredBlockText} />
|
||||
</div>
|
||||
<Link href={featuredHref}>
|
||||
{block.linkText} →
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user