Skip to content

Commit

Permalink
fix link to stylesheet to not rely on base
Browse files Browse the repository at this point in the history
  • Loading branch information
dylansdaniels committed Dec 13, 2024
1 parent 5a976e5 commit 05253b6
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
18 changes: 18 additions & 0 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,27 @@ def generate_page_html(page_paths):
# change file extension for page
page = page.split(".md")[0] + ".html"

# get relative path to the stylesheet
css_path = os.path.join(
os.getcwd(),
"content",
"assets",
"styles.css"
)
relative_css_path = os.path.relpath(
css_path,
start=out_path
)

# combine path and page
out_path = out_path + page

# Update header with the relative stylesheet path
page_components['header'] = page_components['header'].replace(
'<link rel="stylesheet" href="styles.css">',
f'<link rel="stylesheet" href="{relative_css_path}">'
)

# use pypandoc to convert md to html
try:
converted = pypandoc.convert_file(path, 'html')
Expand Down
2 changes: 1 addition & 1 deletion content/01_under_the_hood/cortical_column_structure.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<title>HNN Textbook</title>
<!-- <base href="/website_redesign/"> -->
<link href="https://fonts.googleapis.com/css2?family=Fira+Sans:wght@400&display=swap" rel="stylesheet">
<link rel="stylesheet" href="styles.css">
<link rel="stylesheet" href="../assets/styles.css">
</head>
<body>

Expand Down
2 changes: 1 addition & 1 deletion content/01_under_the_hood/primary_electric_currents.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<title>HNN Textbook</title>
<!-- <base href="/website_redesign/"> -->
<link href="https://fonts.googleapis.com/css2?family=Fira+Sans:wght@400&display=swap" rel="stylesheet">
<link rel="stylesheet" href="styles.css">
<link rel="stylesheet" href="../assets/styles.css">
</head>
<body>

Expand Down
2 changes: 1 addition & 1 deletion content/02_simulating_erps/overview_of_erps.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<title>HNN Textbook</title>
<!-- <base href="/website_redesign/"> -->
<link href="https://fonts.googleapis.com/css2?family=Fira+Sans:wght@400&display=swap" rel="stylesheet">
<link rel="stylesheet" href="styles.css">
<link rel="stylesheet" href="../assets/styles.css">
</head>
<body>

Expand Down
2 changes: 1 addition & 1 deletion content/preface.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<title>HNN Textbook</title>
<!-- <base href="/website_redesign/"> -->
<link href="https://fonts.googleapis.com/css2?family=Fira+Sans:wght@400&display=swap" rel="stylesheet">
<link rel="stylesheet" href="styles.css">
<link rel="stylesheet" href="assets/styles.css">
</head>
<body>

Expand Down

0 comments on commit 05253b6

Please sign in to comment.