balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

TaxonomyBreadcrumbs.js (1315B)


      1 import { useTemplatesStore } from '../state/Templates'
      2 
      3 export default function TaxonomyBreadcrumbs() {
      4     const searchParams = useTemplatesStore(state => state.searchParams)
      5     const formatTitle = (title) => title.replace('tax_', '').replace(/_/g , ' ').replace(/\b\w/g, l => l.toUpperCase())
      6     return <div className="hidden sm:flex items-start flex-col lg:flex-row -mt-2 lg:-mx-2 mb-4 lg:divide-x-2 lg:leading-none">
      7         {Object.entries(searchParams.taxonomies).map((tax) => {
      8             // Special exception for page templates
      9             if (searchParams.type === 'template' && tax[0] === 'tax_pattern_types') {
     10                 return ''
     11             }
     12             // Special exception for plugins (like metaslider) that won't have full page templates
     13             if (searchParams.type === 'template' && tax[0] === 'tax_features') {
     14                 return ''
     15             }
     16             // Special exception for page types
     17             if (searchParams.type === 'pattern' && tax[0] === 'tax_page_types') {
     18                 return ''
     19             }
     20             return <div key={tax[0]} className="lg:px-2 text-left">
     21                 <span className="font-bold">{formatTitle(tax[0])}</span>: <span>{tax[1]
     22                     ? tax[1]
     23                     : 'All'}</span>
     24             </div>
     25         })}</div>
     26 }