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

feat(www): Add Community Plugin Badge #21847

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 42 additions & 29 deletions www/src/components/package-readme.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,51 @@ import MarkdownPageFooter from "./markdown-page-footer"
import FooterLinks from "./shared/footer-links"
import { GoMarkGithub as GithubIcon } from "react-icons/go"
import GatsbyIcon from "./gatsby-monogram"
import { FaUsers as CommunityIcon } from "react-icons/fa"

const GatsbyPluginBadge = ({ isOfficial }) => {
const Icon = isOfficial ? GatsbyIcon : CommunityIcon
const title = isOfficial
? "Official Gatsby Plugin"
: "Community Gatsby Plugin"
const text = isOfficial ? `Official Plugin` : `Community Plugin`

return (
<div
sx={{
variant: `links.muted`,
mr: 8,
"&&": {
border: 0,
color: `textMuted`,
display: `flex`,
fontWeight: `body`,
},
"&&:hover": {
color: `textMuted`,
},
}}
>
<span
sx={{
display: `inline-block`,
mr: 2,
}}
title={title}
>
<Icon />
</span>
{text}
</div>
)
}

const PackageReadMe = props => {
const { page, packageName, excerpt, html, githubUrl, timeToRead } = props
const metaExcerpt = excerpt || `Plugin information for ${packageName}`
const isOfficial =
githubUrl.indexOf(`https://github.com/gatsbyjs/gatsby`) === 0 &&
packageName[0] !== `@`

return (
<React.Fragment>
Expand Down Expand Up @@ -45,35 +86,7 @@ const PackageReadMe = props => {
justifyContent: `space-between`,
}}
>
{githubUrl.indexOf(`https://github.com/gatsbyjs/gatsby`) === 0 &&
packageName[0] !== `@` && (
<div
sx={{
variant: `links.muted`,
mr: 8,
"&&": {
border: 0,
color: `textMuted`,
display: `flex`,
fontWeight: `body`,
},
"&&:hover": {
color: `textMuted`,
},
}}
>
<span
sx={{
display: `inline-block`,
mr: 2,
}}
title={`Official Gatsby Plugin`}
>
<GatsbyIcon />
</span>
Official Plugin
</div>
)}
<GatsbyPluginBadge isOfficial={isOfficial} />
<a
sx={{ variant: `links.muted` }}
href={githubUrl}
Expand Down
19 changes: 12 additions & 7 deletions www/src/components/plugin-searchbar-body.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { visuallyHidden } from "../utils/styles"
import { Global, css } from "@emotion/core"
import removeMD from "remove-markdown"
import SkipNavLink from "./skip-nav-link"
import { FaUsers as CommunityIcon } from "react-icons/fa"

// This is for the urlSync
const updateAfter = 700
Expand Down Expand Up @@ -407,13 +408,17 @@ const Result = ({ hit, pathname, query }) => {
}}
>
{hit.repository &&
hit.name[0] !== `@` &&
hit.repository.url.indexOf(`https://github.com/gatsbyjs/gatsby`) ===
0 && (
<span sx={{ mr: 1 }} alt={`Official Gatsby Plugin`}>
<GatsbyIcon />
</span>
)}
hit.name[0] !== `@` &&
hit.repository.url.indexOf(`https://github.com/gatsbyjs/gatsby`) ===
0 ? (
<span sx={{ mr: 1 }} alt={`Official Gatsby Plugin`}>
<GatsbyIcon />
</span>
) : (
<span sx={{ mr: 1 }} alt={`Community Gatsby Plugin`}>
<CommunityIcon />
</span>
)}
<span
css={{
width: `5em`,
Expand Down