-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Feature request: Support summary card (Twitter, WhatsApp, ..) #1416
Comments
I think this is a twitter specific issue. The following was quoted on Twitter dev forum - Card validator removal notice
I was not able to find a way to validate the summary card using their new api. Whatsapp also has some issues, only square images and small image sizes are supported. This SO question was last modified a month ago For validating open graph protocols: Also, I think these social medias are using cached versions of the preview, so unless the validator is functional, it's going to take a while to see changes |
I wanted to piggy back on this issue @riojosdev @gagarine Is there an handlebar to handle first image on page? I am thinking of trying to run a preprocessor to handle this but I wanted to check in with you all to make sure there isn't I am missing first. |
I see the this ticket is still open. Just to clarify, this is absolutely not an issue of Twitter or WhatsApp. In order to have summary card displayed properly, the loaded page needs to have at least some basic meta tags. For instance, in case of LinkedIn these are the Open Graph (e.g. Is there a plan to address this feature? EDIT: |
I've done some tests and I don't see a way around this limitation, without modifying the base code. These settings could be:
This might be tricky to implement because, as far as I can see, the information about the chapters are taken from the For now (for my own purpose), I included an handling of the image in the following way:
ctx.data.insert(
"file_stem".to_owned(),
json!(path.file_stem().unwrap_or(&OsStr::from("")).to_str()),
);
<meta name="image" content="{{ dir }}/{{ file_stem }}.jpeg" /> This works fine-ish, but it only resolves the issue with the image. The same approach I can follow for the description and say get the first 200 characters of the However, this is not ideal and it would be really nice if there was a way to customize the chapters providing this additional info in the chapter itself. |
I guess this should be handled with front-matter, which is YAML added to each .md file. E.g. on my GoHugo blog, I have these metadata per blog post, which would be equivalent to a referred chapter in
By adding
Better below. Does anyone know how to add a functionality to
This issue also talks about adding metadata: #2142 (comment). Ideally, we'd have a rust front-matter reader that would do the hard part. I found some mentioned them here. |
I took a first stab at reading Frontmatter with https://github.com/sspaeti/mdbook-frontmatter-reader. It works reading the frontmatter successfully, but I'm not sure how I can pass Frontmatter back to mdBook so that I can access it within tag. Maybe that must be part of mdBook and can't be a preprocessor? Any suggestion or hint is much appreciated. My results when printing some debug messages
And this would be my chapter.md:
|
Update: I created a PR that works on my side, but little hacky: #2321. Appreciate any comments or help. |
When a book page is shared on WhatsApp their is no summary card at the moment.
For twitter: https://developer.twitter.com/en/docs/twitter-for-websites/cards/overview/summary
For FB / Whatsapp : https://ogp.me
Somethings like that should works:
The text was updated successfully, but these errors were encountered: