Skip to content

Commit

Permalink
feat: add keywords to movie/series detail pages (#3204)
Browse files Browse the repository at this point in the history
  • Loading branch information
sct committed Jan 4, 2023
1 parent edf5010 commit e084649
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 1 deletion.
2 changes: 1 addition & 1 deletion server/api/themoviedb/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ class TheMovieDb extends ExternalAPI {
params: {
language,
append_to_response:
'credits,external_ids,videos,release_dates,watch/providers',
'credits,external_ids,videos,keywords,release_dates,watch/providers',
},
},
43200
Expand Down
3 changes: 3 additions & 0 deletions server/api/themoviedb/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ export interface TmdbMovieDetails {
id: number;
results?: { [iso_3166_1: string]: TmdbWatchProviders };
};
keywords: {
keywords: TmdbKeyword[];
};
}

export interface TmdbVideo {
Expand Down
6 changes: 6 additions & 0 deletions server/models/Movie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type {
Crew,
ExternalIds,
Genre,
Keyword,
ProductionCompany,
WatchProviders,
} from './common';
Expand Down Expand Up @@ -83,6 +84,7 @@ export interface MovieDetails {
externalIds: ExternalIds;
plexUrl?: string;
watchProviders?: WatchProviders[];
keywords: Keyword[];
}

export const mapProductionCompany = (
Expand Down Expand Up @@ -142,4 +144,8 @@ export const mapMovieDetails = (
externalIds: mapExternalIds(movie.external_ids),
mediaInfo: media,
watchProviders: mapWatchProviders(movie['watch/providers']?.results ?? {}),
keywords: movie.keywords.keywords.map((keyword) => ({
id: keyword.id,
name: keyword.name,
})),
});
16 changes: 16 additions & 0 deletions src/components/Common/Tag/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { TagIcon } from '@heroicons/react/24/outline';

type TagProps = {
content: string;
};

const Tag = ({ content }: TagProps) => {
return (
<div className="inline-flex cursor-pointer items-center rounded-full bg-gray-800 px-2 py-1 text-sm text-gray-200 ring-1 ring-gray-600 transition hover:bg-gray-700">
<TagIcon className="mr-1 h-4 w-4" />
<span>{content}</span>
</div>
);
};

export default Tag;
15 changes: 15 additions & 0 deletions src/components/MovieDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import LoadingSpinner from '@app/components/Common/LoadingSpinner';
import PageTitle from '@app/components/Common/PageTitle';
import type { PlayButtonLink } from '@app/components/Common/PlayButton';
import PlayButton from '@app/components/Common/PlayButton';
import Tag from '@app/components/Common/Tag';
import Tooltip from '@app/components/Common/Tooltip';
import ExternalLinkBlock from '@app/components/ExternalLinkBlock';
import IssueModal from '@app/components/IssueModal';
Expand Down Expand Up @@ -453,6 +454,20 @@ const MovieDetails = ({ movie }: MovieDetailsProps) => {
</div>
</>
)}
{data.keywords.length > 0 && (
<div className="mt-6">
{data.keywords.map((keyword) => (
<Link
href={`/discover/movies/keyword?keywords=${keyword.id}`}
key={`keyword-id-${keyword.id}`}
>
<a className="mb-2 mr-2 inline-flex last:mr-0">
<Tag content={keyword.name} />
</a>
</Link>
))}
</div>
)}
</div>
<div className="media-overview-right">
{data.collection && (
Expand Down
15 changes: 15 additions & 0 deletions src/components/TvDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import PageTitle from '@app/components/Common/PageTitle';
import type { PlayButtonLink } from '@app/components/Common/PlayButton';
import PlayButton from '@app/components/Common/PlayButton';
import StatusBadgeMini from '@app/components/Common/StatusBadgeMini';
import Tag from '@app/components/Common/Tag';
import Tooltip from '@app/components/Common/Tooltip';
import ExternalLinkBlock from '@app/components/ExternalLinkBlock';
import IssueModal from '@app/components/IssueModal';
Expand Down Expand Up @@ -482,6 +483,20 @@ const TvDetails = ({ tv }: TvDetailsProps) => {
</div>
</>
)}
{data.keywords.length > 0 && (
<div className="mt-6">
{data.keywords.map((keyword) => (
<Link
href={`/discover/movies/keyword?keywords=${keyword.id}`}
key={`keyword-id-${keyword.id}`}
>
<a className="mb-2 mr-2 inline-flex last:mr-0">
<Tag content={keyword.name} />
</a>
</Link>
))}
</div>
)}
<h2 className="py-4">{intl.formatMessage(messages.seasonstitle)}</h2>
<div className="flex w-full flex-col space-y-2">
{data.seasons
Expand Down

0 comments on commit e084649

Please sign in to comment.