feat: Render titles for social sharing and improve home page sharing #263
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description 📖
This pull request improves social sharing for all Vitepress websites by rendering
og:title
andtwitter:title
meta tags based on the individual page title.These meta tags are only added if they weren't already provided by the user.
Notes ✏️
Home |
is intentionally avoided as the website title looks nicer on its own when sharing a website.This is only changed in the rendered HTML, the dynamic title will still include
Home |
, as it looks fine when a user is already on the site.Background 📜
Since the title is different for every page, rendering these meta tags would require adding a Vue component, that duplicates the logic in
render.ts
to obtain the full title.By rendering these tags using the title, sharing a specific page in a tweet or similar social websites will display a card with the correct title.