Skip to content

Commit

Permalink
Destructuring
Browse files Browse the repository at this point in the history
  • Loading branch information
espen42 committed Aug 3, 2021
1 parent 0bdc28e commit 919d5c8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions next/src/components/templates/movie.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,15 @@ type MoviePageProps = {
};


const getPageTitle = (pageContext: MoviePageContext) => {
const node = pageContext.node;
const getPageTitle = ( {node, title}:MoviePageContext ) => {

// @ts-ignore
if (!!node && pageContext.title && (node[pageContext.title] || node.data[pageContext.title])) {
// @ts-ignore
return node[pageContext.title] || node.data[pageContext.title];
}

return pageContext.title || 'Person';
return title || 'Person';
};


Expand Down
5 changes: 2 additions & 3 deletions next/src/components/templates/person.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,15 @@ type PersonPageProps = {
pageContext: PersonPageContext
}

const getPageTitle = (pageContext: PersonPageContext) => {
const node = pageContext.node;
const getPageTitle = ( {node, title}:PersonPageContext ) => {

// @ts-ignore
if (!!node && pageContext.title && (node[pageContext.title] || node.data[pageContext.title])) {
// @ts-ignore
return node[pageContext.title] || node.data[pageContext.title];
}

return pageContext.title || 'Person';
return title || 'Person';
};

const PersonPage = ({pageContext}: PersonPageProps) => {
Expand Down

0 comments on commit 919d5c8

Please sign in to comment.