Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
calculateResults() {
if (!this.props.params.q) {
return {
searchResults: [],
totalCount: 0,
tags: [],
};
}
let search = Scrivito.Obj.where(
"*",
"containsPrefix",
this.props.params.q
).andNot("_objClass", "equals", blacklistObjClasses);
// make sure, that tags are calculated _before_ limiting to specific tag.
const tags = search.facet("tags").map(tag => tag.name());
if (this.props.params.tag) {
search = search.and("tags", "equals", this.props.params.tag);
}
return {
searchResults: search.take(this.state.maxItems),
totalCount: search.count(),
tags,
const BlogPostPreviousLink = Scrivito.connect(({ currentBlogPost }) => {
const currentDate = currentBlogPost.get("publishedAt");
// find less than or equal publishedAt
const [olderPost] = Scrivito.getClass("BlogPost")
.all()
.andNot("id", "equals", currentBlogPost.id())
.andNot("publishedAt", "isGreaterThan", currentDate)
.order("publishedAt", "desc")
.take(1);
if (!olderPost) {
return null;
}
return (
<i aria-hidden="true">
</i><i aria-hidden="true">
);
});</i>
const BlogPostNextLink = Scrivito.connect(({ currentBlogPost }) => {
const currentDate = currentBlogPost.get("publishedAt");
// find greater than publishedAt
const [newerPost] = Scrivito.getClass("BlogPost")
.where("publishedAt", "isGreaterThan", currentDate)
.order("publishedAt", "asc")
.take(1);
if (!newerPost) {
return null;
}
return (
<i aria-hidden="true">
</i><i aria-hidden="true">
);
});
</i>
export default async function prerenderObjs(
objClassesBlacklist,
storeResult,
reportError
) {
console.time("[prerenderObjs]");
console.time("Loading all objs");
const objs = await Scrivito.load(() => allObjs(objClassesBlacklist));
console.timeEnd("Loading all objs");
console.log(`Loaded ${objs.length} objs`);
let failedCount = 0;
const objsGroups = chunk(objs, 10);
await asyncForEachSequential(objsGroups, async objsGroup =>
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(
export default async function prerenderSitemap(
objClassesWhitelist,
storeResult
) {
console.time("[prerenderSitemap]");
const pages = await Scrivito.load(() =>
prerenderSitemapSearch(objClassesWhitelist).take()
);
const sitemapUrls = await Scrivito.load(() => pages.map(pageToSitemapUrl));
const content = sitemapUrlsToSitemapXml(sitemapUrls);
console.log(
`[prerenderSitemap] Generated sitemap.xml with ${sitemapUrls.length} items.`
);
console.timeEnd("[prerenderSitemap]");
await storeResult({ filename: "/sitemap.xml", content });
}
function SearchResultItem({ resultItem, q }) {
const searchWords = q.split(/\s+/);
const extractedText = Scrivito.extractText(resultItem, { length: 220 });
const textToHighlight = truncate(extractedText, {
length: 200,
separator: /,? +/,
});
return (
<div>
<div>
<h3>
</h3></div></div>
export function registerTextExtract(className, attributes) {
if (!isString(className)) {
console.warn(
`registerTextExtract: className '${className}' needs to be a string!`
);
}
if (!Scrivito.getClass(className)) {
console.warn(
`registerTextExtract: className '${className}' is not defined!`
);
}
if (textExtractRegistry[className]) {
console.warn(
`registerTextExtract: className '${className}' is already registered!`
);
}
textExtractRegistry[className] = attributes;
}
handleSubmit(event) {
event.preventDefault();
event.stopPropagation();
Scrivito.navigateTo(() => Scrivito.currentPage(), { q: this.state.q });
}
}
handleSubmit(event) {
event.preventDefault();
event.stopPropagation();
Scrivito.navigateTo(oldestSearchResultsPage, { q: this.state.q });
this.setState({ q: "" });
this.props.toggleSearch();
}
}
const obj = Scrivito.currentPage();
if (!obj.get("navigationSection")) {
return null;
}
return (
);
}
export default Scrivito.connect(NavigationSection);