Skip to content

IndexField

Daniel Petutschnigg edited this page Oct 10, 2021 · 19 revisions

Table of Contents

Description

The IndexField provides an easy way to link to childpages of a slug or to fetch data of childpages and build cards on any page in your project. It is not possible to edit the text on these components for that job please look at our StreamField.

Code

import {fields} from '@snek-at/jaen-pages'

const Component = () => {
  return (
    <fields.IndexField
      fieldName="component-indexfield"
      fixedSlug={'pageId'}
      onRender={(page) => {
        return(
	  [...]
	}}
    />
  )
}


export default Component

Parameters

Property Type Required Description
fieldName string yes The fieldName requires you to give the field an identifier that is unique on that page. It is advisable to use descriptive names for fetching purposes.
fixedSlug string no If fixedSlug is not specified the IndexField will take the children of the current page. It allows you to decide which pages children are used.
onRender function yes onRender allows you to build React-Components of any kind.

onRender

Property Type Description
page object The page property gives you the page data including childpages in the form of an object

The page property looks like this:
──page
  ├── children
  ├── fields
  │   ├── your
  │   ├── fields
  │   └── here
  ├── images
  ├── pageMetaData
  │   ├── canonical
  │   ├── datePublished
  │   ├── description
  │   ├── image
  │   ├── isBlogPost
  │   └── title
  ├── parent
  ├── path
  ├── slug
  └── template

Code Sandbox

WIP