Skip to content

Commit

Permalink
fix broken href on custom domain
Browse files Browse the repository at this point in the history
  • Loading branch information
irfansofyana committed Jan 8, 2025
1 parent 076ea5d commit 4c90847
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
title: Irfan's TIL
html_title: "Irfan's TIL" # This will be used in the browser tab
site_name: "Today I Learned" # This will be used in the header and footer
site_name: "Irfan Sofyana Putra's TIL" # This will be used in the header and footer
description: A collection of things I learn from day to day
baseurl: "/" # Change this to your repo name if not using custom domain
url: "https://til.irfansp.dev" # Change this to your site URL
Expand Down
4 changes: 2 additions & 2 deletions _layouts/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ <h1>{{ page.title }}</h1>
<div class="post-meta">
<span class="date-category">
<time datetime="{{ page.date | date_to_xmlschema }}">{{ page.date | date: "%B %-d, %Y" }}</time>
{% if page.category %} - <a href="{{ site.baseurl }}/categories#{{ page.category | slugify }}" class="category-link">{{ page.category }}</a>{% endif %}
{% if page.category %} - <a href="{{ '/categories' | relative_url }}#{{ page.category | slugify }}" class="category-link">{{ page.category }}</a>{% endif %}
</span>
</div>
{% if page.tags.size > 0 %}
<div class="tags">
{% for tag in page.tags %}
<a href="{{ site.baseurl }}/tags#{{ tag | slugify }}" class="tag">#{{ tag }}</a>
<a href="{{ '/tags' | relative_url }}#{{ tag | slugify }}" class="tag">{{ tag }}</a>
{% endfor %}
</div>
{% endif %}
Expand Down
6 changes: 3 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ <h1>Recent Learnings</h1>
<div class="post-meta">
<span class="date-category">
<time datetime="{{ post.date | date_to_xmlschema }}">{{ post.date | date: "%B %-d, %Y" }}</time>
{% if post.category %}<a href="{{ site.baseurl }}/categories#{{ post.category | slugify }}" class="category-link">{{ post.category }}</a>{% endif %}
{% if post.category %}<a href="{{ '/categories' | relative_url }}#{{ post.category | slugify }}" class="category-link">{{ post.category }}</a>{% endif %}
</span>
</div>
<h2 class="post-title">
Expand All @@ -52,7 +52,7 @@ <h2 class="post-title">
{% if post.tags.size > 0 %}
<div class="tags">
{% for tag in post.tags %}
<a href="{{ site.baseurl }}/tags#{{ tag | slugify }}" class="tag">{{ tag }}</a>
<a href="{{ '/tags' | relative_url }}#{{ tag | slugify }}" class="tag">{{ tag }}</a>
{% endfor %}
</div>
{% endif %}
Expand All @@ -77,7 +77,7 @@ <h2>Popular Tags</h2>
{% assign max_size = sorted_tags.first.size | times: 1.0 %}
{% assign size_ratio = tag_size | divided_by: max_size %}
{% assign font_size = size_ratio | times: 0.4 | plus: 0.8 %}
<a href="{{ site.baseurl }}/tags#{{ tag.name | slugify }}"
<a href="{{ '/tags' | relative_url }}#{{ tag.name | slugify }}"
class="tag-item"
style="--tag-size: {{ font_size }}">
<span class="tag-name">{{ tag.name }}</span>
Expand Down
7 changes: 5 additions & 2 deletions search.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ <h2>Search Features</h2>
</ul>
</div>

<link rel="stylesheet" href="{{ site.baseurl }}/assets/css/search.css">
<link rel="stylesheet" href="{{ '/assets/css/search.css' | relative_url }}">
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>

<div class="search-container">
Expand All @@ -26,6 +26,9 @@ <h2>Search Features</h2>
</div>

<script>
// Pre-compute URLs
const tagsBaseUrl = "{{ '/tags' | relative_url }}";

// Initialize search data
const searchStore = {
{% for post in site.til %}
Expand Down Expand Up @@ -148,7 +151,7 @@ <h2><a href="${item.url}">${title}</a></h2>
${tags.length ? `
<div class="tags">
${tags.map(tag => `
<a href="{{ site.baseurl }}/tags#${tag.toLowerCase()}"
<a href="${tagsBaseUrl}#${tag.toLowerCase()}"
class="tag">${tag}</a>
`).join('')}
</div>
Expand Down

0 comments on commit 4c90847

Please sign in to comment.