Skip to content

Commit

Permalink
[DOCS] Port for New hierarchical field for Coveo to 24.5 (#27575)
Browse files Browse the repository at this point in the history
Port for #27569
  • Loading branch information
akopytko authored Nov 15, 2024
1 parent f59990c commit ec2a273
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,24 @@ def process_coveo_meta(meta, url, link):

for namespace, values in meta:
namespace_element = ET.SubElement(url, namespace)
loc_element = url.find("loc")

for tag_name, tag_value in values.items():
if tag_name == 'ovdoctype':
processed_link = process_link(link)
ET.SubElement(namespace_element, tag_name).text = processed_link
else:
ET.SubElement(namespace_element, tag_name).text = process_link(link)
elif tag_name == 'ovcategory' and loc_element is not None:
ET.SubElement(namespace_element, tag_name).text = extract_link(loc_element.text)
elif tag_name == 'ovversion':
ET.SubElement(namespace_element, tag_name).text = tag_value

def process_link(link):
if '/' in link:
return link.split('/')[0].replace("-", " ")
return link.split('.html')[0].replace("-", " ")
return link.split('.html')[0].replace("-", " ")

def extract_link(link):
path = link.split("://")[-1]
segments = path.split('/')[1:]
if segments and segments[-1].endswith('.html'):
segments = segments[:-1]
return '|'.join(segments)
3 changes: 2 additions & 1 deletion docs/sphinx_setup/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@
ov_sitemap_meta = [
('coveo:metadata', {
'ovversion': version_name,
'ovdoctype': 'null'
'ovdoctype': 'null',
'ovcategory': 'null'
})
]

Expand Down

0 comments on commit ec2a273

Please sign in to comment.