-
Notifications
You must be signed in to change notification settings - Fork 982
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
Community award badge and meta descriptions #4567
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
socialLinks, | ||
communityAward | ||
} = frontMatter | ||
|
||
return ( | ||
<SpotlightWrapper isSpotlightMember={isSpotlightMember} frontMatter={frontMatter}> | ||
// Get meta description text | ||
const metaDescription = stripHtml(description) | ||
|
||
return ( | ||
<SpotlightWrapper | ||
isSpotlightMember={isSpotlightMember} | ||
frontMatter={frontMatter} | ||
> | ||
{isSpotlightMember && metaDescription ? ( | ||
<Head> | ||
<meta | ||
name="description" | ||
content={metaDescription} | ||
/> | ||
<meta | ||
property="og:description" | ||
content={metaDescription} | ||
/> | ||
</Head> | ||
) : null} | ||
{communityAward ? ( | ||
<div className={styles.awardBadge}> | ||
<span>Community Award Recipient</span> | ||
</div> | ||
) : null} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lot of formatting changes here from editing the file, this was the main section updated.
// Strip HTML for meta description | ||
function stripHtml(desc) { | ||
const maxLength = 130 | ||
|
||
if(!desc) return null | ||
|
||
// Remove HTML elements from string | ||
const strippedHtml = desc?.replace(/(<([^>]+)>)/gi, "") | ||
|
||
// Strip new lines and return 130 character substring for description | ||
const updatedDesc = strippedHtml | ||
?.substring(0, maxLength) | ||
?.replace(/(\r\n|\r|\n)/g, ""); | ||
|
||
return desc?.length > maxLength ? `${updatedDesc}...` : updatedDesc | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the 2nd edit adding a new function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
Confirmed award badge shows on page and confirmed meta descriptions are showing when sharing links for individual members.
What are you changing in this pull request and why?
Currently on the live site, the meta descriptions for individual spotlight member pages pull from the
description
field in the frontmatter as-is, causing the meta descriptions to be long and have HTML within it:This adjusts the meta descriptions for spotlight member pages, to strip HTML from the meta descriptions and set a max length of 130 characters.
This also adds frontmatter field
communityAward
to add an award badge above spotlight member cards. This field is aboolean
which can be set in individual spotlight member files.Preview
View the award badges for the top two spotlight members on the index page:
https://docs-getdbt-com-git-community-award-badge-dbt-labs.vercel.app/community/spotlight/
Verify meta
description
andog:description
fields are set for individual spotlight member pages. You can also paste these in a message to yourself in Slack to see the social card:https://docs-getdbt-com-git-community-award-badge-dbt-labs.vercel.app/community/spotlight/karen-hsieh
https://docs-getdbt-com-git-community-award-badge-dbt-labs.vercel.app/community/spotlight/josh-devlin
https://docs-getdbt-com-git-community-award-badge-dbt-labs.vercel.app/community/spotlight/alan-cruickshank
https://docs-getdbt-com-git-community-award-badge-dbt-labs.vercel.app/community/spotlight/emily-riederer
Checklist
communityAward
field from two spotlight member files used for an example in this PR