-
Notifications
You must be signed in to change notification settings - Fork 0
tag ページ生成機能 (仮) を追加する #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2317c78
tag ページ生成機能 (仮) を追加する
zztkm eec3a07
Update example_site/layouts/tags/default.html
zztkm f50b109
url_pattern に html が指定された場合の分岐を追加する
zztkm 5900053
tags が存在しない場合には描画されないようにする
zztkm 6c56ad4
不要な処理を削除する
zztkm b2e8220
fix: format
zztkm e2d5683
has_tags を追加する
zztkm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="ja"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <title>Posts tagged "{{tag_name}}" - {{site_title}}</title> | ||
| <meta name="description" content="{{site_description}}"> | ||
| <link rel="stylesheet" href="/css/style.css"> | ||
| </head> | ||
| <body> | ||
| <header> | ||
| <h1>{{site_title}}</h1> | ||
| <p>{{site_description}}</p> | ||
| </header> | ||
| <main> | ||
| <h1>Posts tagged "{{tag_name}}"</h1> | ||
|
|
||
| <ul class="post-list"> | ||
| {{#posts}} | ||
| <li class="post-item"> | ||
| <h2><a href="{{url}}">{{title}}</a></h2> | ||
| {{#pub_datetime}} | ||
| <p class="post-meta"><time datetime="{{pub_datetime}}">{{pub_datetime}}</time>{{#author}} by {{author}}{{/author}}</p> | ||
| {{/pub_datetime}} | ||
| {{#description}} | ||
| <p class="post-description">{{description}}</p> | ||
| {{/description}} | ||
| </li> | ||
| {{/posts}} | ||
| </ul> | ||
| </main> | ||
| <footer> | ||
| <p>© 2025 {{site_title}}</p> | ||
| </footer> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| --- | ||
| title: Second Post | ||
| description: Another example blog post | ||
| author: zztkm | ||
| pub_datetime: 2024-11-10 | ||
| post_slug: second-post | ||
| tags: ["blog", "tutorial"] | ||
| --- | ||
|
|
||
| # Second Post | ||
|
|
||
| This is another example post demonstrating multiple tags. | ||
|
|
||
| Posts with tags will appear on multiple tag pages. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
現在の実装では、投稿にタグがない場合でも「Tags」という見出しと空のリスト(
<ul>)が表示されてしまいます。ramhornsテンプレートでは、リストが空でない場合にのみブロックをレンダリングする機能があります。このセクション全体を条件ブロックで囲むことで、タグが存在する場合にのみ表示されるように修正することをお勧めします。この修正を有効にするには、バックエンドの
RenderContext構造体のtagsフィールドをVec<Tag>からOption<Vec<Tag>>に変更する必要があります。そして、タグのリストが空の場合はNoneを、そうでない場合はSome(tags)をコンテキストに渡してください。ramhornsはOptionを正しく解釈し、Someの場合のみブロックをレンダリングします。テンプレートの修正案は以下の通りです。
{{#tags}}でOptionをチェックし、{{#.}}でVecをイテレートします。{{#tags}} <div class="tags-section"> <h3>Tags</h3> <ul class="tag-list"> {{#.}} <li><a href="{{url}}" class="tag-link">{{name}}</a></li> {{/.}} </ul> </div> {{/tags}}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
修正した