@@ -523,3 +523,75 @@ def test_folder_note_not_duplicate_child(self):
523523 assert "Fairshore" not in child_labels
524524 assert "The Salty Dog" in child_labels
525525 assert "Market Square" in child_labels
526+
527+
528+ class TestUnlistedPages :
529+ """Test that unlisted frontmatter hides pages from nav."""
530+
531+ def test_unlisted_page_hidden_from_nav (self ):
532+ pages = [
533+ make_page ("about" , "About" ),
534+ Page (
535+ source_path = Path ("/vault/secret.md" ),
536+ slug = "secret" ,
537+ frontmatter = {"title" : "Secret" , "unlisted" : True },
538+ content = "" ,
539+ ),
540+ ]
541+ tree = build_nav_tree (pages )
542+ labels = [c .label for c in tree .children ]
543+ assert "About" in labels
544+ assert "Secret" not in labels
545+
546+ def test_unlisted_page_folder_still_shown (self ):
547+ pages = [
548+ Page (
549+ source_path = Path ("/vault/docs/hidden.md" ),
550+ slug = "docs/hidden" ,
551+ frontmatter = {"title" : "Hidden" , "unlisted" : True },
552+ content = "" ,
553+ ),
554+ make_page ("docs/visible" , "Visible" ),
555+ ]
556+ tree = build_nav_tree (pages )
557+ docs = tree .children [0 ]
558+ assert docs .is_folder
559+ child_labels = [c .label for c in docs .children ]
560+ assert "Visible" in child_labels
561+ assert "Hidden" not in child_labels
562+
563+ def test_unlisted_false_still_shown (self ):
564+ pages = [
565+ Page (
566+ source_path = Path ("/vault/page.md" ),
567+ slug = "page" ,
568+ frontmatter = {"title" : "Page" , "unlisted" : False },
569+ content = "" ,
570+ ),
571+ ]
572+ tree = build_nav_tree (pages )
573+ labels = [c .label for c in tree .children ]
574+ assert "Page" in labels
575+
576+ def test_unlisted_folder_hidden_from_nav (self ):
577+ """Folder with unlisted index page should not appear in nav."""
578+ pages = [
579+ Page (
580+ source_path = Path ("/vault/secret/index.md" ),
581+ slug = "secret/index" ,
582+ frontmatter = {"title" : "Secret" , "unlisted" : True },
583+ content = "" ,
584+ ),
585+ Page (
586+ source_path = Path ("/vault/secret/details.md" ),
587+ slug = "secret/details" ,
588+ frontmatter = {"title" : "Details" },
589+ content = "" ,
590+ ),
591+ make_page ("public" , "Public" ),
592+ ]
593+ tree = build_nav_tree (pages )
594+ labels = [c .label for c in tree .children ]
595+ assert "Public" in labels
596+ assert "secret" not in [c .label .lower () for c in tree .children ]
597+ assert "Details" not in labels
0 commit comments