1- import React from "react" ;
1+ import React , { useMemo , type ReactNode } from "react" ;
22import { objectKeys } from "tsafe/objectKeys" ;
33import { getAssetUrl } from "../tools/getAssetUrl" ;
44import AppleTouchIcon from "../dsfr/favicon/apple-touch-icon.png" ;
@@ -7,6 +7,8 @@ import FaviconIco from "../dsfr/favicon/favicon.ico";
77import { getScriptToRunAsap } from "../useIsDark/scriptToRunAsap" ;
88import { fontUrlByFileBasename } from "./zz_internal/fontUrlByFileBasename" ;
99import { getDefaultColorSchemeServerSide } from "./zz_internal/defaultColorScheme" ;
10+ import { setLink , type RegisteredLinkProps } from "../link" ;
11+ import { setUseLang } from "../i18n" ;
1012//NOTE: As of now there is no way to enforce ordering in Next Appdir
1113//See: https://github.com/vercel/next.js/issues/16630
1214// @import url(...) doesn't work. Using Sass and @use is our last resort.
@@ -17,15 +19,31 @@ export type DsfrHeadProps = {
1719 * Preloading of fonts is only enabled in production.
1820 */
1921 preloadFonts ?: ( keyof typeof fontUrlByFileBasename ) [ ] ;
22+ /** Default: <a /> */
23+ Link ?: ( props : RegisteredLinkProps & { children : ReactNode } ) => ReturnType < React . FC > ;
24+ /** Default: ()=> "fr" */
25+ useLang ?: ( ) => string ;
2026} ;
2127
2228const isProduction = process . env . NODE_ENV !== "development" ;
2329
2430export function DsfrHead ( props : DsfrHeadProps ) {
25- const { preloadFonts = [ ] } = props ;
31+ const { preloadFonts = [ ] , Link , useLang } = props ;
2632
2733 const defaultColorScheme = getDefaultColorSchemeServerSide ( ) ;
2834
35+ useMemo ( ( ) => {
36+ if ( Link !== undefined ) {
37+ setLink ( { Link } ) ;
38+ }
39+ } , [ Link ] ) ;
40+
41+ useMemo ( ( ) => {
42+ if ( useLang !== undefined ) {
43+ setUseLang ( { useLang } ) ;
44+ }
45+ } , [ useLang ] ) ;
46+
2947 return (
3048 < >
3149 { isProduction &&
0 commit comments