Skip to content

Commit

Permalink
ヘッダーとフッターをincludeで読み込む #4
Browse files Browse the repository at this point in the history
  • Loading branch information
kfly8 committed Feb 12, 2021
1 parent d25fe42 commit cb64d46
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
18 changes: 2 additions & 16 deletions layouts/category.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
<link rel="stylesheet" href="/css/main.css">
</head>
<body>
<header class="site-header">
<a href="/" class="logo">Perl-users.jp</a>
</header>
<?= $include->('./include/header.html') ?>
<main>
<h1 class="page-title"><?= $vars->{category} ?></h1>
? for (@{$vars->{files}}) {
Expand All @@ -30,18 +28,6 @@ <h1 class="page-title"><?= $vars->{category} ?></h1>
</div>
? }
</main>
<footer class="site-footer">
<nav>
<a href="https://github.com/perl-users-jp/perl-users-jp.github.io" target="_blank" rel="noopener">
<svg class="octicon" height="32" viewBox="0 0 16 16" version="1.1" width="32" aria-hidden="true"><path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"></path></svg>
</a>
</nav>
<p>
<a href="/">Perl-users.jp</a> - 日本のPerlユーザーのためのハブサイトです。日本の Perl ユーザーに最新の情報を届けることを目的にしています。
</p>
<p>
文章のライセンスは、特に明記が無い限りすべて <a href="http://creativecommons.org/licenses/by/2.0/">CC-by</a>でおねがいします。
</p>
</footer>
<?= $include->('./include/footer.html') ?>
</body>
</html>
13 changes: 13 additions & 0 deletions layouts/include/footer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<footer class="site-footer">
<nav>
<a href="https://github.com/perl-users-jp/perl-users-jp.github.io" target="_blank" rel="noopener">
<svg class="octicon" height="32" viewBox="0 0 16 16" version="1.1" width="32" aria-hidden="true"><path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"></path></svg>
</a>
</nav>
<p>
<a href="/">Perl-users.jp</a> - 日本のPerlユーザーのためのハブサイトです。日本の Perl ユーザーに最新の情報を届けることを目的にしています。
</p>
<p>
文章のライセンスは、特に明記が無い限りすべて <a href="http://creativecommons.org/licenses/by/2.0/">CC-by</a>でおねがいします。
</p>
</footer>
3 changes: 3 additions & 0 deletions layouts/include/header.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<header class="site-header">
<a href="/" class="logo">Perl-users.jp</a>
</header>
3 changes: 2 additions & 1 deletion lib/PerlUsersJP/Builder.pm
Original file line number Diff line number Diff line change
Expand Up @@ -623,11 +623,12 @@ sub _render_string {
my $renderer = eval <<~ "..." or die $@;
sub {
my \$vars = shift;
my \$include = shift;
$code->();
}
...

return $renderer->($vars);
return $renderer->($vars, sub { $self->_render_string(@_) });
}

sub _normalize_name {
Expand Down

0 comments on commit cb64d46

Please sign in to comment.