Skip to content

Commit 48773d6

Browse files
committed
Update generate-sitemaps.py
1 parent 773badd commit 48773d6

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

generate-sitemaps.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,20 @@ def generate_sitemap_for_language(posts_dir, url_prefix, output_dir, reference_d
1717
# Skip files in redir directory
1818
if "redir" in file_path.parts:
1919
continue
20-
try:
21-
post = frontmatter.load(file_path)
22-
if 'permalink' in post:
23-
permalink = post['permalink']
24-
# Use permalink as-is if it has a domain, otherwise prepend base_url
25-
url = permalink if permalink.startswith(('http://', 'https://')) else f"{base_url}/{permalink.lstrip('/')}"
26-
# Skip dash.plotly.com URLs
27-
if 'dash.plotly.com' in url:
28-
continue
29-
# Skip chart-studio URLs
30-
if 'chart-studio' in url:
31-
continue
32-
# Only include URLs that start with the specified prefix (with or without leading slash)
33-
if permalink.startswith(url_prefix) or permalink.startswith(f"/{url_prefix}"):
34-
urls.append(url)
35-
except Exception as e:
36-
pass
20+
post = frontmatter.load(file_path)
21+
if 'permalink' in post:
22+
permalink = post['permalink']
23+
# Use permalink as-is if it has a domain, otherwise prepend base_url
24+
url = permalink if permalink.startswith(('http://', 'https://')) else f"{base_url}/{permalink.lstrip('/')}"
25+
# Skip dash.plotly.com URLs
26+
if 'dash.plotly.com' in url:
27+
continue
28+
# Skip chart-studio URLs
29+
if 'chart-studio' in url:
30+
continue
31+
# Only include URLs that start with the specified prefix (with or without leading slash)
32+
if permalink.startswith(url_prefix) or permalink.startswith(f"/{url_prefix}"):
33+
urls.append(url)
3734

3835
# Remove duplicates and sort
3936
urls = sorted(set(urls))

0 commit comments

Comments
 (0)