serve a declared slug as an address, leaving the key alone
The human chose the second option: a route sits beside the key rather than replacing it. So `slug` renames what a bundle is served at, in every language, and identity stays derived from the path — which is exactly what keeps ADR-0033 intact, since series membership is the directory. A series landing page can now be renamed without orphaning its chapters, and there is a test that says so. `Site` resolves routes at index time, because only it can see whether every variant agrees. Disagreement is dropped rather than resolved, as is a slug landing where another bundle already answers — the same rule colliding keys and contested aliases already follow. The key a slug moved away from stops answering, so the old address does not quietly keep working. Two bugs surfaced doing this, both older than this change: An alias naming its own bundle's former key was rejected as "an alias that names a real bundle" — which made rename-plus-alias, the entire point of ADR-0008's alias mechanism, impossible. The check now asks what a request asks: is anything actually served there. Aliases were counted per declaring *file*, so a bundle whose two language variants both listed the same alias looked like two rival claimants and lost the alias. It is a set of keys now. This one only appears with translated content, which is why no fixture had caught it since entry 4 — the real binary did, on the first multilingual rename.
This commit is contained in:
@@ -299,14 +299,14 @@ func (r *Renderer) Bundle(b content.Bundle, served string, variants []string, se
|
||||
title = b.Key
|
||||
}
|
||||
p := Page{
|
||||
head: r.head(title, served, content.URL(b.Key, served)),
|
||||
head: r.head(title, served, content.URL(b.Route, served)),
|
||||
Key: b.Key,
|
||||
HTML: template.HTML(body.String()),
|
||||
Extra: b.Extra,
|
||||
Sequence: r.sequence(seq, served),
|
||||
}
|
||||
for _, l := range variants {
|
||||
p.Alternates = append(p.Alternates, Alternate{Lang: l, URL: r.absolute(content.URL(b.Key, l))})
|
||||
p.Alternates = append(p.Alternates, Alternate{Lang: l, URL: r.absolute(content.URL(b.Route, l))})
|
||||
}
|
||||
return r.execute(r.page, p, b.Key)
|
||||
}
|
||||
@@ -352,7 +352,7 @@ func (r *Renderer) sequence(seq *content.Sequence, lang string) *Sequence {
|
||||
}
|
||||
out := &Sequence{
|
||||
Title: seq.Series.Title,
|
||||
URL: content.URL(seq.Series.Key, lang),
|
||||
URL: content.URL(seq.Series.Route, lang),
|
||||
Index: seq.Index,
|
||||
Count: len(seq.Members),
|
||||
}
|
||||
@@ -374,7 +374,7 @@ func (r *Renderer) sequence(seq *content.Sequence, lang string) *Sequence {
|
||||
|
||||
// item is one listing entry.
|
||||
func (r *Renderer) item(b content.Bundle, lang string) Item {
|
||||
return Item{Title: b.Title, Key: b.Key, URL: content.URL(b.Key, lang), Date: b.Date}
|
||||
return Item{Title: b.Title, Key: b.Key, URL: content.URL(b.Route, lang), Date: b.Date}
|
||||
}
|
||||
|
||||
// paginate builds the shell of a listing page and returns the slice of entries it shows.
|
||||
|
||||
Reference in New Issue
Block a user