HTMLを綺麗に

諏訪子 <suwako@076.moe>、2025-11-08 18:12
コミット 8513c530f56deb2e1008518c462e0d99f907cacf ・親 adaf762 ・ファイルを見る

7個のファイル、+112 -101

@@ -42,7 +42,7 @@
4242 */
4343 public function addCss(string $name): void {
4444 $this->custCss[] =
45- '<link rel="stylesheet" type="text/css" href="/static/style-'.$name.'.css" />';
45+ "<link rel=\"stylesheet\" type=\"text/css\" href=\"/static/style-{$name}.css\" />\n";
4646 $this->assign('custCss', $this->custCss);
4747 }
4848
@@ -1,16 +1,27 @@
11 {@ include(common/header) @}
2+{@ include(common/search) @}
3+
24 <div class="news-article">
3- {@ if (isset($meta->thumbnail) && $meta->thumbnail != '') @}
5+{@ if (isset($meta->thumbnail) && $meta->thumbnail != '') @}
46 <div class="thumbnail{{ isset($meta->thumborient) && $meta->thumborient != 'center' ? ' '.$meta->thumborient : '' }}">
57 <img src="/static/article/{{ $meta->thumbnail }}" alt="" />
68 </div>
7- {@ endif @}
9+{@ endif @}
810 <div class="meta">
911 <div class="meta-date">{{ $meta->date }}</div>
1012 <div class="meta-author">{{ $meta->author }}</div>
13+{@ if (isset($meta->category) && !empty($meta->category) && $meta->category[0] !== '') @}
14+{@ foreach ($meta->category as $cat) @}
15+ <div class="meta-category">
16+ {{ $cat }}
17+
18+ </div>
19+{@ endforeach @}
20+{@ endif @}
1121 </div>
1222
1323 <h1 class="title">{{{ $meta->title }}}</h1>
14- {{{ $article }}}
24+{{{ $article }}}
25+
1526 </div>
1627 {@ include(common/footer) @}
@@ -7,16 +7,16 @@
77 <title>{{ SITEINFO['title'] }}: {{ $pagetit }}</title>
88 <link rel="stylesheet" type="text/css" href="/static/style.css" />
99 {@ if (isset($custCss) && !empty($custCss) && !is_bool($custCss)) @}
10- {@ foreach ($custCss as $css) @}
10+{@ foreach ($custCss as $css) @}
1111 {{{ $css }}}
12- {@ endforeach @}
12+{@ endforeach @}
1313 {@ endif @}
1414 {@ if (isset($meta)) @}
1515 <meta name="author" content="{{ $meta->author }}" />
16- {@ if (isset($meta->thumbnail)) @}
16+{@ if (isset($meta->thumbnail)) @}
1717 <meta name="thumbnail" content="/static/{{ $meta->thumbnail }}" />
18- {@ endif @}
1918 {@ endif @}
19+{@ endif @}
2020 <meta name="description" content="{{ $description }}" />
2121 <meta name="keywords" content="{{ SITEINFO['tags'].',' }}{@ if (isset($meta)) @}{@ foreach ($meta->category as $cat) @}{{ $cat.',' }}{@ endforeach @}{@ endif @}" />
2222
@@ -24,23 +24,23 @@
2424 <meta property="og:description" content="{{ $description }}" />
2525 <meta property="og:type" content="{{ isset($meta) && isset($meta->thumbnail) ? 'article' : 'website' }}" />
2626 <meta property="og:url" content="{{ isset($_SERVER['REQUEST_URI']) ? 'https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'] : 'https://'.$_SERVER['HTTP_HOST'] }}" />
27- {@ if (isset($meta) && isset($meta->thumbnail)) @}
27+{@ if (isset($meta) && isset($meta->thumbnail)) @}
2828 <meta property="og:image" content="https://{{ $_SERVER['HTTP_HOST'] }}/static/article/{{ $meta->thumbnail }}" />
29- {@ endif @}
29+{@ endif @}
3030
31- {@ if (TWITTER_HANDLE != '') @}
31+{@ if (TWITTER_HANDLE != '') @}
3232 <meta name="twitter:card" content="summary_large_image" />
3333 <meta name="twitter:card" content="{{ TWITTER_HANDLE }}" />
3434 <meta name="twitter:title" content="{{ SITEINFO['title'] }}: {{ $pagetit }}" />
3535 <meta name="twitter:url" content="{{ isset($_SERVER['REQUEST_URI']) ? 'https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'] : 'https://'.$_SERVER['HTTP_HOST'] }}" />
3636 <meta name="twitter:description" content="{{ $description }}" />
37- {@ if (isset($meta) && isset($meta->thumbnail)) @}
37+{@ if (isset($meta) && isset($meta->thumbnail)) @}
3838 <meta name="twitter:image:src" content="https://{{ $_SERVER['HTTP_HOST'] }}/static/article/{{ $meta->thumbnail }}" />
39- {@ endif @}
40- {@ endif @}
41- {@ if (ATOM_ENABLED) @}
39+{@ endif @}
40+{@ endif @}
41+{@ if (ATOM_ENABLED) @}
4242 <link rel="alternate" type="application/atom+xml" title="{{ SITEINFO['title'] }} feed" href="/blog.atom" />
43- {@ endif @}
43+{@ endif @}
4444 </head>
4545 <body>
4646 <div class="container">
@@ -50,9 +50,9 @@
5050 </div>
5151 <nav>
5252 {@ foreach ($menu as $m) @}
53- {@ if ($m['show']) @}
53+{@ if ($m['show']) @}
5454 <a class="{{ $m['class'] }}{{ $curPage == $m['page'] ? ' active' : '' }}" href="{{ $m['href'] }}">{{ $m['text'] }}</a>
55- {@ endif @}
55+{@ endif @}
5656 {@ endforeach @}
5757 </nav>
5858 </header>
@@ -1,23 +1,21 @@
1- <article class="news-card">
2- {@ if (isset($post['thumbnail']) && $post['thumbnail'] != '') @}
3- <div class="news-image">
4- <a href="/{{ $section }}/{{ $post['slug'] }}">
5- <img src="/static/article/{{ $post['thumbnail'] }}" alt="{{ $post['title'] }}" loading="lazy" />
6- </a>
1+ <article class="news-card">
2+{@ if (isset($post['thumbnail']) && $post['thumbnail'] != '') @}
3+ <div class="news-image">
4+ <a href="/{{ $section }}/{{ $post['slug'] }}">
5+ <img src="/static/article/{{ $post['thumbnail'] }}" alt="{{ $post['title'] }}" loading="lazy" />
6+ </a>
7+ </div>
8+{@ endif @}
9+ <div class="news-content">
10+ <div class="news-meta">
11+ <span class="news-date">{{ $post['date'] }}</span>
12+{@ foreach ($post['category'] as $cat) @}
13+ <span class="news-category">{{ $cat }}</span>
14+{@ endforeach @}
715 </div>
8- {@ endif @}
9- <div class="news-content">
10- <div class="news-meta">
11- <span class="news-date">{{ $post['date'] }}</span>
12- {# {@ if (isset($post['category']) && is_array($post['category'])) @} #}
13- {@ foreach ($post['category'] as $cat) @}
14- <span class="news-category">{{ $cat }}</span>
15- {@ endforeach @}
16- {# {@ endif @} #}
17- </div>
18- <h2 class="news-title">
19- <a href="/{{ $section }}/{{ $post['slug'] }}{{{ isset($_GET['q']) ? '?q='.urlencode($_GET['q']) : '' }}}">{{{ $post['title'] }}}</a>
20- </h2>
21- <p class="news-preview">{{{ $post['preview'] }}}</p>
22- </div>
23- </article>
16+ <h2 class="news-title">
17+ <a href="/{{ $section }}/{{ $post['slug'] }}{{{ isset($_GET['q']) ? '?q='.urlencode($_GET['q']) : '' }}}">{{{ $post['title'] }}}</a>
18+ </h2>
19+ <p class="news-preview">{{{ $post['preview'] }}}</p>
20+ </div>
21+ </article>
@@ -1,71 +1,71 @@
1- {@ if (isset($totalPages) && $totalPages > 1) @}
1+{@ if (isset($totalPages) && $totalPages > 1) @}
22 <div class="pagination">
3- {# 検索クエリがある場合はページネーションリンクに含める #}
4- {$ $queryParams = [] $}
5- {@ if (isset($_GET['q']) && !empty($_GET['q'])) @}
6- {$ $queryParams['q'] = $_GET['q'] $}
7- {@ endif @}
3+{# 検索クエリがある場合はページネーションリンクに含める #}
4+{$ $queryParams = [] $}
5+{@ if (isset($_GET['q']) && !empty($_GET['q'])) @}
6+{$ $queryParams['q'] = $_GET['q'] $}
7+{@ endif @}
88
9- {# 前のページへのリンク #}
10- {@ if (isset($currentPage) && $currentPage > 1) @}
11- {$ $prevParams = $queryParams $}
12- {$ $prevParams['page'] = $currentPage - 1 $}
13- {$ $prevQueryString = http_build_query($prevParams) $}
9+{# 前のページへのリンク #}
10+{@ if (isset($currentPage) && $currentPage > 1) @}
11+{$ $prevParams = $queryParams $}
12+{$ $prevParams['page'] = $currentPage - 1 $}
13+{$ $prevQueryString = http_build_query($prevParams) $}
1414 <a href="?{{ $prevQueryString }}" class="page-link">&laquo; 前</a>
15- {@ endif @}
15+{@ endif @}
1616
17- {# 表示するページ番号の範囲を計算(モバイル対応の為) #}
18- {# 最大表示ページ数 #}
19- {$ $rangeSize = 2 $}
20- {$ $startPage = max(1, $currentPage - floor($rangeSize / 2)) $}
21- {$ $endPage = min($totalPages, $startPage + $rangeSize - 1) $}
17+{# 表示するページ番号の範囲を計算(モバイル対応の為) #}
18+{# 最大表示ページ数 #}
19+{$ $rangeSize = 2 $}
20+{$ $startPage = max(1, $currentPage - floor($rangeSize / 2)) $}
21+{$ $endPage = min($totalPages, $startPage + $rangeSize - 1) $}
2222
23- {# 範囲の調整 #}
24- {@ if ($endPage - $startPage + 1 < $rangeSize && $startPage > 1) @}
25- {$ $startPage = max(1, $endPage - $rangeSize + 1) $}
26- {@ endif @}
23+{# 範囲の調整 #}
24+{@ if ($endPage - $startPage + 1 < $rangeSize && $startPage > 1) @}
25+{$ $startPage = max(1, $endPage - $rangeSize + 1) $}
26+{@ endif @}
2727
28- {# 最初のページへのリンク(多数のページがある場合) #}
29- {@ if ($startPage > 1) @}
30- {$ $firstParams = $queryParams $}
31- {$ $firstParams['page'] = 1 $}
32- {$ $firstQueryString = http_build_query($firstParams) $}
28+{# 最初のページへのリンク(多数のページがある場合) #}
29+{@ if ($startPage > 1) @}
30+{$ $firstParams = $queryParams $}
31+{$ $firstParams['page'] = 1 $}
32+{$ $firstQueryString = http_build_query($firstParams) $}
3333
3434 <a href="?{{ $firstQueryString }}" class="page-link">1</a>
35- {@ if ($startPage > 2) @}
35+{@ if ($startPage > 2) @}
3636 <span class="page-ellipsis">...</span>
37- {@ endif @}
38- {@ endif @}
37+{@ endif @}
38+{@ endif @}
3939
40- {@ for ($i = $startPage; $i <= $endPage; $i++) @}
41- {$ $pageParams = $queryParams $}
42- {$ $pageParams['page'] = $i $}
43- {$ $pageQueryString = http_build_query($pageParams) $}
40+{@ for ($i = $startPage; $i <= $endPage; $i++) @}
41+{$ $pageParams = $queryParams $}
42+{$ $pageParams['page'] = $i $}
43+{$ $pageQueryString = http_build_query($pageParams) $}
4444
45- {@ if ($i == $currentPage) @}
46- <span class="page-current" aria-current="page">{{ $i }}</span>
47- {@ else @}
48- <a href="?{{ $pageQueryString }}" class="page-link">{{ $i }}</a>
49- {@ endif @}
50- {@ endfor @}
45+{@ if ($i == $currentPage) @}
46+ <span class="page-current" aria-current="page">{{ $i }}</span>
47+{@ else @}
48+ <a href="?{{ $pageQueryString }}" class="page-link">{{ $i }}</a>
49+{@ endif @}
50+{@ endfor @}
5151
52- {@ if ($endPage < $totalPages) @}
53- {# 最後のページへのリンク(多数のページがある場合) #}
54- {$ $lastParams = $queryParams $}
55- {$ $lastParams['page'] = $totalPages $}
56- {$ $lastQueryString = http_build_query($lastParams) $}
57- {@ if ($endPage < $totalPages - 1) @}
58- <span class="page-ellipsis">...</span>
59- {@ endif @}
60- <a href="?{{ $lastQueryString }}" class="page-link">{{ $totalPages }}</a>
61- {@ endif @}
52+{@ if ($endPage < $totalPages) @}
53+{# 最後のページへのリンク(多数のページがある場合) #}
54+{$ $lastParams = $queryParams $}
55+{$ $lastParams['page'] = $totalPages $}
56+{$ $lastQueryString = http_build_query($lastParams) $}
57+{@ if ($endPage < $totalPages - 1) @}
58+ <span class="page-ellipsis">...</span>
59+{@ endif @}
60+ <a href="?{{ $lastQueryString }}" class="page-link">{{ $totalPages }}</a>
61+{@ endif @}
6262
63- {# 次のページへのリンク #}
64- {@ if (isset($currentPage) && $currentPage < $totalPages) @}
65- {$ $nextParams = $queryParams $}
66- {$ $nextParams['page'] = $currentPage + 1 $}
67- {$ $nextQueryString = http_build_query($nextParams) $}
68- <a href="?{{ $nextQueryString }}" class="page-link">次 &raquo;</a>
69- {@ endif @}
63+{# 次のページへのリンク #}
64+{@ if (isset($currentPage) && $currentPage < $totalPages) @}
65+{$ $nextParams = $queryParams $}
66+{$ $nextParams['page'] = $currentPage + 1 $}
67+{$ $nextQueryString = http_build_query($nextParams) $}
68+ <a href="?{{ $nextQueryString }}" class="page-link">次 &raquo;</a>
69+{@ endif @}
7070 </div>
71- {@ endif @}
71+{@ endif @}
@@ -1,9 +1,11 @@
11 {@ include(common/header) @}
22 {@ include(common/search) @}
3+
34 <div class="news-grid">
4- {@ foreach ($posts as $post) @}
5- {@ include(common/newscard) @}
6- {@ endforeach @}
5+{@ foreach ($posts as $post) @}
6+{@ include(common/newscard) @}
7+{@ endforeach @}
78 </div>
8- {@ include(common/pagination) @}
9+
10+{@ include(common/pagination) @}
911 {@ include(common/footer) @}