feat: add $BASE_URL support in url

This commit is contained in:
st1020 2023-10-23 20:57:18 +08:00
parent 71e0389b90
commit bf1a110516
4 changed files with 14 additions and 9 deletions

View file

@ -1,5 +1,5 @@
# The base URL of the site; the only required configuration variable. # The base URL of the site; the only required configuration variable.
base_url = "https://st1020.github.io/kita/" base_url = "https://st1020.github.io/kita"
# The site title and description; used in feeds by default. # The site title and description; used in feeds by default.
title = "Kita" title = "Kita"
@ -74,23 +74,23 @@ url = "https://github.com/st1020/kita"
[[extra.profile.social]] [[extra.profile.social]]
name = "rss" name = "rss"
url = "/atom.xml" url = "$BASE_URL/atom.xml"
[[extra.menu]] [[extra.menu]]
name = "Projects" name = "Projects"
url = "/projects" url = "$BASE_URL/projects"
[[extra.menu]] [[extra.menu]]
name = "Archive" name = "Archive"
url = "/archive" url = "$BASE_URL/archive"
[[extra.menu]] [[extra.menu]]
name = "Tags" name = "Tags"
url = "/tags" url = "$BASE_URL/tags"
[[extra.menu]] [[extra.menu]]
name = "About" name = "About"
url = "/about" url = "$BASE_URL/about"
[extra.footer] [extra.footer]
since = 2020 since = 2020

View file

@ -38,7 +38,7 @@
<a <a
class="primary-link h-8 w-8 text-[0] [background:var(--url)_center_center/cover_no-repeat]" class="primary-link h-8 w-8 text-[0] [background:var(--url)_center_center/cover_no-repeat]"
style="--url: url(./icons/{{ social.name }}.svg)" style="--url: url(./icons/{{ social.name }}.svg)"
href="{{ social.url }}" href="{{ social.url | replace(from=`$BASE_URL`, to=config.base_url) | safe }}"
target="_blank" target="_blank"
rel="{% if social.name == `rss` %}alternate{% else %}me{% endif %}" rel="{% if social.name == `rss` %}alternate{% else %}me{% endif %}"
> >

View file

@ -67,7 +67,7 @@
<li> <li>
<a <a
class="primary-link block py-2 text-center text-lg font-medium lg:px-3 lg:py-0" class="primary-link block py-2 text-center text-lg font-medium lg:px-3 lg:py-0"
href="{{ menu.url }}" href="{{ menu.url | replace(from=`$BASE_URL`, to=config.base_url) | safe }}"
>{{ menu.name }}</a >{{ menu.name }}</a
> >
</li> </li>

View file

@ -18,7 +18,12 @@
</div> </div>
<div class="flex gap-x-2"> <div class="flex gap-x-2">
{% for link in project.links %} {% for link in project.links %}
<a class="underline" href="{{ link.url }}" target="_blank">{{ link.name }}</a> <a
class="underline"
href="{{ link.url | replace(from=`$BASE_URL`, to=config.base_url) | safe }}"
target="_blank"
>{{ link.name }}</a
>
{% endfor %} {% endfor %}
</div> </div>
</div> </div>