Breadcrumb streamType

Frontastic provides you with a Breadcrumb so you can implement it easily if you want to include it in your project.

Below is an example of how that could look on your site:

The BreadcrumbFieldHandler comes with Frontastic as part of the API documentation.

🚧

This only works on pages within the page builderpage builder - An interface you work with to build your pages., you can't add this Frontastic componentFrontastic component - A customizable building block that's used together with other components to create a commerce site. Known as `tastic` for short in code. to a dynamic pagedynamic page - A type of page that creates the default layout of pages that use the same structure but with different data, for example, a Product Details Page, wishlist, cart, search, and so on. Previously known as `master page`..

You then need to add it into a Frontastic componentFrontastic component - A customizable building block that's used together with other components to create a commerce site. Known as `tastic` for short in code.. To do this, create a BreadcrumbTastic.json file as you'd usually set up a Frontastic componentFrontastic component - A customizable building block that's used together with other components to create a commerce site. Known as `tastic` for short in code., as well as the tastic.jsx. Below is an example of what you could include for both:

{
  "tasticType": "breadCrumb",
  "name": "Breadcrumb",
  "category": "Navigation",
  "icon": "menu",
  "schema": [
    {
      "name": "Breadcrumb",
      "fields": [
        {
          "label": "Breadcrumb",
          "field": "breadcrumb",
          "type": "stream",
          "streamType": "breadcrumb",
        }
      ]
    }
  ]
}
import React from 'react'
import PropTypes from 'prop-types'
import { compose } from 'redux';
import tastify from 'frontastic-catwalk/src/js/helper/tastify';
import app from 'frontastic-catwalk/src/js/app/app';



const BreadcrumbTastic = ({ data: { breadcrumb } }) => {
    if (!breadcrumb) {
        return null
    }


    return <div className='breadcrumb'>
        {breadcrumb.map(({ nodeId, name, prefix }) => <div>
            {/* add link elements here, example below */}
        </div>)}
    </div>
}


const NodeLinkArray = PropTypes.arrayOf({
    nodeId: PropTypes.string.isRequired,
    name: PropTypes.string.isRequired,
    prefix: PropTypes.string,
})


BreadcrumbTastic.propTypes = {
    data: PropTypes.shape({
        breadcrumb: NodeLinkArray.isRequired,
    }).isRequired,
}


export default compose(tastify()) BreadcrumbTastic;

If you haven't created a Frontastic componentFrontastic component - A customizable building block that's used together with other components to create a commerce site. Known as `tastic` for short in code. before, follow the steps in this article.

Below is an example of the middle section that included styling and link elements.

const BreadcrumbTastic = ({ data: { breadcrumb } }) => {
    return <div className='breadcrumb flex bg-gray-400 px-8 py-3 rounded-t-full space-x-3'>
        {breadcrumb?.map(({ nodeId, name }) => <div className="cursor-pointer" onClick={() => app.getRouter()?.push(`node_${nodeId}`)} >
            <p className="text-gray-700 font-bold" >{name}<span class="chevron right"></span></p>
        </div>)}

        <style>
            {.chevron::before {
            border-style: solid;
            border-width: 0.25em 0.25em 0 0;
            border-color: rgba(74, 85, 104);
            content: '';
            display: inline-block;
            height: 0.55em;
            position: relative;
            top: 0.4em;
            transform: rotate(-45deg);
            vertical-align: top;
            width: 0.55em;
        }

        .chevron.right:before {
            left: 0.1em;
            transform: rotate(45deg);
        }}
        </style>
    </div>
}

Did this page help you?