-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.py
More file actions
40 lines (30 loc) · 1.23 KB
/
Copy pathscript.py
File metadata and controls
40 lines (30 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import os
blogs_directory = 'blogs/'
# Define the template for the blog card
blog_card_template = """
<li>
<a href="{blog_url}">
{blog_title}
</a>
</li>
<!-- REPLACE_WITH_BLOG_CARDS -->
"""
# List all files in the 'blogs' directory
blog_files = os.listdir(blogs_directory)
# Initialize an empty string to store the updated HTML content
updated_html_content = ""
for blog_file in blog_files:
if blog_file.endswith('.pdf') or blog_file.endswith('.docx'):
# Extract the blog title (without the file extension)
blog_title = os.path.splitext(blog_file)[0]
# Define the URL to the blog file
blog_url = os.path.join(blogs_directory, blog_file)
# Read the existing index.html content
with open('index.html', 'r') as index_file:
existing_html_content = index_file.read()
# Replace the placeholder in the existing HTML with the updated content
updated_html = existing_html_content.replace('<!-- REPLACE_WITH_BLOG_CARDS -->', updated_html_content)
# Write the updated HTML content back to the index.html file
with open('index.html', 'w') as index_file:
index_file.write(updated_html)
# Commit and push the changes to your repository using Git, as shown in the previous GitHub Actions step