Skip to content

Commit

Permalink
feat: allow customize social network with partial template.
Browse files Browse the repository at this point in the history
  • Loading branch information
lepture committed Jun 1, 2024
1 parent e0bcc7d commit 1fc3cca
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 34 deletions.
27 changes: 27 additions & 0 deletions docs/customisation/social.rst
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,30 @@ The Reddit icon will be displayed only on the footer.
html_theme_options = {
"reddit_url": "https://www.reddit.com/r/flask/"
}
LinkedIn
~~~~~~~~

The LinkedIn icon will be displayed only on the footer.

.. code-block:: python
html_theme_options = {
"linkedin_url": "https://www.linkedin.com/company/microsoft"
}
Custom networks
---------------

If you need to add social networks that Shibuya theme doesn't contain, you can
custom it with ``partials/foot-socials.html``:

.. code-block:: html
:caption: _templates/partials/foot-socials.html

<div class="sy-foot-socials">
{%- include "components/foot-socials.html" -%}
<a href="your-social-network-url" aria-label="Your Social network">
<svg>...</svg>
</a>
</div>
62 changes: 30 additions & 32 deletions src/shibuya/theme/shibuya/components/foot-socials.html
Original file line number Diff line number Diff line change
@@ -1,32 +1,30 @@
<div class="sy-foot-socials">
{%- if theme_readthedocs_url %}
<a href="{{ theme_readthedocs_url }}" aria-label="Readthedocs"><i class="i-simpleicons readthedocs"></i></a>
{%- endif %}
{%- if theme_github_url %}
<a href="{{ theme_github_url }}" aria-label="GitHub"><i class="i-simpleicons github"></i></a>
{%- endif %}
{%- if theme_gitlab_url %}
<a href="{{ theme_gitlab_url }}" aria-label="Gitlab"><i class="i-simpleicons gitlab"></i></a>
{%- endif %}
{%- if theme_bitbucket_url %}
<a href="{{ theme_bitbucket_url }}" aria-label="Bitbucket"><i class="i-simpleicons bitbucket"></i></a>
{%- endif %}
{%- if theme_twitter_url %}
<a href="{{ theme_twitter_url }}" aria-label="X (Twitter)"><i class="i-simpleicons x-twitter"></i></a>
{%- endif %}
{%- if theme_mastodon_url %}
<a href="{{ theme_mastodon_url }}" aria-label="Mastodon"><i class="i-simpleicons mastodon"></i></a>
{%- endif %}
{%- if theme_discord_url %}
<a href="{{ theme_discord_url }}" aria-label="Discord"><i class="i-simpleicons discord"></i></a>
{%- endif %}
{%- if theme_youtube_url %}
<a href="{{ theme_youtube_url }}" aria-label="YouTube"><i class="i-simpleicons youtube"></i></a>
{%- endif %}
{%- if theme_reddit_url %}
<a href="{{ theme_reddit_url }}" aria-label="Reddit"><i class="i-simpleicons reddit"></i></a>
{%- endif %}
{%- if theme_linkedin_url %}
<a href="{{ theme_linkedin_url }}" aria-label="LinkedIn"><i class="i-simpleicons linkedin"></i></a>
{%- endif %}
</div>
{%- if theme_readthedocs_url %}
<a href="{{ theme_readthedocs_url }}" aria-label="Readthedocs"><i class="i-simpleicons readthedocs"></i></a>
{%- endif %}
{%- if theme_github_url %}
<a href="{{ theme_github_url }}" aria-label="GitHub"><i class="i-simpleicons github"></i></a>
{%- endif %}
{%- if theme_gitlab_url %}
<a href="{{ theme_gitlab_url }}" aria-label="Gitlab"><i class="i-simpleicons gitlab"></i></a>
{%- endif %}
{%- if theme_bitbucket_url %}
<a href="{{ theme_bitbucket_url }}" aria-label="Bitbucket"><i class="i-simpleicons bitbucket"></i></a>
{%- endif %}
{%- if theme_twitter_url %}
<a href="{{ theme_twitter_url }}" aria-label="X (Twitter)"><i class="i-simpleicons x-twitter"></i></a>
{%- endif %}
{%- if theme_mastodon_url %}
<a href="{{ theme_mastodon_url }}" aria-label="Mastodon"><i class="i-simpleicons mastodon"></i></a>
{%- endif %}
{%- if theme_discord_url %}
<a href="{{ theme_discord_url }}" aria-label="Discord"><i class="i-simpleicons discord"></i></a>
{%- endif %}
{%- if theme_youtube_url %}
<a href="{{ theme_youtube_url }}" aria-label="YouTube"><i class="i-simpleicons youtube"></i></a>
{%- endif %}
{%- if theme_reddit_url %}
<a href="{{ theme_reddit_url }}" aria-label="Reddit"><i class="i-simpleicons reddit"></i></a>
{%- endif %}
{%- if theme_linkedin_url %}
<a href="{{ theme_linkedin_url }}" aria-label="LinkedIn"><i class="i-simpleicons linkedin"></i></a>
{%- endif %}
3 changes: 3 additions & 0 deletions src/shibuya/theme/shibuya/partials/foot-socials.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div class="sy-foot-socials">
{%- include "components/foot-socials.html" -%}
</div>
2 changes: 1 addition & 1 deletion src/shibuya/theme/shibuya/partials/site-foot.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="sy-foot-inner sy-container mx-auto">
<div class="sy-foot-reserved md:flex justify-between items-center">
{% include "components/foot-copyright.html" %}
{% include "components/foot-socials.html" %}
{% include "partials/foot-socials.html" %}
</div>
</div>
</footer>
2 changes: 1 addition & 1 deletion src/shibuya/theme/shibuya/theme.conf
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ discord_url =
mastodon_url =
youtube_url =
reddit_url =
readthedocs_url =
linkedin_url =
readthedocs_url =

# open graph and twitter card
og_image_url =
Expand Down
6 changes: 6 additions & 0 deletions static/css/layout/foot.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,9 @@
.sy-foot-socials a + a {
margin-left: 0.5rem;
}

.sy-foot-socials a svg {
display: inline-block;
width: 1.4rem;
height: 1.4rem;
}

0 comments on commit 1fc3cca

Please sign in to comment.