@dr.pogodin/react-helmet
Version:
Thread-safe Helmet for React 19+ and friends
264 lines (263 loc) • 5.74 kB
JavaScript
import { c as _c } from "react/compiler-runtime";
import { createContext, useMemo } from 'react';
import Helmet from './Helmet';
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
const Context = /*#__PURE__*/createContext({
description: '',
title: ''
});
/**
* Auxiliary wrapper around "react-helmet", which helps to inject meta tags
* (page title, a brief content description, and social media thumbnails) into
* generated pages.
*/
const MetaTags = t0 => {
const $ = _c(56);
const {
children,
description,
extraMetaTags,
image,
siteName,
socialDescription,
socialTitle,
title,
url
} = t0;
const socTitle = socialTitle || title;
const socDesc = socialDescription || description;
let t1;
if ($[0] !== description || $[1] !== image || $[2] !== siteName || $[3] !== socialDescription || $[4] !== socialTitle || $[5] !== title || $[6] !== url) {
t1 = {
description,
image,
siteName,
socialDescription,
socialTitle,
title,
url
};
$[0] = description;
$[1] = image;
$[2] = siteName;
$[3] = socialDescription;
$[4] = socialTitle;
$[5] = title;
$[6] = url;
$[7] = t1;
} else {
t1 = $[7];
}
const context = t1;
let extra;
if ($[8] !== extraMetaTags) {
extra = [];
if (extraMetaTags?.length) {
for (let i = 0; i < extraMetaTags.length; ++i) {
const {
content,
name
} = extraMetaTags[i];
extra.push(/*#__PURE__*/_jsx("meta", {
content: content,
name: name
}, `extra-meta-tag-${i}`));
}
}
$[8] = extraMetaTags;
$[9] = extra;
} else {
extra = $[9];
}
let t2;
if ($[10] !== title) {
t2 = /*#__PURE__*/_jsx("title", {
children: title
});
$[10] = title;
$[11] = t2;
} else {
t2 = $[11];
}
let t3;
if ($[12] !== description) {
t3 = /*#__PURE__*/_jsx("meta", {
content: description,
name: "description"
});
$[12] = description;
$[13] = t3;
} else {
t3 = $[13];
}
let t4;
if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
t4 = /*#__PURE__*/_jsx("meta", {
content: "summary_large_image",
name: "twitter:card"
});
$[14] = t4;
} else {
t4 = $[14];
}
let t5;
if ($[15] !== socTitle) {
t5 = /*#__PURE__*/_jsx("meta", {
content: socTitle,
name: "twitter:title"
});
$[15] = socTitle;
$[16] = t5;
} else {
t5 = $[16];
}
let t6;
if ($[17] !== socDesc) {
t6 = /*#__PURE__*/_jsx("meta", {
content: socDesc,
name: "twitter:description"
});
$[17] = socDesc;
$[18] = t6;
} else {
t6 = $[18];
}
let t7;
if ($[19] !== image) {
t7 = image ? /*#__PURE__*/_jsx("meta", {
content: image,
name: "twitter:image"
}) : null;
$[19] = image;
$[20] = t7;
} else {
t7 = $[20];
}
let t8;
if ($[21] !== siteName) {
t8 = siteName ? /*#__PURE__*/_jsx("meta", {
content: `@${siteName}`,
name: "twitter:site"
}) : null;
$[21] = siteName;
$[22] = t8;
} else {
t8 = $[22];
}
let t9;
if ($[23] !== socTitle) {
t9 = /*#__PURE__*/_jsx("meta", {
content: socTitle,
property: "og:title"
});
$[23] = socTitle;
$[24] = t9;
} else {
t9 = $[24];
}
let t10;
if ($[25] !== image) {
t10 = image ? /*#__PURE__*/_jsx("meta", {
content: image,
property: "og:image"
}) : null;
$[25] = image;
$[26] = t10;
} else {
t10 = $[26];
}
let t11;
if ($[27] !== image || $[28] !== socTitle) {
t11 = image ? /*#__PURE__*/_jsx("meta", {
content: socTitle,
property: "og:image:alt"
}) : null;
$[27] = image;
$[28] = socTitle;
$[29] = t11;
} else {
t11 = $[29];
}
let t12;
if ($[30] !== socDesc) {
t12 = /*#__PURE__*/_jsx("meta", {
content: socDesc,
property: "og:description"
});
$[30] = socDesc;
$[31] = t12;
} else {
t12 = $[31];
}
let t13;
if ($[32] !== siteName) {
t13 = siteName ? /*#__PURE__*/_jsx("meta", {
content: siteName,
property: "og:site_name"
}) : null;
$[32] = siteName;
$[33] = t13;
} else {
t13 = $[33];
}
let t14;
if ($[34] !== url) {
t14 = url ? /*#__PURE__*/_jsx("meta", {
content: url,
property: "og:url"
}) : null;
$[34] = url;
$[35] = t14;
} else {
t14 = $[35];
}
let t15;
if ($[36] !== extra || $[37] !== t10 || $[38] !== t11 || $[39] !== t12 || $[40] !== t13 || $[41] !== t14 || $[42] !== t2 || $[43] !== t3 || $[44] !== t5 || $[45] !== t6 || $[46] !== t7 || $[47] !== t8 || $[48] !== t9) {
t15 = /*#__PURE__*/_jsxs(Helmet, {
children: [t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, extra]
});
$[36] = extra;
$[37] = t10;
$[38] = t11;
$[39] = t12;
$[40] = t13;
$[41] = t14;
$[42] = t2;
$[43] = t3;
$[44] = t5;
$[45] = t6;
$[46] = t7;
$[47] = t8;
$[48] = t9;
$[49] = t15;
} else {
t15 = $[49];
}
let t16;
if ($[50] !== children || $[51] !== context) {
t16 = children ? /*#__PURE__*/_jsx(Context, {
value: context,
children: children
}) : null;
$[50] = children;
$[51] = context;
$[52] = t16;
} else {
t16 = $[52];
}
let t17;
if ($[53] !== t15 || $[54] !== t16) {
t17 = /*#__PURE__*/_jsxs(_Fragment, {
children: [t15, t16]
});
$[53] = t15;
$[54] = t16;
$[55] = t17;
} else {
t17 = $[55];
}
return t17;
};
MetaTags.Context = Context;
export default MetaTags;
//# sourceMappingURL=MetaTags.js.map