Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 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;
}
Scrivito.provideComponent("JobOverviewWidget", ({ widget }) => {
let jobsSearch = Scrivito.getClass("Job").all();
if (widget.get("locationLocality")) {
jobsSearch = jobsSearch.and(
"locationLocality",
"containsPrefix",
widget.get("locationLocality")
);
}
const jobs = [...jobsSearch];
if (!jobs.length) {
return (
There are no job pages. Create one using the page menu.
);
}
({ maxItems, author, tag, filterBlogPostId }) => {
let blogPosts = Scrivito.getClass("BlogPost")
.all()
.order("publishedAt", "desc");
if (author) {
blogPosts = blogPosts.and("author", "refersTo", author);
}
if (tag) {
blogPosts = blogPosts.and("tags", "equals", tag);
}
if (filterBlogPostId) {
blogPosts = blogPosts.andNot("id", "equals", filterBlogPostId);
}
let posts;
if (maxItems) {
posts = blogPosts.take(maxItems);
} else {