Tagger på innlegg med tagg-sider
Kommaseparert tagg-felt i editoren, lagret som liste i frontmatter (dedup case-ufølsomt). /tag/<slug>/ lister alle innlegg med taggen, også gjesters; /tag/ lister alle tagger med antall. Tagger vises som piller på innlegg og i lister, som <category> i feeden og i sitemap. «tag» er reservert som slug/brukernavn. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JcEy43fNYpwg6K6oTKakWR
This commit is contained in:
parent
259465342b
commit
f0fcb875c5
11 changed files with 109 additions and 6 deletions
|
|
@ -339,3 +339,34 @@ def test_signature_from_profile(client, cfg):
|
|||
).status_code
|
||||
== 200
|
||||
)
|
||||
|
||||
|
||||
def test_tags(client, cfg):
|
||||
login(client)
|
||||
token = csrf(client)
|
||||
|
||||
def publish(title, tags):
|
||||
r = client.post("/admin/new", data={"csrf": token})
|
||||
pid = r.headers["Location"].split("/admin/edit/")[1]
|
||||
client.post(
|
||||
f"/admin/edit/{pid}",
|
||||
data={"csrf": token, "title": title, "body": "x", "tags": tags, "action": "publish"},
|
||||
)
|
||||
|
||||
publish("En", "Friluftsliv, skog ,skog, Skog")
|
||||
publish("To", "friluftsliv")
|
||||
publish("Tre", "")
|
||||
md = (cfg.content_dir / "posts/en/index.md").read_text()
|
||||
assert 'tags: ["Friluftsliv", "skog"]' in md # dedup, case-ufølsomt, trimmet
|
||||
assert "tags:" not in (cfg.content_dir / "posts/tre/index.md").read_text()
|
||||
|
||||
assert 'href="../tag/friluftsliv/"' in client.get("/en/").text
|
||||
page = client.get("/tag/friluftsliv/").text
|
||||
assert "tagg: friluftsliv" in page.lower() and ">En<" in page and ">To<" in page and ">Tre<" not in page
|
||||
assert client.get("/tag/skog/").status_code == 200
|
||||
assert client.get("/tag/").status_code == 200 and "(2)" in client.get("/tag/").text
|
||||
assert "<category>skog</category>" in client.get("/feed.xml").text
|
||||
assert "https://blog.example.no/tag/friluftsliv/" in client.get("/sitemap.xml").text
|
||||
# "tag" er reservert som slug
|
||||
publish("tag", "")
|
||||
assert not (cfg.content_dir / "posts/tag").exists()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue