#๐Ÿ‘‰ Content collections for small e-catalog with no backend

14 messages ยท Page 1 of 1 (latest)

stone cloud
#

yeah, it sounds like a use-case content collections neatly allows

#

you could set details like product name, price, image in a schema, and astro will make sure all entries include all that information

astral vine
#

no need in schema right now. if only for practice new astro stuff

#

but there is one a big small problems - using <Image />

#

is it good?

const getProductImagesByCode = (code) => {
  const images = import.meta.glob("/src/images/product/*", { eager: true });
  const imagesProps = Object.values(images).map((image) => image.default);
  const imagesFiltered = imagesProps.filter((image) => image.src.includes(code));

  return imagesFiltered;
}

export default getProductImagesByCode;

im getting image(-s) by product's code and use them for <Image />
any better solution?

stone cloud
#

depends on how you plan to use it, but yes

#

markdown files can reference images in their frontmatter

#

and the when you call getEntry, you'd get the path to the optimized version of that image

astral vine
#

no no no...
i dont wanna describe images in md/mdx

#

image naming rule is <code>-[1...3].*

#

example 'FGC001-1.jpg`

#

function above find all image files with code i need.. then >> <Image/>

#

hm.. mb ez to describe all images.. hmm