Commit 492fb50f authored by Jon Moore's avatar Jon Moore
Browse files

Update BlogListing.js

parent 738f687d
Pipeline #39497 passed with stage
in 3 minutes and 42 seconds
......@@ -12,13 +12,18 @@ import BlogCard from './BlogCard';
const fetchEntries = async versionStatus => {
const triggerSearch = async versionStatus => {
try {
//DELIVERY API QUERY START//
let query = new Query(
Op.equalTo('sys.contentTypeId', 'blogPost'),
Op.equalTo('sys.versionStatus', versionStatus)
);
query.pageSize = 3;
query.fields = ['title', 'summary', 'image', 'sys'];
//DELIVERY API QUERY END//
//DELIVERY API SEARCH START//
return await cachedSearch.search(query, 1);
//DELIVERY API SEARCH END//
} catch (error) {
throw new Error(error);
}
......@@ -29,6 +34,7 @@ const fetchEntries = async versionStatus => {
const BlogListing = ({ className }) => {
const [results, setResults] = useState();
//GET VERSION STATUS
const versionStatus = useSelector(selectVersionStatus);
//const versionStatus = 'latest';
useEffect(() => {
......@@ -39,6 +45,7 @@ const BlogListing = ({ className }) => {
let resultsInfo = null;
//DELIVERY API PAGING INFO START//
if (results && results.totalCount > 0) {
const start = results.pageIndex * results.pageSize + 1;
let end = results.pageSize;
......@@ -46,6 +53,7 @@ const BlogListing = ({ className }) => {
resultsInfo = `Displaying ${start}-${end} of ${results.totalCount} results`;
}
//DELIVERY API PAGING INFO END//
return (
<BlogListingStyled className={className}>
......@@ -56,6 +64,7 @@ const BlogListing = ({ className }) => {
/>
)}
{/* DELIVERY API RENDER ENTRIES START */}
{results &&
results.items &&
results.items.map((entry, idx) => {
......@@ -70,6 +79,7 @@ const BlogListing = ({ className }) => {
);
})}
{!results || (results.length < 1 && <p>No results found.</p>)}
{/* DELIVERY API RENDER ENTRIES END */}
</BlogListingStyled>
);
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment