Skip to content

Only show users from the Fortune 500 on the home page #707

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

Merged
merged 2 commits into from
Dec 8, 2020
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
6 changes: 3 additions & 3 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = {
darkImage: '/img/users/codecademy.svg',
lightImage: '/img/users/codecademy.svg',
infoLink: 'https://www.codecademy.com',
pinned: true,
pinned: false,
},
{
caption: 'Expedia Group',
Expand Down Expand Up @@ -71,7 +71,7 @@ module.exports = {
darkImage: '/img/users/gusto.svg',
lightImage: '/img/users/gusto.svg',
infoLink: 'https://gusto.com/',
pinned: true,
pinned: false,
},
{
caption: 'Habitaclia',
Expand Down Expand Up @@ -180,10 +180,10 @@ module.exports = {
},
{
caption: 'Walmart Labs',
pinned: true,
darkImage: '/img/users/walmart.png',
lightImage: '/img/users/walmart.png',
infoLink: 'https://www.walmartlabs.com/',
pinned: true,
},
{
caption: 'Wix.com',
Expand Down
41 changes: 11 additions & 30 deletions src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@ import { Container } from '../components/Container'
import { Showcase } from '../components/Showcase'
import Layout from '@theme/Layout'

const HomeSplash = props => {
const HomeSplash = (props) => {
const { language = '' } = props
const { siteConfig } = useDocusaurusContext()
const { baseUrl, customFields } = siteConfig
const docsPart = `${customFields.docsPath ? `${customFields.docsPath}/` : ''}`
const langPart = `${language ? `${language}/` : ''}`
const docUrl = doc => `${baseUrl}${docsPart}${langPart}${doc}`
const docUrl = (doc) => `${baseUrl}${docsPart}${langPart}${doc}`

const SplashContainer = props => (
const SplashContainer = (props) => (
<div className="homeContainer">
<div className="homeSplashFade">
<div className="wrapper homeWrapper">{props.children}</div>
</div>
</div>
)

const Logo = props => (
const Logo = (props) => (
<div className="projectLogo">
<img src={props.img_src} alt="Project Logo" />
</div>
Expand All @@ -43,7 +43,7 @@ const HomeSplash = props => {
</div>
)

const Button = props => (
const Button = (props) => (
<div className="pluginWrapper buttonWrapper">
<a
className="button button--primary button--outline"
Expand Down Expand Up @@ -71,7 +71,7 @@ export default class Index extends React.Component {
const { config: siteConfig, language = '' } = this.props
const { baseUrl } = siteConfig

const Block = props => (
const Block = (props) => (
<Container
padding={['bottom', 'top']}
id={props.id}
Expand Down Expand Up @@ -241,36 +241,17 @@ export default class Index extends React.Component {
if ((siteConfig.customFields.users || []).length === 0) {
return null
}
const NUMBER_OF_UNPINNED_USERS_TO_SHOWCASE = 3

const randomizedList = (arr, n) => {
var result = new Array(n),
len = arr.length,
taken = new Array(len)
if (n > len) return arr
while (n--) {
var x = Math.floor(Math.random() * len)
result[n] = arr[x in taken ? taken[x] : x]
taken[x] = --len in taken ? taken[len] : len
}
return result
}

const userShowcase = [
...siteConfig.customFields.users.filter(u => u.pinned),
...randomizedList(
siteConfig.customFields.users.filter(u => !u.pinned),
NUMBER_OF_UNPINNED_USERS_TO_SHOWCASE
),
]

const pageUrl = page => baseUrl + (language ? `${language}/` : '') + page
const pageUrl = (page) =>
baseUrl + (language ? `${language}/` : '') + page

return (
<div className="productShowcaseSection paddingBottom paddingTop">
<h2>Who is Using This?</h2>
<div className="logos">
<Showcase users={userShowcase} />
<Showcase
users={siteConfig.customFields.users.filter((u) => u.pinned)}
/>
</div>
<a
className="button button--primary button--outline"
Expand Down