Skip to content

Commit 3357e1e

Browse files
committed
feat: use relative path for in site reference
1 parent 9390758 commit 3357e1e

7 files changed

Lines changed: 15 additions & 14 deletions

File tree

bulbofile.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ const data = {
1212
orgName: 'Node.js 日本ユーザーグループ',
1313
pages: require('./pages'),
1414
layoutDir: path.join(__dirname, 'source/layout'),
15-
basepath: process.env.BASEPATH || ''
15+
// file を受け取って root への相対パスを返す関数
16+
basepath: file => path.dirname(path.relative(file.relative, ''))
1617
}
1718

1819
require('nunjucks').configure().addFilter('date', require('nunjucks-date'))

source/layout/event-index.njk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
{% for event in file.files %}
77
<hr />
8-
<h2><a href="{{ basepath }}/{{ event.relative }}">{{ event.fm.name }}</a></h2>
8+
<h2><a href="{{ basepath(file) }}/{{ event.relative }}">{{ event.fm.name }}</a></h2>
99
<p>日時:
1010
{% for date in event.fm.date %}
1111
{% if not loop.first %}
@@ -14,7 +14,7 @@
1414
{{ date | date('YYYY年MM月DD日') }}
1515
{% endfor %}
1616
{% if event.fm.image %}
17-
<p><a href="{{ basepath }}{{ event.relative }}"><img src="{{ event.fm.image }}" /></a></p>
17+
<p><a href="{{ basepath(file) }}{{ event.relative }}"><img src="{{ event.fm.image }}" /></a></p>
1818
{% endif %}
1919
</ul>
2020
{% endfor %}

source/layout/event.njk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
<hr />
66
{% if file.fm.image %}
77
{% if file.fm.site %}
8-
<a href="{{ file.fm.site.url }}"><img src="{{ basepath }}/{{ file.fm.image }}" /></a>
8+
<a href="{{ file.fm.site.url }}"><img src="{{ basepath(file) }}/{{ file.fm.image }}" /></a>
99
{% else %}
10-
<img src="{{ basepath }}/{{ file.fm.image }}" />
10+
<img src="{{ basepath(file) }}/{{ file.fm.image }}" />
1111
{% endif %}
1212
<br/>
1313
<br/>

source/layout/job.njk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<h1>{{ file.fm.name }}</h1>
55
{% if file.fm.image %}
66
<a href="{{ file.fm.url }}">
7-
<img src="{{ basepath }}/{{ file.fm.image }}" width="165" style="margin: 15px;"/>
7+
<img src="{{ basepath(file) }}/{{ file.fm.image }}" width="165" style="margin: 15px;"/>
88
</a>
99
{% endif %}
1010
{% if file.fm.role %}

source/layout/jobboard.njk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
{% for file in file.files %}
77
<hr />
8-
<h2><a href="{{ basepath }}/{{ file.relative }}">{{ file.fm.name }}</a></h2>
8+
<h2><a href="{{ basepath(file) }}/{{ file.relative }}">{{ file.fm.name }}</a></h2>
99
{% if file.fm.image %}
10-
<p><img src="{{ basepath }}/{{ file.fm.image }}" width="120" style="margin: 15px;"></p>
10+
<p><img src="{{ basepath(file) }}/{{ file.fm.image }}" width="120" style="margin: 15px;"></p>
1111
{% endif %}
1212
<p>
1313
{% if file.fm.role %}

source/layout/layout.njk

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
<title>{{ orgName }}</title>
22
<meta charset="UTF-8">
33
<meta name="viewport" content="width=device-width, initial-scale=1">
4-
<link rel="stylesheet" href="{{ basepath }}/css/tacit.min.css"/>
5-
<link rel="stylesheet" href="{{ basepath }}/css/style.css"/>
6-
<link rel="icon" href="{{ basepath }}/images/favicon.png" />
4+
<link rel="stylesheet" href="{{ basepath(file) }}/css/tacit.min.css"/>
5+
<link rel="stylesheet" href="{{ basepath(file) }}/css/style.css"/>
6+
<link rel="icon" href="{{ basepath(file) }}/images/favicon.png" />
77

88
<nav>
9-
<img width="150" src="{{ basepath }}/images/nodejs-logo.svg" />
9+
<img width="150" src="{{ basepath(file) }}/images/nodejs-logo.svg" />
1010
<br />
1111
<ul>
1212
{% for page in pages %}
1313
{% if page.path == file.relative %}
1414
<li>{{ page.name }}
1515
{% else %}
16-
<li><a href="{{ basepath }}/{{ page.path }}">{{ page.name }}</a>
16+
<li><a href="{{ basepath(file) }}/{{ page.path }}">{{ page.name }}</a>
1717
{% endif %}
1818
{% endfor %}
1919
</ul>

source/layout/news-index.njk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<hr />
88
<h2>
99
<small>{{ file.fm.date | date('YYYY/MM/DD') }}</small>
10-
<a href="{{ basepath }}/{{ file.relative }}">{{ file.fm.title }}</a>
10+
<a href="{{ basepath(file) }}/{{ file.relative }}">{{ file.fm.title }}</a>
1111
</h2>
1212
{% endfor %}
1313

0 commit comments

Comments
 (0)