Skip to content

Commit 4b8f613

Browse files
committed
Fix book being overwritten by redirect, again
1 parent 35dc1b5 commit 4b8f613

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and [Pydantic's HISTORY.md](https://github.com/pydantic/pydantic/blob/main/HISTORY.md), and this project *mostly* adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## `1!0.1.0a35`
8+
9+
### Fixed
10+
11+
* Fixed another issue with the web book being overwritten by a redirect page if the plugin version is removed from the site path.
12+
713
## `1!0.1.0a34`
814

915
### Added

src/hexdoc/cli/app.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from hexdoc.core import ModResourceLoader, ResourceLocation
1919
from hexdoc.data.metadata import HexdocMetadata
2020
from hexdoc.data.sitemap import (
21+
SitemapMarker,
2122
delete_updated_books,
2223
dump_sitemap,
2324
load_sitemap,
@@ -356,14 +357,17 @@ def merge(
356357
root_version: Version | None = None
357358
root_redirect: str | None = None
358359

360+
def add_redirect(marker: SitemapMarker, path: Path):
361+
if path != Path(marker.path.removeprefix("/")):
362+
redirects[path] = marker.redirect_contents
363+
359364
for version, item in sitemap.items():
360365
if version.startswith("latest"): # TODO: check type of item instead
361366
continue
362367

363-
redirects[plugin.site_root / version] = item.default_marker.redirect_contents
364-
if plugin.site_root / version != plugin.versioned_site_path: # hacky hacky
365-
for lang, marker in item.markers.items():
366-
redirects[plugin.site_root / version / lang] = marker.redirect_contents
368+
add_redirect(item.default_marker, plugin.site_root / version)
369+
for lang, marker in item.markers.items():
370+
add_redirect(marker, plugin.site_root / version / lang)
367371

368372
item_version = Version(version)
369373
if not root_version or item_version > root_version:

0 commit comments

Comments
 (0)