Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const { result, preloadDump } = await Scrivito.renderPage(obj, () => {
const bodyContent = ReactDOMServer.renderToString();
const helmet = Helmet.renderStatic();
return {
objId: obj.id(),
objUrl: Scrivito.urlFor(obj),
htmlAttributes: helmet.htmlAttributes.toString(),
headContent: `
${helmet.title.toString()}
${helmet.meta.toString()}
${helmet.link.toString()}
`,
bodyAttributes: helmet.bodyAttributes.toString(),
bodyContent,
};
});
const htmlAttributes = { lang: "en" };
let title = "";
let meta = [];
const links = [
{
rel: "shortcut icon",
type: "image/png",
href: favicon,
},
];
const page = Scrivito.currentPage();
if (page) {
title = page.get("title") || "";
meta = getMetadata(page);
links.push({ rel: "canonical", href: Scrivito.urlFor(page) });
}
return (
);
});
render() {
const root = Scrivito.Obj.root();
if (!root) {
return null;
}
const cookieConsentLink = root.get("cookieConsentLink");
if (!cookieConsentLink) {
return null;
}
const cookieConsentLinkUrl = Scrivito.urlFor(cookieConsentLink);
const cookieLinkTitle = cookieConsentLink.title() || "Learn more »";
return (
<div></div>
function pageToSitemapUrl(page) {
return {
url: [
{ loc: Scrivito.urlFor(page) },
{ lastmod: formatDate(page.lastChanged(), 'yyyy-mm-dd') },
],
};
}
function getMetadata(page) {
const meta = [
{ name: "twitter:card", content: "summary_large_image" },
{ name: "prerender-status-code", content: "200" },
{ property: "og:type", content: "article" },
{ property: "og:url", content: Scrivito.urlFor(page) },
];
const extractedText = Scrivito.extractText(page, { length: 330 });
const robotsIndex = page.get("robotsIndex");
if (robotsIndex === "no") {
meta.push({ name: "robots", content: "noindex" });
}
const description = page.get("metaDataDescription");
if (description) {
meta.push({ name: "description", content: description });
}
const root = Scrivito.Obj.root();
if (root) {
const facebookAppId = root.get("facebookAppId");
asyncForEach(objsGroup, async obj => {
try {
const prerenderedFiles = await prerenderObj(obj);
await asyncForEach(prerenderedFiles, storeResult);
} catch (e) {
failedCount += 1;
const pageId = obj.id();
const pageUrl = Scrivito.urlFor(obj);
reportError(
`Error while processing obj ${pageId} (${pageUrl}). Skipping file.`,
e.message,
e
);
}
})
);
Scrivito.load(() => {
const link = this.props.page.get("link");
const url = link && Scrivito.urlFor(link);
return { link, url };
}).then(({ link, url }) => {
if (!link) {
function dataFromEvent(event) {
return {
"@context": "http://schema.org",
"@type": "Event",
name: event.get("title"),
url: Scrivito.urlFor(event),
startDate: formatDate(event.get("date"), "yyyy-mm-dd"),
location: locationFromEvent(event),
image: urlFromBinary(event.get("image")),
description: event.get("metaDataDescription"),
};
}
function pageToSitemapUrl(page) {
return {
url: [
{ loc: Scrivito.urlFor(page) },
{ lastmod: formatDate(page.lastChanged(), "yyyy-mm-dd") },
],
};
}
function getMetadata(page) {
const meta = [
{ name: "twitter:card", content: "summary_large_image" },
{ name: "prerender-status-code", content: "200" },
{ property: "og:type", content: "article" },
{ property: "og:url", content: Scrivito.urlFor(page) },
];
const textExtract = textExtractFromObj(page);
const robotsIndex = page.get("robotsIndex");
if (robotsIndex === "no") {
meta.push({ name: "robots", content: "noindex" });
}
const description = page.get("metadataDescription");
if (description) {
meta.push({ name: "description", content: description });
}
const root = Scrivito.Obj.root();
if (root) {
const facebookAppId = root.get("facebookAppId");