minista-shared-head
Version:
## About
29 lines (28 loc) • 686 B
JavaScript
;
import { jsx } from "react/jsx-runtime";
import { HeadContext } from "../shared/index.js";
export function HeadProvider({
headData,
children
}) {
const setHeadData = (key, value) => {
switch (key) {
case "htmlAttributes":
case "bodyAttributes":
headData[key] = {
...headData[key],
...value
};
break;
case "tags":
headData[key] = [
...headData[key] ? [headData[key]].flat() : [],
...[value].flat()
];
break;
default:
headData[key] = value;
}
};
return /* @__PURE__ */ jsx(HeadContext.Provider, { value: { setHeadData }, children });
}