Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
168 commits
Select commit Hold shift + click to select a range
2685532
Merge pull request #19 from kirill-zhirnov/15_product_page
Jan 17, 2022
58402db
working
Jan 18, 2022
0a96832
working
Jan 18, 2022
3075473
working
Jan 18, 2022
e137b22
working
Jan 19, 2022
9bbe740
working
Jan 20, 2022
0a222c9
aside menu and other improvements
Jan 21, 2022
0d98444
added generic menu to redux.
Jan 22, 2022
4a9b969
cart fixes
Jan 22, 2022
4aca82d
cart fixes
Jan 22, 2022
6ffb74e
linter version fix
Jan 22, 2022
cbcefa5
Merge pull request #43 from kirill-zhirnov/linters_add
Jan 22, 2022
243fb84
made common breadcrumbs component
keXXpert Jan 26, 2022
2c37d56
added variant pick animation
keXXpert Jan 26, 2022
59ba289
added custom hook
keXXpert Jan 26, 2022
0523807
added vertical menu component
keXXpert Jan 27, 2022
72af175
lint fix
keXXpert Jan 27, 2022
f5931c5
updated makeBreadCrumb interface
keXXpert Jan 27, 2022
3379ebd
improved animation
keXXpert Jan 28, 2022
ccfa067
updated v-menu classes and styling
keXXpert Jan 28, 2022
d4e0aca
updated callbacks
keXXpert Jan 28, 2022
5545c10
added filters collapse, check-buttons
keXXpert Jan 28, 2022
60bfa5e
minor style improvements
Jan 28, 2022
b08ec1f
Merge pull request #44 from kirill-zhirnov/30_breadcrumbs
Jan 28, 2022
7c0295d
Merge pull request #45 from kirill-zhirnov/35_animate_error
Jan 31, 2022
23c9ea4
Merge pull request #47 from kirill-zhirnov/36_vertical_menu
Jan 31, 2022
241aa23
added range slider, filters lazy load
keXXpert Feb 2, 2022
6cf9f5f
Merge branch 'master' into 28_filters
keXXpert Feb 2, 2022
d13c9b7
added popper
keXXpert Feb 3, 2022
2470d76
different filters improvements
keXXpert Feb 3, 2022
5920174
added horizontal menu
keXXpert Feb 4, 2022
0269378
Merge pull request #49 from kirill-zhirnov/28_filters
Feb 4, 2022
e627642
made class component for horMenu
keXXpert Feb 4, 2022
017ed68
added animation, BEM classes
keXXpert Feb 4, 2022
fbf8524
Merge branch 'master' into 37_horizontal_menu
keXXpert Feb 4, 2022
ca82c9c
different hor menu improvements
keXXpert Feb 7, 2022
82a125f
fixed update error
keXXpert Feb 7, 2022
f112a05
intial commit
keXXpert Feb 8, 2022
7a54a9a
fixed duplicate ids
keXXpert Feb 8, 2022
70eeaed
updated horizontal menu links and styling
keXXpert Feb 8, 2022
6ee5082
added filters mobile dialog
keXXpert Feb 8, 2022
ad05c5f
lint fix
keXXpert Feb 8, 2022
bebc4ef
Merge pull request #50 from kirill-zhirnov/37_horizontal_menu
Feb 8, 2022
c3860d1
minor improvements
Feb 9, 2022
7900234
updated footer component
keXXpert Feb 9, 2022
c00e4f1
updated call to order component
keXXpert Feb 10, 2022
4759c31
updated foter css class naming
keXXpert Feb 10, 2022
f5647e4
mobile filters form improvements
keXXpert Feb 10, 2022
862bb34
Merge branch 'master' into 51_filters_mobile
keXXpert Feb 10, 2022
af801d0
lint fix
keXXpert Feb 10, 2022
526d11d
initial aside menu setup
keXXpert Feb 11, 2022
8d43912
added aside menu swipe effect
keXXpert Feb 11, 2022
ab99ce8
rm console.log
Feb 11, 2022
a371996
fixed styles and naming
keXXpert Feb 11, 2022
94677bc
updated cart component
keXXpert Feb 11, 2022
ed193e5
Merge pull request #53 from kirill-zhirnov/51_filters_mobile
Feb 12, 2022
3459d46
updated css
keXXpert Feb 14, 2022
e4e6df5
Merge branch 'master' into 38_footer
keXXpert Feb 14, 2022
1ca0e09
fixed swipe speed
keXXpert Feb 14, 2022
1d5814a
updated page layout z-index and wrapper click
keXXpert Feb 14, 2022
2b6456e
Merge branch 'master' into 27_call2order
keXXpert Feb 14, 2022
3d68aa3
aside menu improvements
keXXpert Feb 14, 2022
e81207c
added ssr menu in cart, updated cart styling
keXXpert Feb 14, 2022
056d72d
hid sort icon on inactive filter
keXXpert Feb 14, 2022
1e79748
added category title sort, FA icons import
keXXpert Feb 14, 2022
f0ca78a
minor adjustments
Feb 15, 2022
be752a6
Merge pull request #55 from kirill-zhirnov/38_footer
Feb 15, 2022
dc49c35
minor adjustments
Feb 15, 2022
541f617
Merge pull request #60 from kirill-zhirnov/40_aside_menu
Feb 15, 2022
50eae68
Merge pull request #61 from kirill-zhirnov/32_sorting
Feb 15, 2022
ef47108
update
Feb 15, 2022
98bf75f
product page improvements
keXXpert Feb 16, 2022
5225833
package.json fix
keXXpert Feb 16, 2022
102def7
Merge branch 'master' into 34_product_styles
keXXpert Feb 16, 2022
d620b75
fixed type import
keXXpert Feb 16, 2022
246c13f
call2order top placement
keXXpert Feb 16, 2022
ff8ce1d
Merge branch 'master' into 27_call2order
keXXpert Feb 16, 2022
9c57604
styles naming improvement
keXXpert Feb 16, 2022
889551c
import fixes
keXXpert Feb 16, 2022
6ecf6a3
updated swiper styling
keXXpert Feb 16, 2022
15a7367
added imageSlider dynamic import
keXXpert Feb 16, 2022
3c59489
fixed cart and horizontal menu bugs
keXXpert Feb 16, 2022
dcd2b70
updated api orders-cart interface
keXXpert Feb 16, 2022
7138a92
minor styling fix
keXXpert Feb 16, 2022
e8bae8c
lint fix
keXXpert Feb 16, 2022
026705f
Merge pull request #56 from kirill-zhirnov/27_call2order
Feb 17, 2022
e28bf0b
merged with master
Feb 17, 2022
19cab0f
Merge pull request #64 from kirill-zhirnov/34_product_styles
Feb 17, 2022
bd85748
fix package.json
Feb 17, 2022
123331c
Merge pull request #66 from kirill-zhirnov/48_api_orders
Feb 17, 2022
e9ff4b1
fix package.json
Feb 17, 2022
1ec7ffd
Merge branch 'master' into 62_cart
keXXpert Feb 18, 2022
3341152
Merge pull request #65 from kirill-zhirnov/62_cart
Feb 21, 2022
a0eb9ad
checkout added
Feb 23, 2022
b196a42
seo fixes. Prepare styles for fork.
Feb 25, 2022
573b327
main page fixes
Feb 25, 2022
f025ad5
default variables
Feb 25, 2022
9a17bc0
preconnect
Feb 25, 2022
0b8694c
preconnect fix
Feb 26, 2022
201cba2
variables fixes
Feb 26, 2022
782c54f
variables fixes
Feb 26, 2022
b75553a
minor improvements
Feb 26, 2022
246cc0a
added products slider
keXXpert Feb 28, 2022
d166d61
minor improvements
Feb 28, 2022
069f382
minor improvements
Feb 28, 2022
59cca77
added cover component
keXXpert Mar 1, 2022
10e9d69
lint fix
keXXpert Mar 1, 2022
bccf30b
minor improvements
Mar 1, 2022
216d347
minor improvements
Mar 1, 2022
eba60ef
minor improvements
Mar 1, 2022
bb2da9a
minor improvements
Mar 1, 2022
14e506b
slider improvements, fixing issues
keXXpert Mar 1, 2022
8fd7480
Merge branch 'master' into 68_product_slider
keXXpert Mar 1, 2022
92fa1fe
import fix
keXXpert Mar 1, 2022
451c496
lint fix
keXXpert Mar 1, 2022
980a355
added to-cart to product
keXXpert Mar 1, 2022
6c32813
different cover component improvements
keXXpert Mar 2, 2022
c16b8fe
Merge branch 'master' into 70_cover
keXXpert Mar 2, 2022
c1b5a46
products slider improvements
keXXpert Mar 2, 2022
fcf6203
added large swiper slider
keXXpert Mar 3, 2022
379acd9
added page-block
Mar 3, 2022
607ad2e
Merge pull request #71 from kirill-zhirnov/70_cover
Mar 3, 2022
8500b5b
slider improvements
keXXpert Mar 3, 2022
37a2172
Merge branch 'master' into 68_product_slider
keXXpert Mar 3, 2022
7ed9536
minor improvements
Mar 3, 2022
b97e1ea
minor type improvement
keXXpert Mar 3, 2022
42f9240
Merge branch 'master' into 72_slider
keXXpert Mar 3, 2022
340357a
minor improvements
Mar 3, 2022
590fab1
Merge pull request #74 from kirill-zhirnov/72_slider
Mar 3, 2022
757bfa9
merged
Mar 3, 2022
56530f4
Merge pull request #69 from kirill-zhirnov/68_product_slider
Mar 3, 2022
e937f1e
added sitemap and noindex tag
keXXpert Mar 4, 2022
a53aac0
Merge pull request #75 from kirill-zhirnov/73_sitemap
Mar 5, 2022
564b55a
robots added
Mar 5, 2022
f570275
minor improvements
Apr 2, 2022
b834303
minor improvements
Apr 4, 2022
140ba00
micense and readme
Apr 5, 2022
b1d945a
package.json updates
Apr 5, 2022
4972d2c
minor fixes
Apr 7, 2022
fca6e13
minor fixes
Apr 8, 2022
5e6d14b
minor fixes
Apr 8, 2022
644ca8d
bump versions
Apr 9, 2022
f0ce5b7
minor fixes
Apr 9, 2022
49b2df2
readme patch
May 28, 2022
b772b00
next upgraded
Jun 24, 2022
72212bd
updated boundless-checkout-react to latest version
i-anton Sep 2, 2022
4cafed9
up readme
Sep 17, 2022
eb2a18a
updaate checkout version
Sep 17, 2022
5835567
Merge pull request #77 from kirill-zhirnov/updateCheckout
Sep 17, 2022
1ae27a9
Merge branch 'master' of github.com:kirill-zhirnov/boundless-nextjs-s…
Sep 17, 2022
1c1f7a5
readme update
Oct 1, 2022
4d76465
readme update
Dec 4, 2022
0ba4b7c
readme update
Dec 30, 2022
7426f15
v1.0.1
Mar 7, 2023
4f5376b
API&Checkout upgrade
Mar 7, 2023
9880414
fix minor issue
Apr 21, 2023
338a442
v1.0.2
Apr 21, 2023
3603c64
fetch locale options from API
Apr 22, 2023
bd41066
v1.0.3
Apr 22, 2023
16f2b95
v1.0.4
Jun 3, 2023
1881791
minor fix for cart
Jun 3, 2023
632b41d
add youtube link
Jun 3, 2023
e2ebc16
working
Aug 19, 2023
1cbd63c
transformed links to next13
Aug 19, 2023
9249172
transformed imgs to next13
Aug 19, 2023
8c843e8
v1.0.5
Aug 19, 2023
0961805
fixes
Aug 19, 2023
88e212d
v1.0.6
Aug 19, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
BOUNDLESS_BASE_URL=< your shop url, i.e. http://www.myshop.com >
BOUNDLESS_API_PERMANENT_TOKEN=<< your permanent token here>>
BOUNDLESS_INSTANCE_ID=<ID>

