@@ -206,15 +206,22 @@ def parse_markdown_content(metadata, content):
206
206
heading_slug = slug
207
207
lines = content .splitlines ()
208
208
current_h1 = metadata .get ('title' , '' )
209
+ current_h2 = None
210
+ current_h3 = None
211
+ current_h4 = None
209
212
current_subdoc = {
210
213
'file_path' : metadata .get ('file_path' , '' ),
211
214
'slug' : heading_slug ,
212
215
'url' : f'{ DOCS_SITE } { heading_slug } ' ,
213
216
'h1' : current_h1 ,
214
- 'content' : metadata .get ('description' , '' ),
215
217
'title' : metadata .get ('title' , '' ),
218
+ 'content' : metadata .get ('description' , '' ),
216
219
'keywords' : metadata .get ('keywords' , '' ),
217
220
'objectID' : get_object_id (heading_slug ),
221
+ 'type' : 'lvl0' ,
222
+ 'hierarchy' : {
223
+ 'lvl0' : metadata .get ('title' , '' )
224
+ }
218
225
}
219
226
for line in lines :
220
227
if line .startswith ('# ' ):
@@ -227,7 +234,10 @@ def parse_markdown_content(metadata, content):
227
234
current_subdoc ['slug' ] = heading_slug
228
235
current_subdoc ['url' ] = f'{ DOCS_SITE } { heading_slug } '
229
236
current_subdoc ['h1' ] = current_h1
237
+ current_subdoc ['title' ] = current_h1
238
+ current_subdoc ['type' ] = 'lvl1'
230
239
current_subdoc ['object_id' ] = custom_slugify (heading_slug )
240
+ current_subdoc ['hierarchy' ]['lvl1' ] = current_h1
231
241
elif line .startswith ('## ' ):
232
242
if current_subdoc :
233
243
yield from split_large_document (current_subdoc )
@@ -246,7 +256,13 @@ def parse_markdown_content(metadata, content):
246
256
'h2' : current_h2 ,
247
257
'content' : '' ,
248
258
'keywords' : metadata .get ('keywords' , '' ),
249
- 'objectID' : get_object_id (f'{ heading_slug } -{ current_h2 } ' )
259
+ 'objectID' : get_object_id (f'{ heading_slug } -{ current_h2 } ' ),
260
+ 'type' : 'lvl2' ,
261
+ 'hierarchy' : {
262
+ 'lvl0' : metadata .get ('title' , '' ),
263
+ 'lvl1' : current_h1 ,
264
+ 'lvl2' : current_h2 ,
265
+ }
250
266
}
251
267
elif line .startswith ('### ' ):
252
268
# note we send users to the h2 or h1 even on ###
@@ -267,7 +283,14 @@ def parse_markdown_content(metadata, content):
267
283
'h3' : current_h3 ,
268
284
'content' : '' ,
269
285
'keywords' : metadata .get ('keywords' , '' ),
270
- 'objectID' : get_object_id (f'{ heading_slug } -{ current_h3 } ' )
286
+ 'objectID' : get_object_id (f'{ heading_slug } -{ current_h3 } ' ),
287
+ 'type' : 'lvl3' ,
288
+ 'hierarchy' : {
289
+ 'lvl0' : metadata .get ('title' , '' ),
290
+ 'lvl1' : current_h1 ,
291
+ 'lvl2' : current_h2 ,
292
+ 'lvl3' : current_h3 ,
293
+ }
271
294
}
272
295
elif line .startswith ('#### ' ):
273
296
if current_subdoc :
@@ -279,12 +302,20 @@ def parse_markdown_content(metadata, content):
279
302
current_subdoc = {
280
303
'file_path' : metadata .get ('file_path' , '' ),
281
304
'slug' : f'{ heading_slug } ' ,
282
- 'url' : f'{ DOCS_SITE } { heading_slug } # ' ,
305
+ 'url' : f'{ DOCS_SITE } { heading_slug } ' ,
283
306
'title' : current_h4 ,
284
307
'h4' : current_h4 ,
285
308
'content' : '' ,
286
309
'keywords' : metadata .get ('keywords' , '' ),
287
- 'objectID' : get_object_id (f'{ heading_slug } -{ current_h4 } ' )
310
+ 'objectID' : get_object_id (f'{ heading_slug } -{ current_h4 } ' ),
311
+ 'type' : 'lvl4' ,
312
+ 'hierarchy' : {
313
+ 'lvl0' : metadata .get ('title' , '' ),
314
+ 'lvl1' : current_h1 ,
315
+ 'lvl2' : current_h2 ,
316
+ 'lvl3' : current_h3 ,
317
+ 'lvl4' : current_h4 ,
318
+ }
288
319
}
289
320
elif current_subdoc :
290
321
current_subdoc ['content' ] += line + '\n '
0 commit comments