Skip to content

Commit

Permalink
#204: Follow up
Browse files Browse the repository at this point in the history
  • Loading branch information
garronej committed Oct 31, 2023
1 parent 4b0e334 commit 9aa8a57
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 11 deletions.
8 changes: 2 additions & 6 deletions src/link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ type HTMLAnchorProps = DetailedHTMLProps<
>;

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface RegisterLink {}
export interface RegisterLink { }

export type RegisteredLinkProps = RegisterLink extends { Link: infer Link }
? Omit<UnpackProps<Link>, "children">
: Omit<HTMLAnchorProps, "children">;

let Link: (
props: RegisteredLinkProps & { children: ReactNode }
) => ReturnType<React.FC> = props => {
let Link: React.ComponentType<RegisteredLinkProps & { children: ReactNode }> = props => {
const { href, ...rest } = props as { to?: string; href?: string };

button: {
Expand All @@ -42,8 +40,6 @@ let Link: (
return <a href={href} {...rest} />;
};

//<a {...props} />;

export function setLink(params: { Link: typeof Link }): void {
Link = props => {
{
Expand Down
4 changes: 2 additions & 2 deletions src/next-appdir/DsfrHead.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import FaviconIco from "../dsfr/favicon/favicon.ico";
import { getScriptToRunAsap } from "../useIsDark/scriptToRunAsap";
import { fontUrlByFileBasename } from "./zz_internal/fontUrlByFileBasename";
import { getDefaultColorSchemeServerSide } from "./zz_internal/defaultColorScheme";
import { setLink, type RegisteredLinkProps } from "../link";
import { setLink, RegisteredLinkProps } from "../link";
import { assert } from "tsafe/assert";
//NOTE: As of now there is no way to enforce ordering in Next Appdir
//See: https://github.com/vercel/next.js/issues/16630
Expand All @@ -22,7 +22,7 @@ export type DsfrHeadProps = {
*/
preloadFonts?: (keyof typeof fontUrlByFileBasename)[];
/** Default: <a /> */
Link?: (props: RegisteredLinkProps & { children: ReactNode }) => ReturnType<React.FC>;
Link?: React.ComponentType<RegisteredLinkProps & { children: ReactNode }>;
/**
* When set, the value will be used as the nonce attribute of subsequent script tags.
*
Expand Down
2 changes: 1 addition & 1 deletion src/next-appdir/zz_internal/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function startReactDsfr(params: {
/** Default: false */
verbose?: boolean;
/** Default: <a /> */
Link?: (props: RegisteredLinkProps & { children: ReactNode }) => ReturnType<React.FC>;
Link?: React.ComponentType<RegisteredLinkProps & { children: ReactNode }>;
/**
* When true, the nonce of the script tag will be checked, fetched from {@link DsfrHead} component and injected in react-dsfr scripts.
*
Expand Down
2 changes: 1 addition & 1 deletion src/next-pagesdir.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export type CreateNextDsfrIntegrationApiParams = {
/** Default: false */
verbose?: boolean;
/** Default: <a /> */
Link?: (props: RegisteredLinkProps & { children: ReactNode }) => ReturnType<React.FC>;
Link?: React.ComponentType<RegisteredLinkProps & { children: ReactNode }>;
/** If not provided no fonts are preloaded.
* Preloading of fonts is only enabled in production.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/spa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function startReactDsfr(params: {
/** Default: false */
verbose?: boolean;
/** Default: <a /> */
Link?: (props: RegisteredLinkProps & { children: ReactNode }) => ReturnType<React.FC>;
Link?: React.ComponentType<RegisteredLinkProps & { children: ReactNode }>;
/** Default: ()=> "fr" */
useLang?: () => string;
/**
Expand Down

0 comments on commit 9aa8a57

Please sign in to comment.