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

Community award badge and meta descriptions #4567

Merged
merged 5 commits into from
Dec 4, 2023
Merged

Conversation

JKarlavige
Copy link
Collaborator

@JKarlavige JKarlavige commented Dec 1, 2023

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:
image

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 a boolean 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 and og: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

  • Remove communityAward field from two spotlight member files used for an example in this PR

@JKarlavige JKarlavige requested a review from a team as a code owner December 1, 2023 15:53
@github-actions github-actions bot added content Improvements or additions to content size: medium This change will take up to a week to address and removed content Improvements or additions to content labels Dec 1, 2023
Copy link

vercel bot commented Dec 1, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs-getdbt-com ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 4, 2023 2:37pm

Comment on lines +51 to +79
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}
Copy link
Collaborator Author

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.

Comment on lines +208 to +223
// 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
}
Copy link
Collaborator Author

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

@JKarlavige JKarlavige requested review from a team, breezyfasano and john-rock and removed request for a team December 1, 2023 16:07
Copy link
Contributor

@john-rock john-rock left a 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.

@john-rock john-rock merged commit 75ba438 into current Dec 4, 2023
7 checks passed
@john-rock john-rock deleted the community-award-badge branch December 4, 2023 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: medium This change will take up to a week to address
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants