Skip to content

Commit 9079910

Browse files
committed
2 parents cc1f087 + 068fc42 commit 9079910

File tree

5 files changed

+76
-1
lines changed

5 files changed

+76
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Compiled pages are published at [https://cp-algorithms.com/](https://cp-algorith
1616

1717
## Changelog
1818

19+
- August, 2025: Overhaul of CP-Algorithms [donation system](https://github.com/sponsors/cp-algorithms). Please consider supporting us, so that we can grow!
1920
- August, 2025: Launched a [Discord server](https://discord.gg/HZ5AecN3KX)!
2021
- October, 2024: Welcome new maintainers: [jxu](https://github.com/jxu), [mhayter](https://github.com/mhayter) and [kostero](https://github.com/kostero)!
2122
- October, 15, 2024: GitHub pages based mirror is now served at [https://gh.cp-algorithms.com/](https://gh.cp-algorithms.com/), and an auxiliary competitive programming library is available at [https://lib.cp-algorithms.com/](https://lib.cp-algorithms.com/).

mkdocs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ edit_uri: edit/main/src/
3131
copyright: Text is available under the <a href="https://github.com/cp-algorithms/cp-algorithms/blob/main/LICENSE">Creative Commons Attribution Share Alike 4.0 International</a> License<br/>Copyright &copy; 2014 - 2025 by <a href="https://github.com/cp-algorithms/cp-algorithms/graphs/contributors">cp-algorithms contributors</a>
3232
extra_javascript:
3333
- javascript/config.js
34+
- javascript/donation-banner.js
3435
- https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?features=es6
3536
- https://unpkg.com/mathjax@3/es5/tex-mml-chtml.js
3637
extra_css:
@@ -84,6 +85,8 @@ extra:
8485
link: https://github.com/cp-algorithms/cp-algorithms
8586
- icon: fontawesome/brands/discord
8687
link: https://discord.gg/HZ5AecN3KX
88+
- icon: fontawesome/solid/circle-dollar-to-slot
89+
link: https://github.com/sponsors/cp-algorithms
8790
analytics:
8891
provider: google
8992
property: G-7FLS2HCYHH

src/javascript/donation-banner.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
document.addEventListener("DOMContentLoaded", () => {
2+
const STORAGE_KEY = "donationBannerHiddenUntil";
3+
const HIDE_DAYS = 90;
4+
5+
const hiddenUntil = Number(localStorage.getItem(STORAGE_KEY) || 0);
6+
if (Date.now() < hiddenUntil) return;
7+
8+
const banner = document.createElement("aside");
9+
banner.id = "donation-banner";
10+
banner.innerHTML = `
11+
<div class="donation-banner">
12+
<p class="donation-text">
13+
<strong>Please consider
14+
<a class="donation-link" href="https://github.com/sponsors/cp-algorithms">
15+
supporting us</a>
16+
</strong> — ad-free, volunteer-run.
17+
</p>
18+
<button class="donation-close" type="button" aria-label="Dismiss">×</button>
19+
</div>
20+
`;
21+
22+
const content = document.querySelector("div.md-content") || document.body;
23+
content.insertBefore(banner, content.firstChild);
24+
25+
banner.querySelector(".donation-close").addEventListener("click", () => {
26+
banner.remove();
27+
const until = Date.now() + HIDE_DAYS * 24 * 60 * 60 * 1000;
28+
localStorage.setItem(STORAGE_KEY, String(until));
29+
});
30+
});

src/overrides/partials/header.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@
9999
{% include ".icons/fontawesome/brands/discord.svg" %}
100100
</a>
101101
</div>
102+
103+
<div class="md-header__option">
104+
<a href="https://github.com/sponsors/cp-algorithms" title="GitHub Sponsors" class="md-header__button md-icon" aria-label="GitHub Sponsors">
105+
{% include ".icons/fontawesome/solid/circle-dollar-to-slot.svg" %}
106+
</a>
107+
</div>
102108
</nav>
103109
{% if "navigation.tabs.sticky" in features %}
104110
{% if "navigation.tabs" in features %}

src/stylesheets/extra.css

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,39 @@ body[dir=rtl] .metadata.page-metadata .contributors-text{
5454

5555
.arithmatex{
5656
overflow-y: hidden !important;
57-
}
57+
}
58+
59+
/* Donation banner */
60+
#donation-banner {
61+
margin: 0.75rem 0.75rem 0;
62+
}
63+
64+
.donation-banner {
65+
display: flex;
66+
67+
background: #fff9c4;
68+
border: 1px solid #f0e68c;
69+
color: #2b2b2b;
70+
71+
padding: 0.5rem 0.5rem;
72+
border-radius: 8px;
73+
font-size: 0.75rem;
74+
}
75+
76+
.donation-text { margin: 0; }
77+
.donation-link {
78+
color: revert;
79+
text-decoration: underline;
80+
}
81+
82+
.donation-close {
83+
margin-left: auto;
84+
font-size: 1rem;
85+
cursor: pointer;
86+
}
87+
88+
[data-md-color-scheme="slate"] .donation-banner {
89+
background: #3b3200;
90+
border-color: #665c1e;
91+
color: #fff7b3;
92+
}

0 commit comments

Comments
 (0)