Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
fix: Fix current link state in static export (#5809)
Oleg Isonen2b06b2a98756
diff --git a/fixtures/ssg-cloudflare-pages/app/__generated__/_index.tsx b/fixtures/ssg-cloudflare-pages/app/__generated__/_index.tsxindex f25a124612..050563f9e0 100644--- a/fixtures/ssg-cloudflare-pages/app/__generated__/_index.tsx+++ b/fixtures/ssg-cloudflare-pages/app/__generated__/_index.tsx@@ -11,9 +11,9 @@ import {Body as Body,Heading as Heading,Text as Text,- Link as Link,Image as Image,} from "@webstudio-is/sdk-components-react";+import { Link as Link } from "@webstudio-is/sdk-components-react/ssg";export const projectId = "d845c167-ea07-4875-b08d-83e97c09dcce";diff --git a/fixtures/ssg-cloudflare-pages/pages/another-page/+Page.tsx b/fixtures/ssg-cloudflare-pages/pages/another-page/+Page.tsxindex 2b0a21844c..53cca63dce 100644--- a/fixtures/ssg-cloudflare-pages/pages/another-page/+Page.tsx+++ b/fixtures/ssg-cloudflare-pages/pages/another-page/+Page.tsx@@ -4,6 +4,7 @@ import {PageSettingsTitle,ReactSdkContext,} from "@webstudio-is/react-sdk/runtime";+import { SsgCurrentUrlContext } from "@webstudio-is/sdk-components-react/ssg";import { assetBaseUrl, imageLoader } from "../../app/constants.mjs";import {Page,@@ -23,8 +24,10 @@ const PageComponent = ({ data }: { data: PageContext["data"] }) => {onError: console.error,}}>- {/* Use the URL as the key to force scripts in HTML Embed to reload on dynamic pages */}- <Page key={url} system={system} />+ <SsgCurrentUrlContext.Provider value={url}>+ {/* Use the URL as the key to force scripts in HTML Embed to reload on dynamic pages */}+ <Page key={url} system={system} />+ </SsgCurrentUrlContext.Provider><PageSettingsMetaurl={url}pageMeta={pageMeta}diff --git a/fixtures/ssg-cloudflare-pages/pages/index/+Page.tsx b/fixtures/ssg-cloudflare-pages/pages/index/+Page.tsxindex d865d57f09..e8952f15d9 100644--- a/fixtures/ssg-cloudflare-pages/pages/index/+Page.tsx+++ b/fixtures/ssg-cloudflare-pages/pages/index/+Page.tsx@@ -4,6 +4,7 @@ import {PageSettingsTitle,ReactSdkContext,} from "@webstudio-is/react-sdk/runtime";+import { SsgCurrentUrlContext } from "@webstudio-is/sdk-components-react/ssg";import { assetBaseUrl, imageLoader } from "../../app/constants.mjs";import { Page, breakpoints, siteName } from "../../app/__generated__/_index";@@ -19,8 +20,10 @@ const PageComponent = ({ data }: { data: PageContext["data"] }) => {onError: console.error,}}>- {/* Use the URL as the key to force scripts in HTML Embed to reload on dynamic pages */}- <Page key={url} system={system} />+ <SsgCurrentUrlContext.Provider value={url}>+ {/* Use the URL as the key to force scripts in HTML Embed to reload on dynamic pages */}+ <Page key={url} system={system} />+ </SsgCurrentUrlContext.Provider><PageSettingsMetaurl={url}pageMeta={pageMeta}diff --git a/fixtures/ssg-cloudflare-pages/public/favicon.ico b/fixtures/ssg-cloudflare-pages/public/favicon.icodeleted file mode 100644index 9cb8c815dc..0000000000Binary files a/fixtures/ssg-cloudflare-pages/public/favicon.ico and /dev/null differdiff --git a/fixtures/ssg-netlify-by-project-id/pages/index/+Page.tsx b/fixtures/ssg-netlify-by-project-id/pages/index/+Page.tsxindex d865d57f09..e8952f15d9 100644--- a/fixtures/ssg-netlify-by-project-id/pages/index/+Page.tsx+++ b/fixtures/ssg-netlify-by-project-id/pages/index/+Page.tsx@@ -4,6 +4,7 @@ import {PageSettingsTitle,ReactSdkContext,} from "@webstudio-is/react-sdk/runtime";+import { SsgCurrentUrlContext } from "@webstudio-is/sdk-components-react/ssg";import { assetBaseUrl, imageLoader } from "../../app/constants.mjs";import { Page, breakpoints, siteName } from "../../app/__generated__/_index";@@ -19,8 +20,10 @@ const PageComponent = ({ data }: { data: PageContext["data"] }) => {onError: console.error,}}>- {/* Use the URL as the key to force scripts in HTML Embed to reload on dynamic pages */}- <Page key={url} system={system} />+ <SsgCurrentUrlContext.Provider value={url}>+ {/* Use the URL as the key to force scripts in HTML Embed to reload on dynamic pages */}+ <Page key={url} system={system} />+ </SsgCurrentUrlContext.Provider><PageSettingsMetaurl={url}pageMeta={pageMeta}diff --git a/fixtures/ssg-netlify-by-project-id/pages/redirect/+Page.tsx b/fixtures/ssg-netlify-by-project-id/pages/redirect/+Page.tsxindex 260560b8ef..0b7ef5266b 100644--- a/fixtures/ssg-netlify-by-project-id/pages/redirect/+Page.tsx+++ b/fixtures/ssg-netlify-by-project-id/pages/redirect/+Page.tsx@@ -4,6 +4,7 @@ import {PageSettingsTitle,ReactSdkContext,} from "@webstudio-is/react-sdk/runtime";+import { SsgCurrentUrlContext } from "@webstudio-is/sdk-components-react/ssg";import { assetBaseUrl, imageLoader } from "../../app/constants.mjs";import {Page,@@ -23,8 +24,10 @@ const PageComponent = ({ data }: { data: PageContext["data"] }) => {onError: console.error,}}>- {/* Use the URL as the key to force scripts in HTML Embed to reload on dynamic pages */}- <Page key={url} system={system} />+ <SsgCurrentUrlContext.Provider value={url}>+ {/* Use the URL as the key to force scripts in HTML Embed to reload on dynamic pages */}+ <Page key={url} system={system} />+ </SsgCurrentUrlContext.Provider><PageSettingsMetaurl={url}pageMeta={pageMeta}diff --git a/fixtures/ssg-netlify-by-project-id/public/favicon.ico b/fixtures/ssg-netlify-by-project-id/public/favicon.icodeleted file mode 100644index 9cb8c815dc..0000000000Binary files a/fixtures/ssg-netlify-by-project-id/public/favicon.ico and /dev/null differdiff --git a/packages/cli/src/framework-vike-ssg.ts b/packages/cli/src/framework-vike-ssg.tsindex e21c1ff19f..03de225e7b 100644--- a/packages/cli/src/framework-vike-ssg.ts+++ b/packages/cli/src/framework-vike-ssg.ts@@ -33,6 +33,7 @@ export const createFramework = async (): Promise<Framework> => {await rm(routeTemplatesDir, { recursive: true, force: true });const base = "@webstudio-is/sdk-components-react";+ const ssg = "@webstudio-is/sdk-components-react/ssg";const reactRadix = "@webstudio-is/sdk-components-react-radix";const animation = "@webstudio-is/sdk-components-animation";const components: Record<string, string> = {};@@ -41,6 +42,8 @@ export const createFramework = async (): Promise<Framework> => {components[name] = `${base}:${name}`;metas[name] = meta;}+ components.Link = `${ssg}:Link`;+ components.RichTextLink = `${ssg}:RichTextLink`;for (const [name, meta] of Object.entries(radixComponentMetas)) {components[`${reactRadix}:${name}`] = `${reactRadix}:${name}`;metas[`${reactRadix}:${name}`] = meta;@@ -57,6 +60,7 @@ export const createFramework = async (): Promise<Framework> => {textarea: `${base}:Textarea`,input: `${base}:Input`,select: `${base}:Select`,+ a: `${ssg}:Link`,},html: ({ pagePath }: { pagePath: string }) => {// ignore dynamic pages in static exportdiff --git a/packages/cli/templates/ssg/app/route-templates/html/+Page.tsx b/packages/cli/templates/ssg/app/route-templates/html/+Page.tsxindex 19c341ab7f..d358fb83dd 100644--- a/packages/cli/templates/ssg/app/route-templates/html/+Page.tsx+++ b/packages/cli/templates/ssg/app/route-templates/html/+Page.tsx@@ -4,6 +4,7 @@ import {PageSettingsTitle,ReactSdkContext,} from "@webstudio-is/react-sdk/runtime";+import { SsgCurrentUrlContext } from "@webstudio-is/sdk-components-react/ssg";import { assetBaseUrl, imageLoader } from "__CONSTANTS__";import { Page, breakpoints, siteName } from "__CLIENT__";@@ -19,8 +20,10 @@ const PageComponent = ({ data }: { data: PageContext["data"] }) => {onError: console.error,}}>- {/* Use the URL as the key to force scripts in HTML Embed to reload on dynamic pages */}- <Page key={url} system={system} />+ <SsgCurrentUrlContext.Provider value={url}>+ {/* Use the URL as the key to force scripts in HTML Embed to reload on dynamic pages */}+ <Page key={url} system={system} />+ </SsgCurrentUrlContext.Provider><PageSettingsMetaurl={url}pageMeta={pageMeta}diff --git a/packages/cli/templates/ssg/public/favicon.ico b/packages/cli/templates/ssg/public/favicon.icodeleted file mode 100644index 9cb8c815dc..0000000000Binary files a/packages/cli/templates/ssg/public/favicon.ico and /dev/null differdiff --git a/packages/sdk-components-react/package.json b/packages/sdk-components-react/package.jsonindex ac1d22bc69..47ccd9f8f6 100644--- a/packages/sdk-components-react/package.json+++ b/packages/sdk-components-react/package.json@@ -33,6 +33,11 @@"types": "./lib/types/local-link.d.ts","import": "./lib/local-link.js"},+ "./ssg": {+ "webstudio": "./src/ssg.tsx",+ "types": "./lib/types/ssg.d.ts",+ "import": "./lib/ssg.js"+ },"./templates": {"webstudio": "./src/templates.ts","types": "./lib/types/templates.d.ts",diff --git a/packages/sdk-components-react/src/link-utils.test.ts b/packages/sdk-components-react/src/link-utils.test.tsindex 44a723f1f5..48f9820bb1 100644--- a/packages/sdk-components-react/src/link-utils.test.ts+++ b/packages/sdk-components-react/src/link-utils.test.ts@@ -1,5 +1,26 @@import { expect, test } from "vitest";-import { isLocalLinkActive, resolveLocalLinkUrl } from "./link-utils";+import {+ isLocalHref,+ isLocalLinkActive,+ resolveLocalLinkUrl,+} from "./link-utils";++test("href is local unless it is absolute, protocol-relative, or an asset", () => {+ expect(isLocalHref("/path", "/assets/")).toBe(true);+ expect(isLocalHref("?tag=bla", "/assets/")).toBe(true);+ expect(isLocalHref("#section", "/assets/")).toBe(true);+ expect(isLocalHref("", "/assets/")).toBe(true);++ expect(isLocalHref("https://example.com/path", "/assets/")).toBe(false);+ expect(isLocalHref("//example.com/path", "/assets/")).toBe(false);+ expect(isLocalHref("mailto:[email protected]", "/assets/")).toBe(false);+ expect(isLocalHref("/assets/file.pdf", "/assets/")).toBe(false);+});++test("asset base url only excludes matching root-relative asset paths", () => {+ expect(isLocalHref("/assets", "/assets/")).toBe(true);+ expect(isLocalHref("/assets2/file.pdf", "/assets/")).toBe(true);+});test("local link matches exact pathname, search, and hash", () => {expect(diff --git a/packages/sdk-components-react/src/link-utils.ts b/packages/sdk-components-react/src/link-utils.tsindex 0d51985a7c..153ad35ee9 100644--- a/packages/sdk-components-react/src/link-utils.ts+++ b/packages/sdk-components-react/src/link-utils.ts@@ -1,9 +1,17 @@+import type { ComponentPropsWithoutRef } from "react";+export type UrlParts = {pathname: string;search: string;hash: string;};+type AnchorProps = ComponentPropsWithoutRef<"a">;++export const isLocalHref = (href: string, assetBaseUrl: string) =>+ /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i.test(href) === false &&+ (href.startsWith("/") && href.startsWith(assetBaseUrl)) === false;+/*** React Router resolves href="" and hash-only hrefs without preserving the* concrete browser URL shape Webstudio uses for :local-link-like matching.@@ -46,3 +54,46 @@ export const isLocalLinkActive = (current: UrlParts, target: UrlParts) => {current.hash === target.hash);};++export const getLocalLinkProps = <+ Props extends {+ href: string;+ "aria-current"?: AnchorProps["aria-current"];+ className?: string;+ },+>(+ props: Props,+ location: UrlParts,+ resolvedPath: UrlParts+) => {+ const { href, "aria-current": ariaCurrent, className, ...linkProps } = props;+ const target = resolveLocalLinkUrl(href, location, resolvedPath);+ const isActive = isLocalLinkActive(location, target);+ const classNameValue = [className, isActive ? "active" : undefined]+ .filter(Boolean)+ .join(" ");++ return {+ href,+ linkProps,+ localLinkProps: {+ ...(isActive ? { "aria-current": ariaCurrent ?? "page" } : {}),+ ...(classNameValue === "" ? {} : { className: classNameValue }),+ },+ };+};++export const stripRouterOnlyProps = <+ Props extends {+ prefetch?: unknown;+ reloadDocument?: unknown;+ replace?: unknown;+ preventScrollReset?: unknown;+ },+>({+ prefetch,+ reloadDocument,+ replace,+ preventScrollReset,+ ...props+}: Props) => props;diff --git a/packages/sdk-components-react/src/local-link.tsx b/packages/sdk-components-react/src/local-link.tsxindex 0fee316293..353a6d9f83 100644--- a/packages/sdk-components-react/src/local-link.tsx+++ b/packages/sdk-components-react/src/local-link.tsx@@ -10,8 +10,9 @@ import {import { ReactSdkContext } from "@webstudio-is/react-sdk/runtime";import { Link as BaseLink } from "./link";import {- isLocalLinkActive,- resolveLocalLinkUrl,+ getLocalLinkProps,+ isLocalHref,+ stripRouterOnlyProps,type UrlParts,} from "./link-utils";@@ -41,42 +42,6 @@ type RouterLinkComponentProps = Omit<LocalLinkProps, "href" | "target"> & {ref?: LegacyRef<HTMLAnchorElement>;};-const absoluteUrlPattern = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;--const shouldUseRouterLink = (href: string, assetBaseUrl: string) => {- if (href.startsWith("#") || absoluteUrlPattern.test(href)) {- return false;- }-- if (href.startsWith("/") && href.startsWith(assetBaseUrl)) {- return false;- }-- return true;-};--const getLocalLinkProps = (- props: LocalLinkProps & { href: string },- location: UrlParts,- resolvedPath: UrlParts-) => {- const { href, "aria-current": ariaCurrent, className, ...linkProps } = props;- const target = resolveLocalLinkUrl(href, location, resolvedPath);- const isActive = isLocalLinkActive(location, target);- const classNameValue = [className, isActive ? "active" : undefined]- .filter(Boolean)- .join(" ");-- return {- href,- linkProps,- localLinkProps: {- ...(isActive ? { "aria-current": ariaCurrent ?? "page" } : {}),- ...(classNameValue === "" ? {} : { className: classNameValue }),- },- };-};-const getRouterHref = (href: string, location: UrlParts) => {if (href === "") {return `${location.pathname}${location.search}`;@@ -85,19 +50,6 @@ const getRouterHref = (href: string, location: UrlParts) => {return href;};-const stripRouterOnlyProps = <- Props extends Pick<- LocalLinkProps,- "prefetch" | "reloadDocument" | "replace" | "preventScrollReset"- >,->({- prefetch,- reloadDocument,- replace,- preventScrollReset,- ...props-}: Props) => props;-/*** Remix and React Router expose compatible navigation hooks but from different* packages. This factory keeps Webstudio's local-link semantics in one place@@ -162,7 +114,7 @@ export const createLocalLink = ({// cast to string when invalid value type is provided with bindingconst href = String(props.href ?? "");- if (shouldUseRouterLink(href, assetBaseUrl)) {+ if (href.startsWith("#") === false && isLocalHref(href, assetBaseUrl)) {// Route through the framework only for navigations it should own. Asset// paths can also be root-relative, so they must stay plain anchors.return <RouterLink {...props} href={href} ref={ref} />;diff --git a/packages/sdk-components-react/src/ssg.test.tsx b/packages/sdk-components-react/src/ssg.test.tsxnew file mode 100644index 0000000000..a84568769d--- /dev/null+++ b/packages/sdk-components-react/src/ssg.test.tsx@@ -0,0 +1,143 @@+/**+ * @vitest-environment jsdom+ */+import { renderToStaticMarkup } from "react-dom/server";+import { expect, test, vi } from "vitest";+import { ReactSdkContext } from "@webstudio-is/react-sdk/runtime";+import { Link, SsgCurrentUrlContext } from "./ssg";++const sdkContext = {+ assetBaseUrl: "/assets/",+ imageLoader: ({ src }: { src: string }) => src,+ videoLoader: ({ src }: { src: string }) => src,+ resources: {},+ breakpoints: [],+ onError: vi.fn(),+};++const renderLinks = (currentUrl: string) => {+ const markup = renderToStaticMarkup(+ <ReactSdkContext.Provider value={sdkContext}>+ <SsgCurrentUrlContext.Provider value={currentUrl}>+ <Link href="/path?tag=bla#section">Exact</Link>+ <Link href="/path">Path only</Link>+ <Link href="/path?tag=bla">Missing hash</Link>+ <Link href="/path?tag=other#section">Different query</Link>+ <Link href="/path#section">Missing query</Link>+ <Link href="#section">Hash only</Link>+ <Link href="#">Bare hash</Link>+ <Link href="?tag=bla#section">Search only</Link>+ <Link href="">Empty</Link>+ <Link href="/path?tag=bla#section" className="custom">+ Active class+ </Link>+ <Link href="/path" className="custom">+ Inactive class+ </Link>+ <Link href="/path?tag=bla#section" aria-current="location">+ Aria override+ </Link>+ </SsgCurrentUrlContext.Provider>+ </ReactSdkContext.Provider>+ );+ document.body.innerHTML = markup;+ return Array.from(document.querySelectorAll("a"));+};++test("local link is current only when pathname, search, and hash match", () => {+ const links = renderLinks("https://example.com/path?tag=bla#section");++ expect(links.map((link) => link.getAttribute("aria-current"))).toEqual([+ "page",+ null,+ null,+ null,+ null,+ "page",+ null,+ "page",+ null,+ "page",+ null,+ "location",+ ]);++ expect(links[0]?.getAttribute("class")).toBe("active");+ expect(links[1]?.hasAttribute("class")).toBe(false);+ expect(links[9]?.getAttribute("class")).toBe("custom active");+ expect(links[10]?.getAttribute("class")).toBe("custom");+});++test("local link preserves exact pathname behavior", () => {+ const markup = renderToStaticMarkup(+ <ReactSdkContext.Provider value={sdkContext}>+ <SsgCurrentUrlContext.Provider value="https://example.com/path/child">+ <Link href="/path">Parent</Link>+ <Link href="/path/child">Child</Link>+ <Link href="/path/">Trailing slash</Link>+ <Link href="/Path/child">Different case</Link>+ </SsgCurrentUrlContext.Provider>+ </ReactSdkContext.Provider>+ );+ document.body.innerHTML = markup;+ const links = Array.from(document.querySelectorAll("a"));++ expect(links.map((link) => link.getAttribute("aria-current"))).toEqual([+ null,+ "page",+ null,+ null,+ ]);+});++test("external and asset links render as plain anchors", () => {+ const markup = renderToStaticMarkup(+ <ReactSdkContext.Provider value={sdkContext}>+ <SsgCurrentUrlContext.Provider value="https://example.com/path">+ <Link+ href="https://example.com/path"+ prefetch="intent"+ preventScrollReset+ reloadDocument+ replace+ target="_blank"+ aria-current="location"+ >+ External+ </Link>+ <Link href="/assets/file.pdf">Asset</Link>+ </SsgCurrentUrlContext.Provider>+ </ReactSdkContext.Provider>+ );+ document.body.innerHTML = markup;+ const links = Array.from(document.querySelectorAll("a"));++ expect(links[0]?.getAttribute("href")).toBe("https://example.com/path");+ expect(links[0]?.getAttribute("target")).toBe("_blank");+ expect(links[0]?.getAttribute("aria-current")).toBe("location");+ expect(links[0]?.hasAttribute("prefetch")).toBe(false);+ expect(links[0]?.hasAttribute("preventscrollreset")).toBe(false);+ expect(links[0]?.hasAttribute("reloaddocument")).toBe(false);+ expect(links[0]?.hasAttribute("replace")).toBe(false);++ expect(links[1]?.getAttribute("href")).toBe("/assets/file.pdf");+ expect(links[1]?.getAttribute("aria-current")).toBeNull();+});++test("invalid absolute href renders as plain anchor", () => {+ const markup = renderToStaticMarkup(+ <ReactSdkContext.Provider value={sdkContext}>+ <SsgCurrentUrlContext.Provider value="https://example.com/path">+ <Link href="http://" $webstudio$canvasOnly$assetId="asset-id">+ Invalid external+ </Link>+ </SsgCurrentUrlContext.Provider>+ </ReactSdkContext.Provider>+ );+ document.body.innerHTML = markup;+ const link = document.querySelector("a");++ expect(link?.getAttribute("href")).toBe("http://");+ expect(link?.getAttribute("aria-current")).toBeNull();+ expect(link?.hasAttribute("$webstudio$canvasOnly$assetId")).toBe(false);+});diff --git a/packages/sdk-components-react/src/ssg.tsx b/packages/sdk-components-react/src/ssg.tsxnew file mode 100644index 0000000000..c3b411d1a0--- /dev/null+++ b/packages/sdk-components-react/src/ssg.tsx@@ -0,0 +1,91 @@+import {+ createContext,+ forwardRef,+ type ComponentPropsWithoutRef,+ useContext,+} from "react";+import { ReactSdkContext } from "@webstudio-is/react-sdk/runtime";+import type { Link as BaseLink } from "./link";++export const SsgCurrentUrlContext = createContext<string | undefined>(+ undefined+);++const isLocalHref = (href: string, assetBaseUrl: string) =>+ /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i.test(href) === false &&+ (href.startsWith("/") && href.startsWith(assetBaseUrl)) === false;++export const Link = forwardRef<+ HTMLAnchorElement,+ ComponentPropsWithoutRef<typeof BaseLink>+>((props, ref) => {+ const currentUrlValue = useContext(SsgCurrentUrlContext);+ const { assetBaseUrl } = useContext(ReactSdkContext);+ const {+ children,+ // @todo: it's a hack made for Image component for the builder and should't be in the runtime at all.+ $webstudio$canvasOnly$assetId,+ prefetch,+ preventScrollReset,+ reloadDocument,+ replace,+ "aria-current": ariaCurrent,+ className,+ ...rest+ } = props;+ const href = String(rest.href ?? "");+ const currentHref =+ currentUrlValue ??+ (typeof window === "undefined" ? undefined : window.location.href);+ const currentUrl = currentHref ? new URL(currentHref) : undefined;+ let ariaCurrentValue = ariaCurrent;+ let classNameValue = className;++ if (currentUrl && isLocalHref(href, assetBaseUrl)) {+ const target =+ href === ""+ ? {+ pathname: currentUrl.pathname,+ search: currentUrl.search,+ hash: "",+ }+ : href.startsWith("#")+ ? {+ pathname: currentUrl.pathname,+ search: currentUrl.search,+ hash: href === "#" ? "" : href,+ }+ : new URL(href, currentUrl);+ const isActive =+ currentUrl.pathname === target.pathname &&+ currentUrl.search === target.search &&+ currentUrl.hash === target.hash;++ ariaCurrentValue = isActive ? (ariaCurrent ?? "page") : undefined;+ classNameValue = [className, isActive ? "active" : undefined]+ .filter(Boolean)+ .join(" ");+ }++ return (+ <a+ {...rest}+ {...(ariaCurrentValue === undefined+ ? {}+ : { "aria-current": ariaCurrentValue })}+ {...(classNameValue ? { className: classNameValue } : {})}+ href={+ href === "" && currentUrl+ ? `${currentUrl.pathname}${currentUrl.search}`+ : href+ }+ ref={ref}+ >+ {children}+ </a>+ );+});++Link.displayName = "Link";++export { Link as RichTextLink };diff --git a/vite.sdk-components.config.ts b/vite.sdk-components.config.tsindex 5f01ec1991..abb35a1a1a 100644--- a/vite.sdk-components.config.ts+++ b/vite.sdk-components.config.ts@@ -20,6 +20,7 @@ export default defineConfig({"src/metas.ts","src/hooks.ts",maybeEntry("src/local-link.tsx"),+ maybeEntry("src/ssg.tsx"),"src/templates.ts",].filter((entry) => entry !== undefined),formats: ["es"],