Skip to content

Commit

Permalink
feat(homepage): add id in each cards
Browse files Browse the repository at this point in the history
  • Loading branch information
ben196888 committed Oct 19, 2023
1 parent 9112cea commit 2718084
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions homepage/src/components/cards.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const Cards = ({ id, title, cards }) => {
</div>
<div className="row">
{cards.map((card) => (
<Card key={card.data.title} card={card} />
<Card key={card.data.id} card={card} />
))}
</div>
</div>
Expand All @@ -18,7 +18,7 @@ const Cards = ({ id, title, cards }) => {
};

const Card = ({ card }) => (
<div className="col-md-4 mb-3">
<div className="col-md-4 mb-3" id={card.data.id}>
<div className="section-main">
<h3>{card.data.title}</h3>
<div>
Expand Down
2 changes: 2 additions & 0 deletions homepage/src/pages/cards.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { fetchPage } from '../lib/fetchPage';
import { fetchCards } from '../lib/fetchCards';
import { getNavigationList } from '../lib/getNavigationList';
import { componentMapper } from '../lib/componentMapper';
import { titleToAnchorId } from '../lib/titleToAnchorId';

/**
*
Expand All @@ -20,6 +21,7 @@ export const getStaticProps = async ({ locale }) => {
image = !image.startsWith('/') ? `/${image}` : image;

data.image = image;
data.id = data.id || titleToAnchorId(data.title);

return {
data,
Expand Down

0 comments on commit 2718084

Please sign in to comment.