Skip to content

Commit

Permalink
update movie description and title
Browse files Browse the repository at this point in the history
  • Loading branch information
Asing1001 committed Oct 30, 2023
1 parent f53f84a commit 7659099
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/app/components/movieDetailTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,12 @@ export default class MovieDetailTabs extends React.PureComponent<any, MovieDetai
return <PageNotFound />;
}
const movie = classifyArticle(matchedMovie);
document.title = `${movie.chineseTitle} ${movie.englishTitle} | Movie Rater | 電影評分 | PTT | IMDB | YAHOO`;
const { chineseTitle, englishTitle, posterUrl } = movie;

document.title = `${chineseTitle} ${englishTitle} | Movie Rater | 電影評分 | PTT | IMDb | LINE電影`;
document['meta'] = {
image: movie.posterUrl,
description: `IMDb:${movie.imdbRating}, Yahoo:${movie.yahooRating}, PTT好雷/普雷/負雷:${movie.goodRateArticles.length}/${movie.normalRateArticles.length}/${movie.badRateArticles.length}`,
image: posterUrl,
description: generateMovieDescription(movie),
};
return (
<Paper zDepth={2}>
Expand All @@ -141,3 +143,16 @@ export default class MovieDetailTabs extends React.PureComponent<any, MovieDetai
);
}
}

function generateMovieDescription(movie: Movie) {
const { imdbRating, lineRating, yahooRating, goodRateArticles, normalRateArticles, badRateArticles } = movie;
const ratings = [];

if (imdbRating) ratings.push(`IMDb:${imdbRating}`);
if (lineRating) ratings.push(`LINE電影:${lineRating}`);
if (yahooRating) ratings.push(`Yahoo:${yahooRating}`);

return `${ratings.join(', ')}${ratings.length ? ', ' : ''}PTT好雷/普雷/負雷:${goodRateArticles.length}/${
normalRateArticles.length
}/${badRateArticles.length}`;
}

0 comments on commit 7659099

Please sign in to comment.