# Optional params:
# BOUNDLESS_BASE_URL=< your shop url, i.e. http://www.myshop.com >
# BOUNDLESS_PRODUCTS_IMAGE_PROPORTION=

# For dev team:
# BOUNDLESS_API_BASE_URL=https://api.rick.dev.boundless-commerce.com
# BOUNDLESS_S3_PREFIX=dev-rick
# BOUNDLESS_S3_PREFIX=dev-rick
# BOUNDLESS_MEDIA_SERVER=https://dev-img.boundless-commerce.com
27 changes: 27 additions & 0 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Linters
#on: push

on:
push:
branches-ignore: [master]
pull_request:
branches: [master]

jobs:
super-lint:
name: Lint code base
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Run Super-Linter
uses: github/super-linter@v4
env:
DEFAULT_BRANCH: master
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# validate only typescript:
VALIDATE_TYPESCRIPT_ES: true
VALIDATE_CSS: true
CSS_FILE_NAME: .stylelintrc.json
LINTER_RULES_PATH: /
2 changes: 1 addition & 1 deletion .stylelintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"selector-class-pattern": null,
"selector-no-qualifying-type": [true, {"ignore": ["attribute", "class", "id"]}]
},
"ignoreFiles": ["**/*.css", "**/*.js", "**/*.ts", "**/*.tsx"]
"ignoreFiles": ["**/*.css", "**/*.js", "**/*.ts", "**/*.tsx", "**/*.md"]
}
2 changes: 1 addition & 1 deletion @types/category.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import {ICategory} from 'boundless-api-client/types/catalog/category';
import {ICategory} from 'boundless-api-client';

