From nobody Fri May 22 12:00:11 2026 X-Original-To: dev-commits-doc-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4gMP3h41fHz6fZKc for ; Fri, 22 May 2026 12:00:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gMP3h3S5xz40Fh for ; Fri, 22 May 2026 12:00:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1779451216; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=n/VmKywxejCEVddWEqeL8MbYxrXey4qeIv0i6iOke6Y=; b=A4e0Jb2cwHDU0TrfWDpAJQlYeqP2jUAuKEqNAbKLv0dJsTpQGqHnEiomS7hv1P+pt6gEA3 8TfMiFBgUXfxQaMG0wfyOlwdzKshG0GLmh33Mxvwn7PmNdCjfLYznQm7bNavgVdfGBaZeV ZEqUfLCVKPnq9NY76Xs161SMusMK7b7JxYN18RdL8CvmoWUBLZ+PAtYVs+Q7X6yCZOQEfq xrW1lxzaoV8i3ilWnZqf5/rXpBahLXwywUFQuOqFBONpmd6DN0cK4E+jorqOYI9jbk2xxu 3J76mOiVD5SgObTAFyAH6ATk4qgWB1PjF6y6KogZMvNb+W60rrnKG8Hbw5EGkw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1779451216; a=rsa-sha256; cv=none; b=pT6TARFVm18dk+d0A1oUBZoxAm1G1tzD4Kf8wFSrHJ8JcH9Yihbzp8IPEDK8rK+sR4VJLD rq8MZclVTnopip9wzMcaHBXMikaknZ8p+Djb3WmxCVQSIHqgawTud7vfkAG+OF11hK1KnK sox65bgJIxE7+FeLbQbIDJ3qHXxzrPgqa3qxbbxcGjDSg6BBWdwOhakYfhqHJDygZ4OClk 7bXXlVXXb46JDf/jlYwq9J4cSIn8vx8CffwUoVnqkZsK4IFOiqnz7EzgTWESjzUAEJ4dbu TG28Zr3Kkkys2GulgUdxntnU3NEfUU9kHoLR4w9jiFDmtNa8paeiAOj6psuViA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1779451216; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=n/VmKywxejCEVddWEqeL8MbYxrXey4qeIv0i6iOke6Y=; b=wVhpM8PNUjCMS0+JlpT1wCvFlwzXo7oEaqdPUMYH8zSf9CHmn9PRAEj/EL3g+ITnUNSv1Z n31KKnEJRfxSiD0Ekr2q6jQsbFrbkxSvlh7a3tZdYF2+hNydMJoirIbFaV/1CXf4r4xjEu 5+YKBQIiqX7xfJndQpe0p29aEzbMN8q0lPyh3DRNZ2fs2r26ELeaQFhRlHKqUTMGKCli65 UgKCa93F1TgTaG73G0gsn2eFfnBdTsDUp3RJNho6vnFOs+GdHILvp5A7d8/VUkRC8vA/lu zSL/k0wLo7EMZVU/7C+BIS7nBeezyxDa3v59DcLnFTZfCetSDvh3sRamG37TPg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gMP3h2v6pz3rm for ; Fri, 22 May 2026 12:00:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 31e3d by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 22 May 2026 12:00:11 +0000 To: doc-committers@FreeBSD.org, dev-commits-doc-all@FreeBSD.org From: Vladlen Popolitov Subject: git: a23bfd024c - main - website: fix light-dark themes switch List-Id: Commit messages for all branches of the doc repository List-Archive: https://lists.freebsd.org/archives/dev-commits-doc-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-doc-all@freebsd.org Sender: owner-dev-commits-doc-all@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: vladlen X-Git-Repository: doc X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a23bfd024cc0d33c3a89f7b152c7ca01ed895906 Auto-Submitted: auto-generated Date: Fri, 22 May 2026 12:00:11 +0000 Message-Id: <6a10454b.31e3d.28fc3d87@gitrepo.freebsd.org> The branch main has been updated by vladlen: URL: https://cgit.FreeBSD.org/doc/commit/?id=a23bfd024cc0d33c3a89f7b152c7ca01ed895906 commit a23bfd024cc0d33c3a89f7b152c7ca01ed895906 Author: Vladlen Popolitov AuthorDate: 2026-05-22 12:00:02 +0000 Commit: Vladlen Popolitov CommitDate: 2026-05-22 12:00:02 +0000 website: fix light-dark themes switch Reviewed by: carlavilla, ziaee Approved by: carlavilla Differential Revision: https://reviews.freebsd.org/D57057 PR: 295341 --- website/themes/beastie/assets/js/theme-chooser.js | 47 ++++++++++++++++++++++ .../beastie/layouts/_partials/site-head.html | 3 ++ 2 files changed, 50 insertions(+) diff --git a/website/themes/beastie/assets/js/theme-chooser.js b/website/themes/beastie/assets/js/theme-chooser.js new file mode 100644 index 0000000000..0bdd3dc23a --- /dev/null +++ b/website/themes/beastie/assets/js/theme-chooser.js @@ -0,0 +1,47 @@ +/* +BSD 2-Clause License + +Copyright (c) 1994-2026, The FreeBSD Documentation Project +Copyright (c) 2026, Vladlen Popolitov +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +// FreeBSD light/dark theme persists +;(function() { + const toggle = document.getElementById('theme-switch'); + if (!toggle) return; + + // restore saved state + const saved = localStorage.getItem('theme-preference'); + if (saved === 'dark') { + toggle.checked = true; + } else if (saved === 'light') { + toggle.checked = false; + } + // if state was no saved - use current state (CSS uses prefers-color-scheme) + // save state, when theme switched to or from dark + toggle.addEventListener('change', function() { + localStorage.setItem('theme-preference', this.checked ? 'dark' : 'light'); + }); +})(); diff --git a/website/themes/beastie/layouts/_partials/site-head.html b/website/themes/beastie/layouts/_partials/site-head.html index ceafa1006f..5aa6a86463 100644 --- a/website/themes/beastie/layouts/_partials/site-head.html +++ b/website/themes/beastie/layouts/_partials/site-head.html @@ -44,6 +44,9 @@ + {{- $themeChooser := resources.Get "js/theme-chooser.js" | resources.Minify }} + + {{- if hugo.IsServer -}} {{- printf "" | safeHTML }} {{- else -}}