Skip to content

Commit

Permalink
feat: add buysellads extension
Browse files Browse the repository at this point in the history
  • Loading branch information
lepture committed Aug 21, 2024
1 parent 0023376 commit 4ec47b0
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 16 deletions.
1 change: 1 addition & 0 deletions docs/_templates/partials/page-bottom.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% include "extensions/buysellads.html" %}
3 changes: 3 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@
"source_type": "github",
"source_user": "lepture",
"source_repo": "shibuya",
"buysellads_code": "CE7DKK3M",
"buysellads_placement": "shibuya",
"buysellads_container_selector": ".yue > section > section",
}


Expand Down
28 changes: 23 additions & 5 deletions src/shibuya/theme/shibuya/extensions/buysellads.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,40 @@
<div class="bsa"></div>
{% if buysellads_container_selector %}
<script>
(function() {
const el = document.querySelector('{{ buysellads_container_selector }}');
if (el) {
const target = document.createElement('div');
target.id = 'bsa-custom-container';
el.appendChild(target);
}
})();
</script>
{% endif %}
<div id="bsa-container"></div>
<script src="//m.servedby-buysellads.com/monetization.custom.js"></script>
<script>
(function() {
if (typeof _bsa !== 'undefined' && _bsa) {
let target = '#bsa-container';
if (document.querySelector('#bsa-custom-container')) {
target = '#bsa-custom-container';
}
_bsa.init('custom', '{{ buysellads_code }}', 'placement:{{ buysellads_placement }}', {
target: '.bsa',
id: 'bsa-bar',
target: target,
template: `
<a class="bsa-bar" style="background-color: ##backgroundColor##; color: ##textColor##" href="##link##" rel="sponsored noopener" target="_blank" title="##company## — ##tagline##">
<div class="bsa">
<a class="bsa-container bsa__##external_id##" style="background-color: ##backgroundColor##; color: ##textColor##" href="##link##" rel="sponsored noopener" target="_blank" title="##company## — ##tagline##">
<div class="bsa-main">
<img class="bsa-img" src="##logo##">
<div class="bsa-details" style="color: ##textColor##">
<span class="bsa-tagline">Sponsored by ##company##</span>
<span class="bsa-tagline">##company## — ##tagline##</span>
<span class="bsa-desc">##description##</span>
</div>
<span class="bsa-cta" style="color: ##ctaTextColor##; background-color: ##ctaBackgroundColor##;">##callToAction##</span>
</div>
</a>
<div class="bsa-ad-via"><a title="ad via BuySellAds" href="##ad_via_link##">Ads via BuySellAds</a></div>
</div>
`
});
}
Expand Down
32 changes: 29 additions & 3 deletions static/css/components/external.css
Original file line number Diff line number Diff line change
Expand Up @@ -109,19 +109,41 @@
}

/* buysellads */
.bsa-bar {
.bsa {
margin: 1rem 0;
}

.bsa a {
text-decoration: none;
border-bottom: none;
}

.bsa-container {
display: flex;

flex-flow: row nowrap;
align-items: center;
justify-content: space-between;

padding: 15px 20px;
border-radius: 10px;
box-shadow: inset 0 0 2px hsla(0, 0%, 0%, 0.15);
border-radius: 6px;
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
text-decoration: none;
}

.bsa-ad-via {
text-align: right;
}

.bsa-ad-via a {
font-weight: 300;
font-size: 10px;
border: none;
background: var(--gray-a3);
padding: 3px 10px;
border-radius: 2px;
}

.bsa-main {
display: flex;

Expand All @@ -138,6 +160,10 @@
line-height: 0;
}

.yue a.bsa-container .bsa-img {
margin-top: 0;
margin-bottom: 0;
}

.bsa-details {
display: flex;
Expand Down
16 changes: 8 additions & 8 deletions static/css/modules.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
@import "./icons/lucide.css";
@import "./icons/simpleicons.css";

@import "./contents/yue.css";
@import "./contents/sphinx.css";
@import "./contents/admonition.css";
@import "./contents/quote.css";
@import "./contents/code.css";
@import "./contents/table.css";
@import "./contents/api-doc.css";

@import "./components/hamburger.css";
@import "./components/search.css";
@import "./components/container.css";
Expand All @@ -20,14 +28,6 @@
@import "./layout/rside.css";
@import "./layout/navigation.css";

@import "./contents/yue.css";
@import "./contents/sphinx.css";
@import "./contents/admonition.css";
@import "./contents/quote.css";
@import "./contents/code.css";
@import "./contents/table.css";
@import "./contents/api-doc.css";

@import "./extensions/rtd.css";
@import "./extensions/copybutton.css";
@import "./extensions/sphinx-design.css";
Expand Down

0 comments on commit 4ec47b0

Please sign in to comment.