Skip to content

Commit

Permalink
feat: add the profile sidebar module (#379)
Browse files Browse the repository at this point in the history
  • Loading branch information
razonyang committed Oct 8, 2023
1 parent ab1d818 commit db3f67c
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.hb-blog-sidebar-profile-img {
height: #{$hb-blog-sidebar-profile-avatar-size}px;
width: #{$hb-blog-sidebar-profile-avatar-size}px;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{{- $params := site.Params.hb.blog.sidebar.profile }}
$hb-blog-sidebar-profile-avatar-size: {{ default 100 $params.avatar_size }};
3 changes: 3 additions & 0 deletions modules/sidebar/profile/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/hbstack/blog/modules/sidebar/profile

go 1.19
20 changes: 20 additions & 0 deletions modules/sidebar/profile/hugo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[[module.imports]]
path = "github.com/hbstack/blog"

[[module.imports]]
path = "github.com/hbstack/socials"

[[module.imports]]
path = "github.com/hugomods/icons/vendors/bootstrap"

[params.hugopress.modules.hb-blog-sidebar-profile.hooks.hb-blog-sidebar]
cacheable = true
weight = 1

[params.hb.blog.sidebar.profile]
avatar = "/images/logo.png"
avatar_size = 100
title = "" # default to site title.
description = "" # default to site description.
company = ""
location = ""
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{{- with site.Params.hb.blog.sidebar.profile }}
<div
class="hb-blog-sidebar-profile hb-module mb-3 d-flex flex-column justify-content-center align-items-center">
{{- $avatarSize := default 100 .avatar_size }}
{{- with .avatar }}
{{ partial "images/image" (dict
"Filename" (printf "%s?height=%d&width=%d" . $avatarSize)
"ClassName" "hb-blog-sidebar-profile-img rounded-circle img-fluid mb-3")
}}
{{- end }}
<p class="hb-blog-sidebar-profile-title h5 mb-3">
{{ default site.Title .title | markdownify }}
</p>
<p class="hb-blog-sidebar-profile-desc text-center mb-2">
{{ default site.Params.description .description | markdownify }}
</p>
<p class="hb-blog-sidebar-profile-meta mb-1">
{{- with .company }}
<span class="mx-1">
{{- partial "icons/icon" (dict "vendor" "bootstrap" "name" "building" "className" "me-1") -}}
{{- . | markdownify -}}
</span>
{{- end }}
{{- with .location }}
<span class="mx-1">
{{- partial "icons/icon" (dict "vendor" "bootstrap" "name" "geo-alt" "className" "me-1") -}}
{{- . | markdownify -}}
</span>
{{- end }}
</p>
{{- with .socials }}
{{- $color := default true ._color }}
<div class="hb-footer-socials d-flex mb-2 justify-content-center">
{{- range $name, $id := . }}
{{/* ignore options. */}}
{{- if hasPrefix $name "_" }}
{{- continue }}
{{- end }}
{{- $ctx := dict
"id" $id
"name" $name
"class" "p-2"
"width" "1.75em"
"height" "1.75em"
"color" $color
}}
{{ partial "hb/modules/socials/link" $ctx }}
{{- end }}
</div>
{{- end }}
</div>
{{- end }}
3 changes: 3 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
"modules/sidebar/posts": {
"component": "modules/sidebar/posts"
},
"modules/sidebar/profile": {
"component": "modules/sidebar/profile"
},
"modules/sidebar/taxonomies": {
"component": "modules/sidebar/taxonomies"
},
Expand Down

0 comments on commit db3f67c

Please sign in to comment.