-
-
Notifications
You must be signed in to change notification settings - Fork 193
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
Add carousel option to the posts #32
Open
Letme
wants to merge
31
commits into
wangchucheng:main
Choose a base branch
from
Letme:add_carousel
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.
Open
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
c4ad535
Add layout changes for including the carousel after the post
Letme acb29d4
Add examples for the carousel changes
Letme 4333e8a
Add carousel also to post single
Letme 3da8b4f
Add arrows images
Letme fabf93a
Change the form of the carousel declaration in FrontMatter
Letme c1e6f71
Use data/assets.toml to define external scripts
Letme c89b1fd
Drop images in favor of the font arrow
Letme 177f161
Update to usage of get-image from utils
Letme 3a07d8f
Use get-image
Letme 39b7b9c
Refactor the images and positions
Letme c18eed8
Set carousel position
Letme 3bc5853
Non working commit: Trying to replace carousel with featuredImage
Letme 9f2cc00
Revert "Set carousel position"
Letme 58424c7
Replace carousel with a featured image
Letme 4b4ec52
Merge branch 'master' of https://github.com/wangchucheng/hugo-eureka …
Letme 6d1b6bf
Merge branch 'master' of https://github.com/wangchucheng/hugo-eureka …
Letme 073aac5
Merge branch 'master' of https://github.com/wangchucheng/hugo-eureka …
Letme 4f0ffba
Split the if
Letme 2ad4640
Merge branch 'master' of https://github.com/wangchucheng/hugo-eureka …
Letme d648de6
Fix the non-working featured image in `/posts/`
Letme aaf64ec
Dropping the added pixles on the side of the image
Letme f83b573
Enable controls (arrows) in the tiny-slider
Letme 036bed5
First carousel image can be a featured image
Letme dc1856e
Merge branch 'master' of https://github.com/wangchucheng/hugo-eureka …
Letme 3fd5bfb
Merge branch 'main' into add_carousel
Letme 6027e2b
Adjust featured to the new print of img style
Letme ebd7053
Remove the duplicate featured image
Letme 4e7bee4
Add the carousel to post-article as it is residing there nowdays
Letme 816a197
Carousel and featured image should not be decided in post-article
Letme c2fd84c
Move carousel to the single layout
Letme 71a3bca
Align doc layout for carousel
Letme 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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
.thumbnails { | ||
margin: 20px 0; | ||
text-align: center; | ||
} | ||
.thumbnails li { | ||
display: inline-block; | ||
cursor: pointer; | ||
border: 5px solid #fff; | ||
} | ||
.thumbnails .tns-nav-active { | ||
background: none; | ||
border-color: #000; | ||
} | ||
.thumbnails li { width: 50px; } | ||
.thumbnails img { vertical-align: bottom; height: auto; max-height: 50px; } | ||
.controls { text-align: center; } | ||
.controls li { | ||
display: block; | ||
position: relative; | ||
height: 60px; | ||
width: 32px; | ||
line-height: 60px; | ||
/* margin-top: calc(-60% - 50px); */ | ||
margin-top: -70px; | ||
padding: 0px 0px; | ||
cursor: pointer; | ||
transition: background 0.3s; | ||
} | ||
.controls li img { display: inline-block; vertical-align: middle; } | ||
.controls .prev { left: 0; } | ||
.controls .next { float: right; | ||
margin-top: -63px;} | ||
.controls li:hover { background: #f2f2f2; } | ||
|
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
+++ | ||
title = "Carousel with image description" | ||
description = "Post with carousel which has image description, but can also omit it " | ||
summary = "" | ||
toc = true | ||
authors = ["Example Author"] | ||
tags = ["image"] | ||
categories = ["themes"] | ||
series = ["Themes Guide"] | ||
date = "2020-05-26" | ||
lastmod = "2020-05-26" | ||
draft = false | ||
|
||
featuredImage = [ | ||
{ image = "carousel1.jpg", description = "Caption of the first image." }, | ||
{ image = "carousel2.jpg", description = "Caption of the second image." }, | ||
{ image = "carousel3.jpg", description = "The next image does not have a caption." }, | ||
{ image = "carousel4.jpg" } | ||
] | ||
+++ | ||
|
||
This post includes a carousel on the end. It is displayed like a gallery and you can | ||
move around the images so that they do not take too much space. Style is at the moment | ||
not configurable, but configuration of the carousel style could be done in the future. | ||
|
||
<!--more--> | ||
|
||
## Example subtitle for carousel | ||
|
||
Aenean vehicula non elit id varius. Mauris condimentum lacinia mollis. Nullam quis cursus metus, eget mattis erat. Aliquam nec ante lacus. In tellus augue, iaculis vitae sollicitudin quis, tempor nec urna. Aenean ut fermentum erat, vel gravida ligula. Etiam sed ex aliquet, egestas nibh eu, iaculis mi. Nunc sit amet fermentum ex. Sed convallis ac arcu tristique rhoncus. Suspendisse potenti. | ||
|
||
Proin justo purus, porttitor et semper ut, commodo et nibh. Nam malesuada id arcu in tempus. Ut ornare vestibulum ultrices. Nullam tempor lectus quis ornare viverra. Vestibulum fringilla turpis ac leo fermentum, et dictum nisi consectetur. Integer ullamcorper fringilla mi, non volutpat sapien ultrices vel. Phasellus at blandit neque, pulvinar rutrum ante. | ||
|
||
Etiam auctor, elit vel pretium consequat, orci magna aliquet dolor, quis varius felis purus ut elit. Sed ultrices feugiat blandit. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Ut accumsan pulvinar purus et ornare. Vestibulum et tortor eget lacus hendrerit porttitor. Cras dapibus ac est posuere mattis. Pellentesque eu ligula ultricies, interdum nulla vel, sollicitudin ligula. Suspendisse sit amet massa sed dui placerat pharetra. Vestibulum massa sem, congue in vehicula vitae, aliquam eu mi. Suspendisse eget laoreet velit. Cras felis enim, molestie in enim nec, mollis venenatis lectus. Donec tincidunt, mi vel interdum varius, urna metus aliquet velit, ut venenatis nulla orci nec lectus. Nam id tortor imperdiet, tempor massa eget, congue nisl. Suspendisse venenatis facilisis orci, non scelerisque risus volutpat sit amet. | ||
|
||
## Example subtitle2 for the carousel | ||
|
||
After this section, you are suppose to see the carousel. | ||
|
||
Aliquam posuere diam non ligula tristique congue. Donec dignissim eu justo sed dictum. Praesent at massa erat. Praesent mollis viverra velit. Aliquam maximus pharetra massa a efficitur. Sed tempus egestas purus sit amet tempor. Donec porttitor varius nisi, eu venenatis risus gravida id. Pellentesque blandit nunc non urna consectetur commodo. Sed at feugiat felis, sit amet malesuada nunc. Curabitur in tempor nisl. Pellentesque accumsan est orci, in commodo felis accumsan facilisis. Nulla maximus suscipit posuere. Nulla et consequat mauris, fermentum ultricies tellus. | ||
|
||
Maecenas consectetur ac libero vitae congue. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec tortor eu lectus placerat varius. Mauris a nisi consectetur, ornare dolor ut, rutrum ligula. Sed enim nisl, fermentum a dictum vel, vestibulum ut odio. Suspendisse laoreet quis urna eu vestibulum. Maecenas commodo augue ex, eu egestas nulla aliquet ut. Cras aliquam dui ipsum, nec sodales erat convallis sit amet. Donec porttitor posuere hendrerit. Sed imperdiet at purus eget tempus. In ac est urna. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
+++ | ||
title = "Carousel with image array" | ||
description = "Post with carousel which does not have description per image" | ||
summary = "" | ||
toc = true | ||
authors = ["Example Author"] | ||
tags = ["image"] | ||
categories = ["themes"] | ||
series = ["Themes Guide"] | ||
date = "2020-05-26" | ||
lastmod = "2020-05-26" | ||
draft = false | ||
|
||
featuredImage = ["carousel1.jpg", "carousel2.jpg", "carousel3.jpg", "carousel4.jpg"] | ||
+++ | ||
|
||
This post includes a carousel without descriptions on the end. It is displayed like a gallery and you can | ||
move around the images so that they do not take too much space. Style is at the moment | ||
not configurable, but configuration of the carousel style could be done in the future. | ||
|
||
<!--more--> | ||
|
||
## Example subtitle for carousel | ||
|
||
Aenean vehicula non elit id varius. Mauris condimentum lacinia mollis. Nullam quis cursus metus, eget mattis erat. Aliquam nec ante lacus. In tellus augue, iaculis vitae sollicitudin quis, tempor nec urna. Aenean ut fermentum erat, vel gravida ligula. Etiam sed ex aliquet, egestas nibh eu, iaculis mi. Nunc sit amet fermentum ex. Sed convallis ac arcu tristique rhoncus. Suspendisse potenti. | ||
|
||
Proin justo purus, porttitor et semper ut, commodo et nibh. Nam malesuada id arcu in tempus. Ut ornare vestibulum ultrices. Nullam tempor lectus quis ornare viverra. Vestibulum fringilla turpis ac leo fermentum, et dictum nisi consectetur. Integer ullamcorper fringilla mi, non volutpat sapien ultrices vel. Phasellus at blandit neque, pulvinar rutrum ante. | ||
|
||
Etiam auctor, elit vel pretium consequat, orci magna aliquet dolor, quis varius felis purus ut elit. Sed ultrices feugiat blandit. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Ut accumsan pulvinar purus et ornare. Vestibulum et tortor eget lacus hendrerit porttitor. Cras dapibus ac est posuere mattis. Pellentesque eu ligula ultricies, interdum nulla vel, sollicitudin ligula. Suspendisse sit amet massa sed dui placerat pharetra. Vestibulum massa sem, congue in vehicula vitae, aliquam eu mi. Suspendisse eget laoreet velit. Cras felis enim, molestie in enim nec, mollis venenatis lectus. Donec tincidunt, mi vel interdum varius, urna metus aliquet velit, ut venenatis nulla orci nec lectus. Nam id tortor imperdiet, tempor massa eget, congue nisl. Suspendisse venenatis facilisis orci, non scelerisque risus volutpat sit amet. | ||
|
||
## Example subtitle2 for the carousel | ||
|
||
After this section, you are suppose to see the carousel. | ||
|
||
Aliquam posuere diam non ligula tristique congue. Donec dignissim eu justo sed dictum. Praesent at massa erat. Praesent mollis viverra velit. Aliquam maximus pharetra massa a efficitur. Sed tempus egestas purus sit amet tempor. Donec porttitor varius nisi, eu venenatis risus gravida id. Pellentesque blandit nunc non urna consectetur commodo. Sed at feugiat felis, sit amet malesuada nunc. Curabitur in tempor nisl. Pellentesque accumsan est orci, in commodo felis accumsan facilisis. Nulla maximus suscipit posuere. Nulla et consequat mauris, fermentum ultricies tellus. | ||
|
||
Maecenas consectetur ac libero vitae congue. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec tortor eu lectus placerat varius. Mauris a nisi consectetur, ornare dolor ut, rutrum ligula. Sed enim nisl, fermentum a dictum vel, vestibulum ut odio. Suspendisse laoreet quis urna eu vestibulum. Maecenas commodo augue ex, eu egestas nulla aliquet ut. Cras aliquam dui ipsum, nec sodales erat convallis sit amet. Donec porttitor posuere hendrerit. Sed imperdiet at purus eget tempus. In ac est urna. |
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<section> | ||
<div id="tinyslider-carousel" class="w-full"> | ||
{{ range .Params.featuredimage }} | ||
<div class="item"> | ||
<div> | ||
{{ if reflect.IsMap . }} | ||
{{ $image := partial "utils/get-image" (dict "context" $ "url" .image "keyword" .image) }} | ||
<img class="img-responsive" src="{{ $image }}" alt="{{ .description }}" /> | ||
</div> | ||
{{ if .description }} | ||
<p>{{ .description }}</p> | ||
{{ end }} | ||
{{ else }} | ||
{{ $image := partial "utils/get-image" (dict "context" $ "url" . "keyword" .) }} | ||
<img class="img-responsive" src="{{ $image }}" /> | ||
</div> | ||
{{ end }} | ||
</div> | ||
{{ end }} | ||
</div> | ||
<div class="tinyslider-controls"> | ||
<ul class="thumbnails" id="customize-thumbnails"> | ||
{{ range .Params.featuredimage }} | ||
<li class="item"> | ||
{{ if reflect.IsMap . }} | ||
{{ $image := partial "utils/get-image" (dict "context" $ "url" .image "keyword" .image) }} | ||
<img class="img-responsive" src="{{ $image }}" alt="{{ .description }}" width="50px" /> | ||
{{ else }} | ||
{{ $image := partial "utils/get-image" (dict "context" $ "url" . "keyword" .) }} | ||
<img class="img-responsive" src="{{ $image }}" width="50px" /> | ||
{{ end }} | ||
</li> | ||
{{ end }} | ||
</ul> | ||
<ul class="controls" id="customize-controls"> | ||
<li class="prev"><i class="fas fa-angle-left"></i></li> | ||
<li class="next"><i class="fas fa-angle-right"></i></li> | ||
</ul> | ||
</div> | ||
<script src="{{ printf .Site.Data.assets.tinyslider.js.url .Site.Data.assets.tinyslider.version }}"></script> | ||
<script> const slider = tns({ | ||
container: '#tinyslider-carousel', | ||
items: 1, | ||
autoplay: false, | ||
center: true, | ||
controls: true, | ||
nav: true, | ||
navContainer: "#customize-thumbnails", | ||
controlsContainer: "#customize-controls", | ||
navAsThumbnails: true, | ||
autoWidth: true, | ||
autoHeight: true, | ||
}); | ||
</script> | ||
|
||
</section> |
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 |
---|---|---|
|
@@ -9,4 +9,5 @@ <h1 class="mb-4">{{ .Title }}</h1> | |
{{ end }} | ||
|
||
{{ .Content }} | ||
|
||
</article> |
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
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{{ $image := "" }} | ||
{{ if .Params.featuredvideo }} | ||
{{ partial "utils/get-video" (dict "context" . "url" .Params.featuredvideo "keyword" "*featured*") }} | ||
{{ else if .Params.featuredimage }} | ||
{{ if and (reflect.IsSlice .Params.featuredimage) (gt (len .Params.featuredimage) 1) }} | ||
{{ partial "components/carousel" . }} | ||
{{ else if reflect.IsSlice .Params.featuredimage }} | ||
{{ $image = partial "utils/get-image" (dict "context" . "url" (first 1 .Params.featuredimage) "keyword" "*featured*") }} | ||
{{ else }} | ||
{{ $image = partial "utils/get-image" (dict "context" . "url" .Params.featuredimage "keyword" "*featured*") }} | ||
{{ end }} | ||
{{ if $image }} | ||
<img src="{{ $image }}" class="w-full" alt="Featured Image"> | ||
{{ end }} | ||
{{ end }} |
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 have added this get-image function calls (3a07d8f), yet the URL it produces is wrong as images are in public/posts yet this function resolves it to root .
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.
As we discussed before, there is a mistake in organizing images in content folder. You can create a folder named
carousel
in this case and renamecarousel.md
toindex.md
and move it to carousel folder along with those images. And images will be inlocalhost:1313/posts/carousel/carousel1.jpg
for example. The front matter should becarousel1.jpg
for example. Please note that the images you uploaded isjpg
, but the filename you entered ispng
.This is called Leaf Bundles in Hugo.
And if you have done that,
get-image
should give you a correct result as I tested it in my machine.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.
Done this in 39b7b9c .