export type ICategoryPartial = Pick<ICategory, 'category_id' | 'title' | 'custom_link' | 'url_key' | 'image'> & {children?: ICategory[] | null};
19 changes: 19 additions & 0 deletions @types/components.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export interface IBreadCrumbItem {
title: string;
isActive?: boolean;
url?: string
}

export interface IMenuItem {
title: string,
url?: string,
img?: IMenuItemImage,
isActive?: boolean,
children?: IMenuItem[]
}

export interface IMenuItemImage {
src: string,
width?: number,
height?: number
}
21 changes: 0 additions & 21 deletions @types/image.ts

This file was deleted.

6 changes: 6 additions & 0 deletions @types/settings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import {ICurrency, ILocaleSettings} from 'boundless-api-client';

export interface IBasicSettings {
'system.locale': ILocaleSettings,
'system.currency': ICurrency
}
20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright (c) 2012-2022 Scott Chacon and others

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
66 changes: 66 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Next.js E-Commerce template

Ready to use [Next.js](https://nextjs.org) (TypeScript) starter kit for high-performance
e-commerce websites 🔥.

Free 👍. Ready to use 😎. Just clone & deploy! 🤘

## Online Demo ⚡️

[blank.demos.my-boundless.app](https://blank.demos.my-boundless.app/) - deployed to Netlify.

## About Boundless Commerce

![Boundless-commerce.com](assets/logo.svg)

[Boundless-commerce.com](https://boundless-commerce.com/) - API’s First Headless E-commerce CMS: We Provide An
Admin-Side For Store Management, Powerful API, And Ready-To-Use Checkout Area.

## Getting Started

1. Go to [Boundless-commerce.com](https://boundless-commerce.com/) and create a free account (no credit card required).
2. Go to "Control panel" -> "Settings" -> "Access tokens" and create a new one:

![](assets/settings-menu.png)
![](assets/create-access-token-btn.png)

3. Copy `.env.example` to `.env`
4. Modify `.env`: put values for the `BOUNDLESS_API_PERMANENT_TOKEN` and `BOUNDLESS_INSTANCE_ID`, copy values from:

![](assets/copy-credentials.png)

5. Install dependencies: `yarn install`
6. `yarn dev` - to start locally, then open `http://localhost:3000`
7. If you want to have absolute URLs in the sitemap.xml and OpenGraph meta tags
you need to also specify `BOUNDLESS_BASE_URL`.

### Optional parameters

- `BOUNDLESS_BASE_URL` - Base URL if you want to have absolute
URLs in the sitemap.xml and OpenGraph meta tags.
- `BOUNDLESS_PRODUCTS_IMAGE_PROPORTION` - Specify resize proportion so product images in lists have
the same size. Possible values are: `1-1`, `2-3`, `3-2`,`4-5`, `5-4`, `3-4`, `4-3`, `16-9`, `9-16`.

## What is included?

Fully ready E-Commerce website with a hierarchical catalog, product widgets,
filters, and marketing components like sliders and carousels.

We developed the template keeping SEO in mind: schema markup, sitemap, and
all necessary meta-tags.

Shopping cart with a nice animated widget and [Fully customizable React checkout](https://github.com/kirill-zhirnov/boundless-checkout-react).

User friendly mobile version.

## Video tutorial

[![How to build React E-commerce Website with Next.js, TypeScript, and Redux in 2023 (Tutorial)](https://img.youtube.com/vi/BOZRLereGig/0.jpg)](https://youtu.be/BOZRLereGig "How to build React E-commerce Website with Next.js, TypeScript, and Redux in 2023 (Tutorial)")

## Ways to deploy Node.js Apps

[![Ways to deploy NodeJs (and/or NextJS) apps - quick overview](https://img.youtube.com/vi/pRj0o-B57O4/0.jpg)](https://www.youtube.com/watch?v=pRj0o-B57O4 " Ways to deploy NodeJs (and/or NextJS) apps - quick overview")

---

[NextJS eCommerce templates](https://boundless-commerce.com/templates) - Free. Ready to use. Just clone & deploy!
Binary file added assets/cliff_1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/cliff_2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/copy-credentials.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/cover-bg-portrait.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/cover-bg.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/create-access-token-btn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
Binary file added assets/settings-menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
105 changes: 105 additions & 0 deletions components/AsideMenu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import clsx from 'clsx';
import {useAppDispatch, useAppSelector} from '../hooks/redux';
import {RootState} from '../redux/store';
import {disableBodyScroll, enableBodyScroll, clearAllBodyScrollLocks} from 'body-scroll-lock';
import {useEffect, useRef} from 'react';
import {setIsOpened} from '../redux/reducers/asideMenu';
import HeaderCart from './cart/HeaderCart';
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
import {faTimes} from '@fortawesome/free-solid-svg-icons';
import AsideMenuList from './asideMenu/MenuList';
import {DragGesture} from '@use-gesture/vanilla';
import {IMenuItem} from '../@types/components';

export default function AsideMenu({menuList}: {menuList?: IMenuItem[]}) {
const rootEl = useRef(null);
const isOpened = useAppSelector((state: RootState) => state.asideMenu.isOpened);
const isRouteChanging = useAppSelector((state: RootState) => state.app.isRouteChanging);
const dispatch = useAppDispatch();
const gesture = useRef<DragGesture | null>(null);

const closeIfOpened = () => {
if (isOpened) {
dispatch(setIsOpened(false));
}
};
const onEscPressed = (e: KeyboardEvent) => {
if (e.defaultPrevented || !isOpened) {
return;
}

if (e.key !== undefined && e.key === 'Escape') {
closeIfOpened();
} else if (e.keyCode !== undefined && e.keyCode === 27) {
closeIfOpened();
}
};

const enableSwipe = () => {
const body = document.querySelector('body');

body!.style.touchAction = 'none';
gesture.current = new DragGesture(body!, ({last, movement}) => {
// if (last && vx > 0.3 && (Math.abs(vy) < Math.abs(vx)) && dx === 1) {
if (last && movement[0] > 100) {
closeIfOpened();
}
});
};

const disableSwipe = () => {
const body = document.querySelector('body');

if (gesture.current) gesture.current.destroy();
gesture.current = null;
body!.style.touchAction = 'auto';
};

useEffect(() => {
if (isRouteChanging) closeIfOpened();
}, [isRouteChanging]); //eslint-disable-line

useEffect(() => {
if (isOpened) {
if (rootEl.current) {
disableBodyScroll(rootEl.current);
}

enableSwipe();

window.addEventListener('resize', closeIfOpened);
window.addEventListener('keydown', onEscPressed);
} else {
if (rootEl.current) {
enableBodyScroll(rootEl.current);
}

disableSwipe();

window.removeEventListener('resize', closeIfOpened);
window.removeEventListener('keydown', onEscPressed);
}

return () => {
clearAllBodyScrollLocks();
window.removeEventListener('resize', closeIfOpened);
window.removeEventListener('keydown', onEscPressed);

disableSwipe();
};
}, [isOpened]);//eslint-disable-line

return (
<aside className={clsx('aside-menu', {'aside-menu_visible': isOpened})}
ref={rootEl}
>
<div className='aside-menu__header'>
<HeaderCart className={'cart-header cart-header_horizontal'} />
<button className='btn' onClick={closeIfOpened} >
<FontAwesomeIcon icon={faTimes} />
</button>
</div>
{menuList && <AsideMenuList menuList={menuList} />}
</aside>
);
}
70 changes: 32 additions & 38 deletions components/BreadCrumbs.tsx
Original file line number Diff line number Diff line change
@@ -1,54 +1,48 @@
import {ICategoryFlatItem} from 'boundless-api-client/types/catalog/category';
import clsx from 'clsx';
import Link from 'next/link';
import {TQuery} from '../@types/common';
import {getCategoryUrl} from '../lib/services/urls';
import {IBreadCrumbItem} from '../@types/components';

export default function BreadCrumbs({parents, activeParams}: IBreadCrumbsProps) {
const _parents = [...parents];
export default function BreadCrumbs({items}: {items: IBreadCrumbItem[]}) {
const isEmpty = items.length === 0;

const richItemAttrs = {
itemProp: 'itemListElement',
itemScope: true,
itemType: 'http://schema.org/ListItem'
itemType: '//schema.org/ListItem'
};

return (
<nav className='breadcrumb-wrapper'>
<ol className='breadcrumb' itemProp='breadcrumb' itemScope itemType='http://schema.org/BreadcrumbList'>
<nav className={clsx('breadcrumb-wrapper', isEmpty && 'd-none')}>
{!isEmpty && <ol className='breadcrumb' itemProp='breadcrumb' itemScope itemType='//schema.org/BreadcrumbList'>
<li className='breadcrumb-item' {...richItemAttrs}>
<Link href='/'>
<a itemProp='item'><span itemProp='name'>Home</span></a>
<Link href='/' itemProp='item'>
<span itemProp='name'>Home</span>
</Link>
<meta itemProp='position' content='1' />
</li>
{parents?.length > 0 && _parents.reverse().map((parent, i) => {
const isLast = parents.length === i + 1;
const isActive = isLast && !activeParams;
const title = parent.title || parent.joined_title;

return (
<li
className={clsx('breadcrumb-item', isActive && 'active')}
key={parent.category_id}
{...(isActive ? {} : richItemAttrs)}
>
{isActive
? title
: <Link href={getCategoryUrl(parent, activeParams)}>
<a itemProp='item'>
<span itemProp='name'>{title}</span>
</a>
</Link>}
<meta itemProp='position' content={String(i + 2)} />
</li>);
})}
</ol>
{items.map((item, i) => (
<li
className={clsx('breadcrumb-item', item.isActive && 'active')}
key={i}
{...(item.url ? richItemAttrs : {})}
>
{item.url && !item.isActive
? <>
<Link href={item.url} itemProp='item'>
<span itemProp='name'>{item.title}</span>
</Link>
<meta itemProp='position' content={String(i + 2)} />
</>
:
<>
<span itemProp='item'>
<span itemProp='name'>{item.title}</span>
</span>
<meta itemProp='position' content={String(i + 2)} />
</>
}
</li>))}
</ol>}
</nav>
);
}

interface IBreadCrumbsProps {
parents: ICategoryFlatItem[];
activeParams?: TQuery;
);
}
Loading