Skip to content
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

feat: add friend link page support using shortcode (hugo-extended version requried) #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions layouts/shortcodes/friend.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{ if .IsNamedParams }}
{{- $src := .Get "logo" -}}
{{- $small := .Get "logo_small" | default $src -}}
{{- $large := .Get "logo_large" | default $src -}}
<div class="friend-div">
<a target="_blank" href={{ .Get "url" | safeURL }} title={{ .Get "name" }} >
<img class="lazyload"
src={{ $src | safeURL }}
data-src={{ $src | safeURL }}
alt={{ .Get "name" }}
data-sizes="auto"
data-srcset="{{ $small | safeURL }}, {{ $src | safeURL }} 1.5x, {{ $large | safeURL }} 2x" />
<span class="friend-name">{{ .Get "name" }}</span>
<span class="friend-info">{{ .Get "word" }}</span>
Comment on lines +6 to +14
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

" should be added around these attribute values, e.g., href="{{ .Get "url" | safeURL }}".

</a>
</div>
{{ end }}
2 changes: 2 additions & 0 deletions static/css/den.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

@import url("syntax.css");

@import url("friend.css");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of inserting this into the main css, you could insert it like this

<link rel="stylesheet" href="{{ "css/den.css" | absURL }}">

And add some checks to only include it when friend list shortcode is used: https://gohugo.io/templates/shortcode-templates/#checking-for-existence


/* Responsive */
@media (min-width: 768px) {
.container {
Expand Down
130 changes: 130 additions & 0 deletions static/css/friend.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
#article-container {
word-wrap: break-word;
overflow-wrap: break-word;
}

#article-container a {
color: #49b1f5;
}

#article-container a:hover {
text-decoration: underline;
}

#article-container img {
margin: 0 auto 0.8rem;
}
Comment on lines +1 to +16
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is article-container a good name for friend lists? You also have a flink class which seems to refer to the same container. Maybe we could just use a single friend-container class and refer to the container as div.friend-container? (Or choose some other appropriate names.)

Moreover, is it really necessary to have both the container and the friend-list-div or just 1 container would be enough for your use case?


.flink#article-container .friend-list-div > .friend-div a .friend-info,
.flink#article-container .friend-list-div > .friend-div a .friend-name {
Comment on lines +18 to +19
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to assume that some container with class="flink" id="article-container" exists, but the website's template & the shortcode itself does not generate such a container. .friend-list-div also has the same issue. This design would make it hard for the users to use this shortcode correctly. We should create another shortcode that generates the container, which is similar to the nested shortcode here: https://gohugo.io/templates/shortcode-templates/#nested-shortcode-image-gallery.

overflow: hidden;
-o-text-overflow: ellipsis;
text-overflow: ellipsis;
white-space: nowrap;
}

.flink#article-container .friend-list-div {
overflow: auto;
padding: 10px 10px 0;
text-align: center;
}

.flink#article-container .friend-list-div > .friend-div {
position: relative;
float: left;
overflow: hidden;
margin: 15px 7px;
width: calc(100% / 3 - 15px);
height: 90px;
border-radius: 8px;
line-height: 17px;
-webkit-transform: translateZ(0);
}

@media screen and (max-width: 1100px) {
.flink#article-container .friend-list-div > .friend-div {
width: calc(50% - 15px) !important;
}

@media screen and (max-width: 600px) {
.flink#article-container .friend-list-div > .friend-div {
width: calc(100% - 15px) !important;
}
}
}

.flink#article-container .friend-list-div > .friend-div:hover {
background: rgba(87, 142, 224, 0.15);
}

.flink#article-container .friend-list-div > .friend-div:hover img {
-webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg);
-o-transform: rotate(360deg);
-ms-transform: rotate(360deg);
transform: rotate(360deg);
}

.flink#article-container .friend-list-div > .friend-div:before {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: -1;
background: var(--text-bg-hover);
content: "";
-webkit-transition: -webkit-transform 0.3s ease-out;
-moz-transition: -moz-transform 0.3s ease-out;
-o-transition: -o-transform 0.3s ease-out;
-ms-transition: -ms-transform 0.3s ease-out;
transition: transform 0.3s ease-out;
-webkit-transform: scale(0);
-moz-transform: scale(0);
-o-transform: scale(0);
-ms-transform: scale(0);
transform: scale(0);
}

.flink#article-container .friend-list-div > .friend-div:hover:before,
.flink#article-container .friend-list-div > .friend-div:focus:before,
.flink#article-container .friend-list-div > .friend-div:active:before {
-webkit-transform: scale(1);
-moz-transform: scale(1);
-o-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
}

.flink#article-container .friend-list-div > .friend-div a {
color: var(--font-color);
text-decoration: none;
}

.flink#article-container .friend-list-div > .friend-div a img {
float: left;
margin: 15px 10px;
width: 60px;
height: 60px;
border-radius: 35px;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-o-transition: all 0.3s;
-ms-transition: all 0.3s;
transition: all 0.3s;
}

.flink#article-container .friend-list-div > .friend-div a .friend-name {
display: block;
padding: 16px 10px 0 0;
height: 40px;
font-weight: 700;
font-size: 20px;
}

.flink#article-container .friend-list-div > .friend-div a .friend-info {
display: block;
padding: 1px 10px 1px 0;
height: 50px;
font-size: 13px;
}