|
2 | 2 | Example demonstrating all document navigation blocks: TOC, Anchors, and Siblings. |
3 | 3 |
|
4 | 4 | This example shows how to create a document with automatic navigation features: |
5 | | -- Table of Contents (TOC) for internal document navigation |
6 | | -- Anchors for displaying related documents and backlinks |
7 | | -- Siblings for showing documents at the same hierarchical level |
| 5 | +- Table of Contents (TOC) for internal document navigation (top) |
| 6 | +- Anchors for displaying related documents and backlinks (top) |
| 7 | +- Siblings for Previous/Next navigation between documents (bottom) |
8 | 8 | """ |
9 | 9 |
|
10 | 10 | from config import get_client |
|
31 | 31 |
|
32 | 32 | # Create document content with all navigation blocks |
33 | 33 | content = [ |
34 | | - # Automatic table of contents |
| 34 | + # Top navigation: TOC and related documents |
35 | 35 | toc_block(), |
36 | | - |
37 | | - # Related documents and backlinks |
38 | 36 | anchors_block(), |
39 | 37 |
|
40 | | - # Sibling documents navigation |
41 | | - siblings_block(), |
42 | | - |
43 | 38 | horizontal_rule(), |
44 | 39 |
|
45 | 40 | # Main content |
|
81 | 76 | "Related documents from the same space" |
82 | 77 | ), |
83 | 78 |
|
84 | | - heading(2, "Siblings Block - Same Level Documents"), |
| 79 | + heading(2, "Siblings Block - Previous/Next Navigation"), |
85 | 80 |
|
86 | 81 | paragraph( |
87 | 82 | "The ", |
88 | 83 | text("siblings_block()", code=True), |
89 | | - " shows documents at the same hierarchical level:" |
| 84 | + " provides Previous/Next navigation between documents in a sequence:" |
90 | 85 | ), |
91 | 86 |
|
92 | 87 | bullet_list( |
93 | | - "Documents in the same folder/collection", |
94 | | - "Documents at the same level in structure", |
95 | | - "Useful for series of related pages (guides, tutorials)" |
| 88 | + "Shows Previous and Next documents in the sequence", |
| 89 | + "Creates navigation buttons (Back/Forward)", |
| 90 | + "Typically placed at the bottom of the page", |
| 91 | + "Perfect for tutorial series and sequential guides" |
96 | 92 | ), |
97 | 93 |
|
98 | 94 | horizontal_rule(), |
|
119 | 115 | heading(2, "All Navigation Blocks Together"), |
120 | 116 |
|
121 | 117 | paragraph(text( |
122 | | - '''from vaiz import toc_block, anchors_block, siblings_block |
| 118 | + '''from vaiz import toc_block, anchors_block, siblings_block, horizontal_rule |
123 | 119 |
|
124 | 120 | content = [ |
| 121 | + # Top navigation |
125 | 122 | toc_block(), # Table of contents |
126 | 123 | anchors_block(), # Related documents |
127 | | - siblings_block(), # Sibling documents |
128 | 124 | |
129 | | - heading(1, "Main Content"), |
130 | | - paragraph("Your content here...") |
| 125 | + horizontal_rule(), |
| 126 | + |
| 127 | + # Your content |
| 128 | + heading(1, "Tutorial Part 2"), |
| 129 | + paragraph("Main content here..."), |
| 130 | + |
| 131 | + horizontal_rule(), |
| 132 | + |
| 133 | + # Bottom navigation |
| 134 | + siblings_block() # Previous/Next buttons |
131 | 135 | ] |
132 | 136 |
|
133 | 137 | client.replace_json_document(document_id, content)''', |
|
139 | 143 | heading(1, "Best Practices"), |
140 | 144 |
|
141 | 145 | bullet_list( |
142 | | - "Place TOC block at the document start for better accessibility", |
| 146 | + "Place TOC and Anchors blocks at the document start for better accessibility", |
| 147 | + "Place Siblings block at the document end for Previous/Next navigation", |
143 | 148 | "Use Anchors block for documentation with cross-references", |
144 | | - "Use Siblings block for series of related pages", |
| 149 | + "Use Siblings block for tutorial series and sequential guides", |
145 | 150 | "For short documents (< 3 sections), TOC may be redundant" |
146 | 151 | ), |
147 | 152 |
|
|
151 | 156 | text("mention_document()", code=True), |
152 | 157 | " to create links between documents and populate the Anchors block!" |
153 | 158 | ), |
| 159 | + |
| 160 | + horizontal_rule(), |
| 161 | + |
| 162 | + # Bottom navigation - demonstrate siblings placement |
| 163 | + siblings_block(), |
154 | 164 | ] |
155 | 165 |
|
156 | 166 | try: |
157 | 167 | response = client.replace_json_document(DOCUMENT_ID, content) |
158 | 168 | print("✅ Document created successfully!") |
159 | 169 | print() |
160 | 170 | print("What was added:") |
161 | | - print(" • TOC block - automatic table of contents") |
162 | | - print(" • Anchors block - related documents and backlinks") |
163 | | - print(" • Siblings block - same-level documents") |
164 | | - print(" • Headings with UIDs for navigation") |
| 171 | + print(" • TOC block (top) - automatic table of contents") |
| 172 | + print(" • Anchors block (top) - related documents and backlinks") |
| 173 | + print(" • Siblings block (bottom) - Previous/Next navigation") |
| 174 | + print(" • Headings with UIDs for TOC navigation") |
| 175 | + print() |
| 176 | + print("Navigation layout:") |
| 177 | + print(" ┌─────────────────────────┐") |
| 178 | + print(" │ TOC Block │ ← Internal navigation") |
| 179 | + print(" │ Anchors Block │ ← Related docs") |
| 180 | + print(" ├─────────────────────────┤") |
| 181 | + print(" │ Content... │") |
| 182 | + print(" ├─────────────────────────┤") |
| 183 | + print(" │ Siblings Block │ ← Previous/Next") |
| 184 | + print(" └─────────────────────────┘") |
165 | 185 | print() |
166 | 186 | print(f"Open document in Vaiz: {DOCUMENT_ID}") |
167 | 187 | print() |
|
0 commit comments