|
59 | 59 | "notes/systemd.html": "notes/tools/systemd.html", |
60 | 60 | } |
61 | 61 |
|
| 62 | +# Pages that lived at nested paths but were renamed or removed in the |
| 63 | +# Jan 2026 cleanup (e.g. /notes/cpp/cpp_constructor.html merged into |
| 64 | +# cpp_basic.html, the /notes/cmake/ section collapsed into cpp_cmake.html, |
| 65 | +# the /notes/appendix/ section migrated to /notes/rust/). Google still has |
| 66 | +# many of these indexed -- mapping them avoids 404s and lets the index |
| 67 | +# converge on the surviving canonical pages. |
| 68 | +_LEGACY_NESTED_REDIRECTS = { |
| 69 | + "notes/c/asm_basic.html": "notes/c/asm.html", |
| 70 | + "notes/c/c_gnuext.html": "notes/c/c_macro.html", |
| 71 | + "notes/debug/gdb_debug.html": "notes/debug/gdb.html", |
| 72 | + "notes/os/os_concurrency.html": "notes/os/os_thread.html", |
| 73 | + "notes/cmake/cmake_basic.html": "notes/cpp/cpp_cmake.html", |
| 74 | + "notes/cmake/cmake_external.html": "notes/cpp/cpp_cmake.html", |
| 75 | + "notes/cmake/cmake_package.html": "notes/cpp/cpp_cmake.html", |
| 76 | + "notes/cmake/index.html": "notes/cpp/cpp_cmake.html", |
| 77 | + "notes/cpp/cpp_constructor.html": "notes/cpp/cpp_basic.html", |
| 78 | + "notes/cpp/cpp_forwarding.html": "notes/cpp/cpp_move.html", |
| 79 | + "notes/cpp/cpp_initialization.html": "notes/cpp/cpp_raii.html", |
| 80 | + "notes/cpp/cpp_ranges.html": "notes/cpp/cpp_iterator.html", |
| 81 | + "notes/cpp/cpp_variadic.html": "notes/cpp/cpp_template.html", |
| 82 | + "notes/tools/bash_date.html": "notes/tools/bash.html", |
| 83 | + "notes/tools/bash_find.html": "notes/tools/bash.html", |
| 84 | + "notes/tools/bash_os.html": "notes/tools/bash.html", |
| 85 | + "notes/tools/bash_re.html": "notes/tools/bash.html", |
| 86 | + "notes/bash/index.html": "notes/tools/bash.html", |
| 87 | + "notes/appendix/index.html": "notes/rust/index.html", |
| 88 | + "notes/appendix/rust_from_cpp.html": "notes/rust/index.html", |
| 89 | +} |
| 90 | + |
62 | 91 | _LEGACY_FLAT_PATTERN = re.compile( |
63 | 92 | r"^notes/(cpp|c|cuda|rust)_([a-z0-9_]+)\.html$" |
64 | 93 | ) |
65 | 94 |
|
66 | 95 |
|
67 | 96 | def _resolve_legacy_flat_target(path): |
68 | | - """Return the nested URL for a known legacy flat path, or None.""" |
69 | | - explicit = _LEGACY_FLAT_REDIRECTS.get(path) |
| 97 | + """Return the canonical URL for a known legacy path, or None.""" |
| 98 | + explicit = ( |
| 99 | + _LEGACY_FLAT_REDIRECTS.get(path) |
| 100 | + or _LEGACY_NESTED_REDIRECTS.get(path) |
| 101 | + ) |
70 | 102 | if explicit: |
71 | 103 | return explicit |
72 | 104 | match = _LEGACY_FLAT_PATTERN.match(path) |
|
0 commit comments