Update related posts design and move comments above it

This commit is contained in:
BBaoVanC 2022-05-04 18:45:02 -05:00
parent 0877a9d400
commit 76b0383c2c
Signed by: bbaovanc
GPG Key ID: 18089E4E3CCF1D3A
2 changed files with 51 additions and 19 deletions

View File

@ -252,25 +252,53 @@
/* Related posts */ /* Related posts */
.related hr { .related {
/* make left/right 0 margin so it takes up full width */
margin: 25px 0; margin: 25px 0;
} }
.related > hr,
.related > h2 {
margin-left: 20px;
margin-right: 20px;
}
.related-posts .post {
min-width: 300px;
max-width: 300px;
/* since .related and .related-posts are both full-width with no margin */
margin-left: 20px;
}
.related-posts .post:last-child {
margin-right: 20px;
}
@media (max-width: 720px) {
/* when the screen is smaller than max size, make sure that the .related div
* still reaches the screen edge. then if the posts overflow and require
* scrolling, you can see it cut off on the side of your phone screen
*/
.related {
margin-left: -20px;
margin-right: -20px;
}
}
@media (min-width: 720px) { @media (min-width: 720px) {
.related { .related {
/* this makes it full width -- 720px max-width on body /* this makes it full width -- 720px max-width on body it is exactly 720px
* add an extra 40px to give a 20px margin on left and right */ * so .related takes up full width
margin-left: calc(-100vw / 2 + 760px / 2); */
margin-right: calc(-100vw / 2 + 760px / 2); margin-left: calc(-100vw / 2 + 720px / 2);
margin-right: calc(-100vw / 2 + 720px / 2);
} }
} }
.related-posts { .related-posts {
display: grid; display: flex;
gap: 20px; overflow-x: scroll;
grid-auto-flow: column;
grid-auto-columns: 300px;
overflow-x: auto;
} }
@ -403,7 +431,6 @@
/* Basic elements */ /* Basic elements */
html { html {
scroll-behavior: smooth; scroll-behavior: smooth;
margin: 0 20px;
} }
@media screen and (prefers-reduced-motion: reduce) { @media screen and (prefers-reduced-motion: reduce) {
@ -416,11 +443,17 @@ body {
background-color: var(--background); background-color: var(--background);
color: var(--text-normal); color: var(--text-normal);
font-family: "Open Sans", "Noto Sans", sans-serif; font-family: "Open Sans", "Noto Sans", sans-serif;
margin: 0 auto 20px; margin: 20px;
max-width: 720px; max-width: 720px;
overflow-wrap: break-word; overflow-wrap: break-word;
} }
@media (min-width: 760px) {
body {
margin: 20px auto;
}
}
footer { footer {
text-align: center; text-align: center;
} }

View File

@ -68,6 +68,12 @@
{{ partial "share.html" . }} {{ partial "share.html" . }}
{{ end }} {{ end }}
{{ if .Params.comments }}
<div class="comments">
{{ partial "comments.html" . }}
</div>
{{ end }}
{{ $related := .Site.RegularPages.Related . | first 10 }} {{ $related := .Site.RegularPages.Related . | first 10 }}
{{ with $related }} {{ with $related }}
<div class="related"> <div class="related">
@ -78,13 +84,6 @@
{{ .Render "summary/post" }} {{ .Render "summary/post" }}
{{ end }} {{ end }}
</div> </div>
<hr>
</div>
{{ end }}
{{ if .Params.comments }}
<div class="comments">
{{ partial "comments.html" . }}
</div> </div>
{{ end }} {{ end }}
{{ end }} {{ end }}