Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support customized meta tags for Twitter Card #5160

Open
2 tasks done
p1slave opened this issue Feb 16, 2023 · 1 comment
Open
2 tasks done

Support customized meta tags for Twitter Card #5160

p1slave opened this issue Feb 16, 2023 · 1 comment

Comments

@p1slave
Copy link

p1slave commented Feb 16, 2023

Check List

Please check followings before submitting a new feature request.

  • I have already read Docs page
  • I have already searched existing issues

Feature Request

It would be great to support customized meta tags for Twitter Card based on the content on each post so that when you tweet the blog link, the preview of text, images, or even videos will show up in the timeline rather than a suspicious link that no one is interested in opening it. Here is the link to the docs of Twitter Card.

Are there any existing plugins that can handle it? I'm not really familiar with the whole Hexo plugin system and may try to write a plugin myself but I think it would be beneficial to everyone if Hexo official team can support this feature!

@stevenjoezhang
Copy link
Member

We could use post excerpt as twitter:description in open_graph helper.

Source code:

result += meta('twitter:card', twitterCard);
if (options.twitter_image) {
let twitter_image = options.twitter_image;
twitter_image = new URL(twitter_image, url || config.url);
result += meta('twitter:image', twitter_image, false);
} else if (images.length) {
result += meta('twitter:image', images[0], false);
}
if (options.twitter_id) {
let twitterId = options.twitter_id;
if (!twitterId.startsWith('@')) twitterId = `@${twitterId}`;
result += meta('twitter:creator', twitterId);
}
if (options.twitter_site) {
result += meta('twitter:site', options.twitter_site, false);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants