Skip to content

Commit

Permalink
fix: 🐛 Tags and Topics page generating (#11)
Browse files Browse the repository at this point in the history
## Status
**READY**

## Description
- Fix Tags and Topics pages generating.

The reason is `topic` and `tag` keys are plural in other places but it
is singular in JSON data `lookups`.

## Follow-up
- `lookups` dict keys should also be plural in JSON data.
  • Loading branch information
goztrk committed Dec 14, 2023
1 parent 020e84d commit b003664
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pages/tags/[slug].jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { TopicsTagsPage } from '@components/topics_tags';

export const getStaticPaths = staticPathFactory('tags');

export const getStaticProps = categoryStaticPropsFactory('tags');
export const getStaticProps = categoryStaticPropsFactory('tags', 'tag');

export default function Page({ entry, videoIds }) {
return <TopicsTagsPage title="Tag" entry={entry} videoIds={videoIds} />;
Expand Down
2 changes: 1 addition & 1 deletion pages/topics/[slug].jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { TopicsTagsPage } from '@components/topics_tags';

export const getStaticPaths = staticPathFactory('topics');

export const getStaticProps = categoryStaticPropsFactory('topics');
export const getStaticProps = categoryStaticPropsFactory('topics', 'topic');

export default function Page({ entry, videoIds }) {
return <TopicsTagsPage title="Topic" entry={entry} videoIds={videoIds} />;
Expand Down
4 changes: 2 additions & 2 deletions utils/static.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ export function staticPathFactory(key) {
});
}

export function categoryStaticPropsFactory(category) {
export function categoryStaticPropsFactory(category, lookup) {
return async ({ params: { slug } }) => {
const entry = NAMES_BY_SLUG[category][slug];

return entry ? {
props: {
entry,
videoIds: THEOLOGY101_DATA.lookups[category][entry] || [],
videoIds: THEOLOGY101_DATA.lookups[lookup][entry] || [],
},
} : { notFound: true };
};
Expand Down

0 comments on commit b003664

Please sign in to comment.