Skip to content

Commit

Permalink
add startups logos to outdated posts slide
Browse files Browse the repository at this point in the history
  • Loading branch information
gary-van-woerkens committed Oct 12, 2023
1 parent 1286e5c commit e4806a0
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 19 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_module
node_modules
.env.local
.next
.secrets.yaml
out
.vscode
7 changes: 7 additions & 0 deletions src/styles/extra.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@
font-size: 1.5em;
}
}

img[alt="other-startup-logo"] {
top: 20px;
max-width: 64px;
position: relative;
display: inline-block;
}
47 changes: 29 additions & 18 deletions src/utils/slides.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,43 @@ const isRecentSlide = (slide) =>
new Date(new Date(slide.created_at).getTime() + 30 * 24 * 60 * 60 * 1000) >=
new Date()

const filterPosts = (posts) =>
posts.reduce(
(result, slide) => {
result[isRecentSlide(slide) ? "recentPosts" : "outdatedPosts"].push(slide)
return result
},
{ outdatedPosts: [], recentPosts: [] }
)

const addOutdatedPostsSlideToExtraSlides = (posts) =>
extraSlides.unshift({
markdown: shuffle(posts)
.map(
(post) =>
`### ![other-startup-logo](${post.team?.avatarUrl}) ${post.team?.name}`
)
.join("\n"),
title: "Les autres startups",
})

const fetcher = async (query) => {
const { posts } = await request(url, query)
const visibleStartups =
const visiblePosts =
posts &&
posts.filter(
(slide) =>
slide.team &&
slide.created_at &&
!slide.team.parentTeam &&
slide.team.privacy === "VISIBLE" &&
slide.created_at
slide.team.privacy === "VISIBLE"
)
const filteredPosts = visibleStartups.filter((slide) => isRecentSlide(slide))
const hiddenPosts = visibleStartups.filter((slide) => !isRecentSlide(slide))
const slides = (filteredPosts && shuffle(filteredPosts)) || []
if (hiddenPosts.length) {
const markdown =
shuffle(hiddenPosts)
.map((post) => `### ${post.team?.name}`)
.join("\n") +
"\n\n![](https://media.giphy.com/media/d8oI97avlJAygnp7RC/giphy.gif)"
slides.push({
markdown,
title: "Elles nous manquent 😿",
})
}
slides.push(...extraSlides)
const { recentPosts, outdatedPosts } = filterPosts(visiblePosts)

addOutdatedPostsSlideToExtraSlides(outdatedPosts)

const slides = recentPosts && [...shuffle(recentPosts), ...extraSlides]

return Promise.resolve(slides)
}

Expand Down

0 comments on commit e4806a0

Please sign in to comment.