Add language and theme to breadcrumbs.
This commit is contained in:
parent
50dce801a2
commit
1263ad3390
@ -1,10 +1,14 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { getLanguage } from '../App';
|
||||||
|
import { useTheme } from '../ThemeContext';
|
||||||
|
|
||||||
const Breadcrumbs = ({ separator, path, children }) => {
|
const Breadcrumbs = ({ separator, path, children }) => {
|
||||||
|
const { theme } = useTheme();
|
||||||
|
const language = getLanguage();
|
||||||
const items = React.Children.toArray(children);
|
const items = React.Children.toArray(children);
|
||||||
|
|
||||||
const generatePath = (index) => {
|
const generatePath = (index) => {
|
||||||
return path.split('/').slice(0, index + 1).join('/');
|
return '/' + language + '/' + path.split('/').slice(0, index + 1).join('/');
|
||||||
};
|
};
|
||||||
|
|
||||||
if (items.length !== path.split('/').length) {
|
if (items.length !== path.split('/').length) {
|
||||||
@ -12,18 +16,20 @@ const Breadcrumbs = ({ separator, path, children }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='breadcrumbs'>
|
<div className={`breadcrumbs`}>
|
||||||
{items.map((item, index) => (
|
{
|
||||||
<React.Fragment key={index}>
|
items.map((item, index) => (
|
||||||
{index > 0 && <span className='separator'>{separator}</span>}
|
<React.Fragment key={index}>
|
||||||
{index < items.length - 1 ? (
|
{index > 0 && <span className='separator'>{separator}</span>}
|
||||||
<a href={generatePath(index)}>{item}</a>
|
{index < items.length - 1 ? (
|
||||||
) : (
|
<a className={`small text-${theme}`} href={generatePath(index)}>{item}</a>
|
||||||
<a href={generatePath(index)}>{item}</a>
|
) : (
|
||||||
)}
|
<a className={`small text-${theme}`} href={generatePath(index)}>{item}</a>
|
||||||
</React.Fragment>
|
)}
|
||||||
))}
|
</React.Fragment>
|
||||||
</div>
|
))
|
||||||
|
}
|
||||||
|
</div >
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -90,6 +90,14 @@ body.light {
|
|||||||
width: 65%;
|
width: 65%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.breadcrumbs a {
|
||||||
|
text-decoration: none;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Core variables and mixins
|
// Core variables and mixins
|
||||||
// @import "variables";
|
// @import "variables";
|
||||||
// @import "mixins";
|
// @import "mixins";
|
||||||
Loading…
x
Reference in New Issue
Block a user