-
-
Notifications
You must be signed in to change notification settings - Fork 196
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
WIP: Refactor relate page #1371
Draft
wu0407
wants to merge
3
commits into
HEIGE-PCloud:main
Choose a base branch
from
wu0407:refactor-relate-page
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 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 |
---|---|---|
@@ -1,52 +1,105 @@ | ||
.related-container { | ||
display: grid; | ||
grid-template-columns: repeat(4, 1fr); | ||
justify-content: space-between; | ||
gap: 1rem; | ||
// margin-top: 2rem; | ||
padding: 0.8rem; | ||
} | ||
|
||
.related-item-container { | ||
flex: 1; | ||
min-width: 0; /* 允许flex项目缩小到比内容更小 */ | ||
background-color: $related-background-color; | ||
@include border-radius(0.25rem); | ||
@include box-shadow(0 2px 4px rgba(0, 0, 0, 0.1)); | ||
@include transition(transform 0.3s ease, box-shadow 0.3s ease); | ||
overflow: hidden; | ||
display: flex; | ||
flex-wrap: nowrap; | ||
overflow-x: scroll; | ||
width: 100%; | ||
height: 280px; | ||
|
||
.related-item-container { | ||
flex-basis: 350px; | ||
flex-grow: 1; | ||
flex-shrink: 1; | ||
height: 270px; | ||
min-width: 300px; | ||
margin-right: 20px; | ||
background: $related-background-color; | ||
position: relative; | ||
aspect-ratio: 2 / 1.5; /* 设置固定的宽高比 */ | ||
} | ||
|
||
.related-item-container:hover { | ||
transform: translateY(-5px); | ||
@include box-shadow(0 4px 8px rgba(0, 0, 0, 0.2)); | ||
h2.related-title { | ||
color: $global-link-hover-color; | ||
} | ||
} | ||
|
||
.related-image { | ||
@include transition(transform 0.4s ease); | ||
.related-item-container > a { | ||
// display: flex; | ||
flex-direction: column; | ||
height: 100%; | ||
width: 100%; | ||
text-decoration: none; | ||
color: $related-color; | ||
} | ||
|
||
img { | ||
width: 100%; | ||
height: 200px; | ||
object-fit: cover; | ||
} | ||
.related-image { | ||
width: 100%; | ||
height: 0; | ||
padding-bottom: 50%; /* 保持 2:1 的宽高比 */ | ||
position: relative; | ||
overflow: hidden; | ||
} | ||
|
||
&:hover { | ||
@include transform(scale(1.01)); | ||
} | ||
} | ||
.related-image img { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
object-fit: cover; | ||
} | ||
|
||
.related-title { | ||
font-size: 0.85rem; | ||
margin: 0.3rem; | ||
overflow: hidden; | ||
} | ||
|
||
/* 有图片时的标题样式 */ | ||
.related-item-container:has(.related-image) .related-title { | ||
white-space: nowrap; | ||
text-overflow: ellipsis; | ||
} | ||
|
||
/* 没有图片时的标题样式 */ | ||
.related-item-container:not(:has(.related-image)) .related-title { | ||
// display: -webkit-box; | ||
// -webkit-line-clamp: 5; /* 显示5行 */ | ||
// -webkit-box-orient: vertical; | ||
// max-height: 7.8em; /* 大约5行的高度,根据实际情况调整 */ | ||
display: flex; /* 使用标准的 Flexbox */ | ||
flex-direction: column; /* 垂直方向排列 */ | ||
overflow: hidden; /* 隐藏超出部分 */ | ||
line-height: 1.5em; | ||
} | ||
|
||
/* 当没有图片时,确保整个区域可点击 */ | ||
.related-item-container:not(:has(.related-image)) > a { | ||
padding: 0.5rem; | ||
} | ||
|
||
@media (max-width: 768px) { | ||
.related-container { | ||
grid-template-columns: repeat(2, 1fr); | ||
padding: 0.5rem; | ||
} | ||
|
||
.related-title { | ||
position: absolute; | ||
text-overflow: ellipsis; | ||
overflow: hidden; | ||
white-space: nowrap; | ||
top: 210px; | ||
width: 95%; | ||
margin: 10px; | ||
font-size: 1.25rem; | ||
line-height: 140%; | ||
font-size: 1rem; | ||
} | ||
} | ||
|
||
.related-title a { | ||
color: $related-color; | ||
|
||
&:hover { | ||
color: $related-hover-color; | ||
} | ||
@media (max-width: 480px) { | ||
.related-container { | ||
grid-template-columns: 1fr; | ||
gap: 0.5rem; | ||
} | ||
|
||
.related-title { | ||
font-size: 0.9rem; | ||
} | ||
} |
This file contains 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 |
---|---|---|
|
@@ -508,7 +508,6 @@ bundle = false | |
# 相关文章推荐配置 | ||
[page.related] | ||
enable = true | ||
count = 5 | ||
|
||
# Sponsor config | ||
# 赞助设置 | ||
|
This file contains 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 |
---|---|---|
|
@@ -14,7 +14,6 @@ hiddenFromHomePage: true | |
hiddenFromSearch: true | ||
related: | ||
enable: true | ||
count: 2 | ||
--- | ||
|
||
<!--more--> | ||
|
This file contains 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 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 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 |
---|---|---|
|
@@ -171,7 +171,6 @@ sponsor: | |
# ... | ||
related: | ||
enable: false | ||
count: 5 | ||
--- | ||
``` | ||
|
||
|
This file contains 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.
I am not sure about this change. Why do you think it's a better idea to fix recommendation count to 4?
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.
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.
I imagine configuring the count to 2 or 3 makes sense equally. The
800px
argument does not hold on mobile, where maybe only one recommendation can fit on screen and you will need to handle the overflow with a scrollbar anyway.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.
Dynamically adapt to screen width,maybe change from 4 to 3 would be more appropriate for 800px.
DoIt/assets/css/_partial/_single/_related.scss
Lines 81 to 100 in ba650e8