Skip to content

Commit

Permalink
template/base: サイトトップへの相対リンクにindex.htmlを明示
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Jun 5, 2022
1 parent 7270b13 commit 37c9977
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion boostjp/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="{{ relative_base }}/">
<a class="navbar-brand" href="{{ relative_index }}">
<div class="title-wrapper clearfix">
<div class="title">{% block brand %}{% endblock %}</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion cpprefjp/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="{{ relative_base }}/">
<a class="navbar-brand" href="{{ relative_index }}">
<div class="title-wrapper clearfix">
<div class="title">{% block brand %}{% endblock %}</div>
</div>
Expand Down
7 changes: 5 additions & 2 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,12 +525,15 @@ def convert_pageinfo(pageinfo, sidebar, sidebar_index, template, hrefs, global_q
'project_name': settings.PROJECT_NAME,
'latest_commit_info': latest_commit_info,
'keywords': settings.META_KEYWORDS,
'relative_base': ''
'relative_base': '',
'relative_index': '/'
}
if settings.USE_RELATIVE_LINK:
url_current_dir = posixpath.dirname(context['url'])
context['relative_base'] = posixpath.relpath(settings.BASE_URL, url_current_dir)
# 以下は <meta /> で埋め込む情報なので敢えて相対パスにはしない。
# Note: ローカル (file:///) で閲覧時にディレクトリを開いてしまわないように "/" で終わらず "index.html"も明示する。
context['relative_index'] = posixpath.relpath(settings.BASE_URL, url_current_dir) + '/index.html'
# Note: 以下は <meta /> で埋め込む情報なので敢えて相対パスにはしない。
# context['url'] = posixpath.relpath(context['url'], url_current_dir)
# context['rss'] = posixpath.relpath(context['rss'], url_current_dir)
convert(pageinfo['path'], template, context, hrefs, global_qualify_list)
Expand Down

0 comments on commit 37c9977

Please sign in to comment.