diff --git a/assets/css/codeberg-docs.css b/assets/css/codeberg-docs.css index bbe2a4c..1be0280 100644 --- a/assets/css/codeberg-docs.css +++ b/assets/css/codeberg-docs.css @@ -256,3 +256,39 @@ a.show-on-focus:focus { .card-text p:last-child { margin-bottom: 0; } + +/* language dropdown */ +.lang-dropdown { + border-radius: var(--bs-border-radius); + border: 1px solid var(--bs-border-color-translucent); + padding: 4px; +} + +.lang-dropdown .dropdown-item { + border-radius: var(--bs-border-radius); + padding: 6px 12px; + font-size: 14px; +} + +.lang-dropdown .dropdown-item.active { + background-color: #0252cc; +} + +[data-bs-theme="dark"] .lang-dropdown .dropdown-item.active, +.dark-mode .lang-dropdown .dropdown-item.active { + background-color: #66a3ff; +} + +/* prevent right-overflow */ +@media (max-width: 767.98px) { + .lang-dropdown { + right: 0; + left: auto; + } +} + +/* remove right-side border radius */ +.btn-group > .dropdown:first-child > .btn { + border-top-right-radius: 0; + border-bottom-right-radius: 0; +} diff --git a/assets/js/index.js b/assets/js/index.js index a718f8a..f5718e0 100644 --- a/assets/js/index.js +++ b/assets/js/index.js @@ -23,3 +23,29 @@ function toggleSidebar() { sidebarEl.classList.add('show'); } } + +document.addEventListener('click', function (event) { + const dropdownToggle = event.target.closest('[data-bs-toggle="dropdown"]'); + if (dropdownToggle) { + event.preventDefault(); + const dropdownContainer = dropdownToggle.closest('.dropdown'); + const dropdownMenu = dropdownContainer ? dropdownContainer.querySelector('.dropdown-menu') : null; + if (dropdownMenu) { + const isExpanded = dropdownToggle.getAttribute('aria-expanded') === 'true'; + closeAllDropdowns(); + dropdownToggle.setAttribute('aria-expanded', !isExpanded ? 'true' : 'false'); + dropdownMenu.classList.toggle('show', !isExpanded); + } + } else { + closeAllDropdowns(); + } +}); + +function closeAllDropdowns() { + document.querySelectorAll('[data-bs-toggle="dropdown"]').forEach(function (toggle) { + toggle.setAttribute('aria-expanded', 'false'); + }); + document.querySelectorAll('.dropdown-menu').forEach(function (menu) { + menu.classList.remove('show'); + }); +} diff --git a/content/_data/i18n.json b/content/_data/i18n.json new file mode 100644 index 0000000..cb99566 --- /dev/null +++ b/content/_data/i18n.json @@ -0,0 +1,20 @@ +{ + "en": { + "docs": "Docs", + "toggle_dark_mode": "Toggle dark mode", + "close": "Close", + "filter_docs": "Filter docs", + "press_slash_to_focus": "Press [key] to focus", + "toggle_sidebar": "Toggle sidebar", + "view_history": "View History", + "view_source": "View Source", + "draft_notice": "Please note that this article is still a draft and might not have any contents yet.", + "copyright": "© Codeberg Docs Contributors. See [license]LICENSE[/license]", + "find_out_more": "Find out more in this section:", + "contributing_title": "Contributing", + "contributing_p1": "Hey there! 👋 Thank you for reading this article!", + "contributing_p2": "Is there something missing, or do you have an idea on how to improve the documentation? Do you want to write your own article?", + "contributing_p3": "You're invited to contribute to the Codeberg Documentation at [repo]its source code repository[/repo] for example, by [pr]adding a pull request[/pr] or joining in on the discussion in [issues]the issue tracker[/issues].", + "contributing_p4": "For an introduction on contributing to Codeberg Documentation, please have a look at [faq]the Contributor FAQ[/faq]." + } +} diff --git a/content/_data/languages.json b/content/_data/languages.json new file mode 100644 index 0000000..a259b5c --- /dev/null +++ b/content/_data/languages.json @@ -0,0 +1,3 @@ +{ + "en": "English" +} diff --git a/content/_includes/contribution_invitation.njk b/content/_includes/contribution_invitation.njk index 95557e3..69d50f4 100644 --- a/content/_includes/contribution_invitation.njk +++ b/content/_includes/contribution_invitation.njk @@ -1,20 +1,25 @@ +{% set i18nDict = i18n[lang or 'en'] %}
Hey there! 👋 Thank you for reading this article!
+{{ i18nDict.contributing_p1 }}
+{{ i18nDict.contributing_p2 }}
- Is there something missing, or do you have an idea on how to improve the documentation? - Do you want to write your own article? + {{ i18nDict.contributing_p3 | tReplace({ + "repo": '', + "/repo": '', + "pr": '', + "/pr": '', + "issues": '', + "/issues": '' + }) | safe }}
- You're invited to contribute to the Codeberg Documentation at its source code repository - for example, by adding a pull request - or joining in on the discussion in the issue tracker. -
-- For an introduction on contributing to Codeberg Documentation, please have a look - at the Contributor FAQ. + {{ i18nDict.contributing_p4 | tReplace({ + "faq": '', + "/faq": '' + }) | safe }}