tadam
(Tom Adam)
May 20, 2021, 3:53pm
1
Hi, I am attempting to render a list of blog posts on our homepage. I am using SlizeZone to retrieve the list of articles. The data returned Is very minimal in the "articles_to_list" and I am unsure how to retrieve the full data so I can display the image, title, short description etc... I have a workaround using .getByUid but I'm hoping there is a cleaner way.
Thank you!
Tom
Phil
(Phil Snow)
May 24, 2021, 10:44am
3
Hi Tom,
Can you tell me are you using Next.js or Nuxt.js?
Thanks.
Phil
(Phil Snow)
May 25, 2021, 5:07pm
5
For querying a list od documents and getting all their data then you're better using the @prismic/client
and querying by type:
Like we do in our Next.js blog example:
import React from "react";
import Head from "next/head";
import Prismic from '@prismicio/client'
import { RichText } from "prismic-reactjs";
// Project components & functions
import DefaultLayout from "layouts";
import { Header, PostList, SetupRepo } from "components/home";
import { Client } from "utils/prismicHelpers";
/**
* Homepage component
*/
const Home = ({ doc, posts }) => {
if (doc && doc.data) {
return (
<DefaultLayout>
<Head>
<title>{RichText.asText(doc.data.headline)}</title>
</Head>
This file has been truncated. show original
Otherwise you'll want to use Fetchlinks or GraphQuery (Fetchlinks V2) , but for this make sure you're using the latest version of the next-slicezone package (0.1.0-alpha.0), which changes how values from the parameters are called. Learn more about next-slicezone's Lifecycle hooks .
To install this run npm install next-slicezone@0.1.0-alpha.0
system
(system)
closed as resolved, flag & select 'Something Else' to reopen.
June 10, 2021, 3:02pm
6
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.