Skip to content

Commit

Permalink
Add lang attribute to preview card (mastodon#23869)
Browse files Browse the repository at this point in the history
  • Loading branch information
c960657 authored and skerit committed Jul 7, 2023
1 parent 0f10634 commit c5a0a21
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/javascript/mastodon/features/status/components/card.jsx
Expand Up @@ -196,11 +196,12 @@ export default class Card extends React.PureComponent {
const interactive = card.get('type') !== 'link';
const className = classnames('status-card', { horizontal, compact, interactive });
const title = interactive ? <a className='status-card__title' href={card.get('url')} title={card.get('title')} rel='noopener noreferrer' target='_blank'><strong>{card.get('title')}</strong></a> : <strong className='status-card__title' title={card.get('title')}>{card.get('title')}</strong>;
const language = card.get('language') || '';
const ratio = card.get('width') / card.get('height');
const height = (compact && !embedded) ? (width / (16 / 9)) : (width / ratio);

const description = (
<div className='status-card__content'>
<div className='status-card__content' lang={language}>
{title}
{!(horizontal || compact) && <p className='status-card__description'>{trim(card.get('description') || '', maxDescription)}</p>}
<span className='status-card__host'>{provider}</span>
Expand Down
2 changes: 1 addition & 1 deletion app/serializers/rest/preview_card_serializer.rb
Expand Up @@ -3,7 +3,7 @@
class REST::PreviewCardSerializer < ActiveModel::Serializer
include RoutingHelper

attributes :url, :title, :description, :type,
attributes :url, :title, :description, :language, :type,
:author_name, :author_url, :provider_name,
:provider_url, :html, :width, :height,
:image, :embed_url, :blurhash
Expand Down

0 comments on commit c5a0a21

Please sign in to comment.