Skip to content

Commit

Permalink
feat: Add contest parameter to launch and update ContestBanner logic
Browse files Browse the repository at this point in the history
  • Loading branch information
TimDaub committed Feb 10, 2025
1 parent 7199916 commit c29357b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/http.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,7 @@ export async function launch(trie, libp2p) {
DOMPurify.sanitize(request.query.domain),
identity,
hash,
request.query.contest
);
} catch (err) {
log(`Error in /: ${err.stack}`);
Expand Down
12 changes: 7 additions & 5 deletions src/views/feed.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ const formatedHolders = holders.map((a) => ethers.utils.getAddress(a));

const html = htm.bind(vhtml);

const ContestBanner = (stories) => html`
const ContestBanner = (stories, expanded = false) => html`
<div style="width: 100%; margin: 16px 0; font-family: var(--font-family);">
<div
style="border: var(--border-thin); border-right: none; border-left: none;"
>
<!-- Header -->
<div
onclick="this.nextElementSibling.style.display = this.nextElementSibling.style.display === 'none' ? 'block' : 'none'"
onclick="var c=this.nextElementSibling; if(c.style.display==='none'){ c.style.display='block'; var url=new window.URL(window.location.href); url.searchParams.set('contest','true'); window.history.replaceState({}, '', url); } else { c.style.display='none'; var url=new window.URL(window.location.href); url.searchParams.delete('contest'); window.history.pushState({}, '', url); }"
style="padding: 16px; background: #F6F6EF; cursor: pointer; display: flex; justify-content: space-between; align-items: center;"
>
<div style="display: flex; align-items: center; gap: 12px">
Expand Down Expand Up @@ -93,7 +93,7 @@ const ContestBanner = (stories) => html`
<!-- Expandable Content -->
<div
style="display: none; background: white; border-top: var(--border-thin);"
style="display: ${expanded ? 'block' : 'none'}; background: white; border-top: var(--border-thin);"
>
<!-- Key Info Grid -->
<div
Expand Down Expand Up @@ -1001,7 +1001,8 @@ function Newsletter() {
`;
}

export default async function (trie, theme, page, domain, identity, hash) {
export default async function (trie, theme, page, domain, identity, hash, contest) {
const expandedContest = contest === "true";
const mints = await registry.mints();
const path = "/";
const totalStories = parseInt(env.TOTAL_STORIES, 10);
Expand All @@ -1010,7 +1011,7 @@ export default async function (trie, theme, page, domain, identity, hash) {
if (identity || hash) {
content = await recommended(trie, page, domain, identity, hash);
} else {
content = await index(trie, page, domain);
content = await index(trie, page, domain, undefined, true, true, contest === "true");
}

const { ad, originals, stories, start, contestStories, pinnedStory } =
Expand Down Expand Up @@ -1079,6 +1080,7 @@ export default async function (trie, theme, page, domain, identity, hash) {
currentQuery,
),
),
expandedContest
)}
</td>
</tr>
Expand Down

0 comments on commit c29357b

Please sign in to comment.