Skip to content

Commit

Permalink
Add missing trailing slashes to links and URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
decimoseptimo committed Feb 12, 2021
1 parent 71f2a06 commit 15ecd8f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ exports.createPages = async ({ graphql, actions, reporter }) => {

products.forEach(({ node }) => {
createPage({
path: node.slug,
path: node.slug + '/',
component: productView,
context: {
// Data passed to context is available
Expand Down Expand Up @@ -124,7 +124,7 @@ exports.createPages = async ({ graphql, actions, reporter }) => {
allSubcategoriesIds,
productsCount: products.length,
},
pathPrefix: `/${slugify(i.name.toLowerCase())}`,
pathPrefix: `/${slugify(i.name.toLowerCase())}/`,
})
}

Expand All @@ -137,7 +137,7 @@ exports.createPages = async ({ graphql, actions, reporter }) => {
context: {
tag: tag.fieldValue,
},
pathPrefix: `/tags/${slugify(tag.fieldValue.toLowerCase())}`,
pathPrefix: `/tags/${slugify(tag.fieldValue.toLowerCase())}/`,
})
})
}
2 changes: 1 addition & 1 deletion src/components/breadcrumbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const Breadcrumbs = ({ data }) => (
</span>
{data.map((i) => (
<span className="item" key={i._id}>
<Link to={`/${slugify(i.name.toLowerCase())}`}>{i.name}</Link>
<Link to={`/${slugify(i.name.toLowerCase())}/`}>{i.name}</Link>
</span>
))}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/sidepanel/panels/categories.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const Categories = () => {

const ItemLink = ({ name, className='' }) => (
<Link
to={`/${slugify(name.toLowerCase())}`}
to={`/${slugify(name.toLowerCase())}/`}
replace
className={className}
activeClassName="active"
Expand Down
10 changes: 5 additions & 5 deletions src/templates/categoryView.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ const CategoryView = (props) => {
const subcategories2 = (
<div className="subcategories">
{subcategories.map((i) => (
<SubcategoryLink to={`/${slugify(i.name.toLowerCase())}`} key={i._id}>
<SubcategoryLink to={`/${slugify(i.name.toLowerCase())}/`} key={i._id}>
{i.name}
</SubcategoryLink>
))}
</div>
)

const handlePageChange = (e, d) => {
d.activePage === 1
? navigate(`/${slugify(category.name.toLowerCase())}`)
: navigate(`/${slugify(category.name.toLowerCase())}/${d.activePage}`)
const handlePageChange = (page) => {
page === 1
? navigate(`/${slugify(category.name.toLowerCase())}/`)
: navigate(`/${slugify(category.name.toLowerCase())}/${page}/`)
}

return (
Expand Down
2 changes: 1 addition & 1 deletion src/templates/productIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const ProductIndex = (props) => {
const products = props.data.allProductsJson.edges

const handlePageChange = (page) => {
page === 1 ? navigate(`/`) : navigate(`/${page}`)
page === 1 ? navigate(`/`) : navigate(`/${page}/`)
}

return (
Expand Down

0 comments on commit 15ecd8f

Please sign in to comment.