[pull] master from changkun:master#53
Open
pull[bot] wants to merge 20 commits into
Open
Conversation
Replace the stacked Chinese+English heroes on the root page with a single hero plus a 中文/English toggle. The language is auto-detected from the browser on first visit and remembered in localStorage; the non-active language is hidden by default to avoid a flash of both.
The why-first rewrite of Chapter 2 added a second structured-binding example — binding key/value pairs while iterating a std::map. Extend the companion file so the downloadable code matches what the book now shows. This was the only code block that changed across the whole book since the companion code was last synced (f148826).
The book was rebranded from C++11/14/17/20 to 'C++11 to C++26', but the site title, header, hero, and meta description still showed the old range. Bring them in line with the book and the site _config.
Remove dead and obsolete front-end cruft: - Drop pivot.js loaded from cdn.rawgit.com (shut down in 2019; the hero shine effect silently 404'd on the live site). - Remove FastClick (the 300ms tap delay it patched is gone from modern mobile browsers). - Remove the Universal Analytics gtag snippet (UA properties stopped collecting data in July 2023). - Delete vestigial #highlights and .social-buttons CSS that no layout references, and the fixed-footer spacing hacks (margin-bottom: 200px). - Make the homepage footer normal-flow instead of position: fixed so it no longer overlaps content. - Fix the logo font stack to list only fonts actually loaded (Dosis was referenced but never linked, so it silently fell back). - Upgrade protocol-relative font CDN link to https.
Bump hexo 5.4.0 -> 8.1.2 and all renderer/generator plugins (and serve) to their latest majors, then regenerate package-lock.json. Local 'npm audit' now reports 0 vulnerabilities, down from the 46 open Dependabot alerts (all in this build-time dependency tree -- none of it ships to readers). The GitHub Dependabot alerts should auto-close once this lands on master and is rescanned. Two fixes were needed to keep the site building under the new toolchain: - Quote the title in book/en-us/09-others.md. Hexo 8's stricter js-yaml rejects the unquoted 'Chapter 09: Minor Features' (the second colon parses as a nested mapping); every other chapter title was already quoted. - Set marked.prependRoot: false. hexo-renderer-marked 6+ prepends the site root to relative image paths by default, turning the book's ../../assets/figures/*.png into a broken /../../assets/... path. This restores the original relative paths. Verified locally (Node 25): full build succeeds with no errors, all 32 chapter pages plus homepage/about render, syntax highlighting and image captions intact, no broken image paths in the output. NOT yet verified in CI -- see the build-env image note in the following commit.
The CI deploy runs inside the prebuilt changkun/modern-cpp-tutorial:build-env
image. Per the Docker Hub API that image was last pushed 2019-07-15 and
never updated -- built from node:latest, which was Node 12 at the time.
Hexo 8 requires Node >= 20.19, so that stale image cannot run the
upgraded toolchain; pushing the Hexo 8 upgrade without rebuilding it will
break the deploy at 'hexo generate'.
Pin to a concrete current LTS so the rebuild is deterministic and won't
silently drift again. NOTE: this Dockerfile change is untested -- the
image still dpkg-installs a 2019 pandoc 2.7.3 .deb and texlive-full, and
CI's make target builds pdf+epub as well as the site, so a rebuild needs
a one-off test ('make build-env' then a full 'make') before relying on
it to deploy.
The landing page rendered both Chinese and English heroes into one HTML document and toggled between them with client-side JS. Mirror the single-language model the book pages and the reference sites already use: index.ejs now renders one hero/footer chosen by page.type, the switcher is a plain link, and a dedicated English landing lives at /modern-cpp/en/. Also fix stale shell copy: <html lang> was hardcoded to en on every page (now follows page.type), the README purpose lines said C++ 'before 2020s' (now C++11 through C++26), and _config.yml description was the author name.
The <title> was a fixed Chinese-led bilingual string on every page; branch it on page.type so the English landing announces itself in English. Add text-decoration:none to the anchor switcher so it renders as the button it replaced rather than an underlined link.
Clears the 3 open Dependabot alerts, all transitive through hexo-renderer-marked: dompurify 3.4.8 -> 3.4.11 (Trusted Types policy and ALLOWED_ATTR pollution advisories) and form-data 4.0.5 -> 4.0.6 (CRLF injection via multipart field names). Lockfile-only; build and markdown rendering verified unchanged.
The pipeline shelled out to a hand-maintained 3.4 GB texlive build-env image on Docker Hub (last rebuilt 2019, Node ~2019). The Jun-7 Hexo 8 / chokidar 4 upgrade needs Node >= 20.19, so that stale container failed at 'Cannot find module fs/promises'. Replace it with a native, Docker-free workflow: checkout@v4 + setup-node@v4 (Node 22, npm cache), npm ci, build the Hexo site, and deploy over SSH with the existing SERVER_* secrets. The website needs only Node and Python 3, so no texlive is required. PDF/epub are no longer rebuilt in CI; the copies on the server are left untouched (scp overwrites, never deletes) so their download links keep working.
Make the site behave like a real bilingual site at the entry point. A non-Chinese browser (or anyone whose remembered choice is English) hitting the root now lands on the English page instead of a wall of Chinese; an explicit 'zh' choice is honored and never bounced. The redirect runs as the first thing in <head>, before the non-async vue script, so it is not blocked on a download. Landing switchers write the choice to localStorage so the auto-route respects it. Also inline the landing flag's size so it can never depend on a cached stylesheet rule (the cause of the giant-flag render after the button->anchor change shipped while old CSS was still cached).
The About pages (Donate/Copyright/Acknowledgements) always rendered with Chinese chrome regardless of the reader's language, and Acknowledgements stacked English on top of Chinese. An English reader reached them from the English menu and got a Chinese page. Introduce an 'about-en' page type (the theme's 'type' field selects both menu language and which section's table-of-contents to list, so a separate type is the clean way to split). Route the shared partials -- header, page, sidebar, layout -- through a single isEn = book-en-us || about-en helper. Add English About pages under /about/en/, point the English menu and the English book footer at them, and reduce each Chinese About page to Chinese only. donate.md becomes a committed source file (was generated from assets/, which stays bilingual for the GitHub README), so it drops out of the Makefile copy/clean and .gitignore.
The header language menu always linked to the other language's preface, so switching language from chapter 7 or an About page dumped you at the preface. Map to the equivalent page instead: swap the zh-cn<->en-us segment for book chapters, /about/<->/about/en/ for About pages, and fall back to the other language's landing for anything else. Drop target=_blank so the switch happens in place, and record the choice in localStorage so the root auto-route honors it.
The sidebar section heading matched only book-zh-cn, so English chapters fell through to the raw-type fallback and showed 'Book-en-us'. Match book-en-us too so it reads 'Main', mirroring the Chinese '正文'.
The landing showed two language switches: the hero #lang-switch button and the header nav language dropdown (used on every other page). Remove the redundant hero button and its now-dead CSS; the nav dropdown is the single switcher, and it already records the choice in localStorage for the root auto-route.
The <head> was minimal and not multilingual-aware. Add, per page and per language: a self-referential canonical; rel=alternate hreflang zh-CN/en/ x-default linking each page to its translation (computed with the same zh-cn<->en-us / about<->about/en logic the visible switcher uses); Open Graph + Twitter Card tags with og:locale/og:locale:alternate; a per-language meta description (was one mixed-language string site-wide). Replace the 1.6 MB cover-PNG favicon with a real 32x32 favicon + 180x180 apple-touch-icon (the book mascot). Drop maximum-scale/user-scalable from viewport (a WCAG 1.4.4 pinch-zoom failure).
… assets Remove three dead theme _config keys (google_analytics, root_domain, moderncpp_version — none referenced anywhere). Strip the unmatched trailing </a> from both book footers. Add alt text to the hero cover and header logo images. Remove the commented-out Code/Exercises/Answers nav block (Answers was never built). Delete vestigial assets: lang/de.svg (no German edition) and the unused check/down/feed/search PNGs.
src/_posts/index.md exists only to drive hexo-generator-index (the homepage), but Hexo also rendered it as a dated post at /2026/06/21/index/ — unlinked, empty, indexable junk. Pin that post to a fixed permalink and strip it after generate in the Makefile, keeping the homepage intact.
filter.py rewrote cross-chapter links with the loose regex (./)(.*?)(.md), whose unescaped dots matched any ':/ … md' span — so a chapter line with an external URL like '#cmdoption-…' got corrupted into 'https..//…' on the built site. Anchor the rewrite to the ](./NN-name.md) link syntax with a simple filename so external URLs are never touched; chapter cross-links and #anchors still resolve. Also repoint the preface Code/Exercises links at the GitHub tree (they were relative dir links that 404 on the static site — no directory index — and the English one had an 'exercise' typo); GitHub URLs work on the site, on GitHub, and in the PDF.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )