HugoBlox / hugo-blox-builder

🚨 GROW YOUR AUDIENCE WITH HUGOBLOX! 🚀 HugoBlox is an easy, fast no-code website builder for researchers, entrepreneurs, data scientists, and developers. Build stunning sites in minutes. 适合研究人员、企业家、数据科学家和开发者的简单快速无代码网站构建器。用拖放功能、可定制模板和内置SEO工具快速创建精美网站!
https://hugoblox.com/templates/
MIT License
8.2k stars 2.9k forks source link

feat: support adding widgets to author pages #1559

Closed UtkarshVerma closed 3 years ago

UtkarshVerma commented 4 years ago

I was wondering if it would be possible to use widgets on author pages like it's possible on section pages. The thing is that I need to create a team website where each member should get one page, with widgets.

gcushen commented 4 years ago

The author page is currently only compatible with the About widget.

Due to the way Hugo handles page bundles, it may require some changes on Hugo side to enable any widget to be used on author pages.

In the meantime, a number of users have had success with creating a Widget Page for each author (on a widget page, you can add whatever widgets you desire) and linking to each author's widget page from their author page or from a widget on the homepage, for example. See https://sourcethemes.com/academic/docs/managing-content/#create-a-widget-page

gcushen commented 4 years ago

It appears that the Hugo limitation blocking this feature being implemented may be resolved in the recent Hugo v0.56 release which standardises page bundles, apparently removing limitations on author pages.

laurentperrinet commented 4 years ago

Would you recommend to wait until this feature is implemented in academic instead of moving to your other suggestion (a Widget Page for each author) ?

UtkarshVerma commented 4 years ago

@gcushen Because I wanted to try out Foundation, I ended up creating a new theme in which I've implemented this feature and it seems to work pretty well. Check it here. These are the concerned filed:

// layouts/author.html
{{ define "main" }}
{{ $page := . }}

<div class="cell align-center grid-x grid-margin-x">
    <div class="author-profile cell medium-12 large-4 grid-y">
        {{ $avatar := (.Resources.ByType "image").GetMatch "*avatar*" }}
        {{ if and site.Params.avatar.gravatar .Params.email }}
        <img class="avatar cell thumbnail align-self-middle" src="https://s.gravatar.com/avatar/{{ md5 .Params.email }}?s=200')" alt="{{ .Title }}">
        {{ else if $avatar }}
        {{ $avatar_image := $avatar.Fill "270x270 Center" }}
        <img class="avatar cell thumbnail align-self-middle" src="{{ $avatar_image.RelPermalink }}" alt="{{ .Title }}">
        {{ end }}
        <div class="cell">
            <h3 class="name text-center">{{ .Title }}</h3>
            <h4 class="role subheader text-center">{{ .Params.role }}</h4>
        </div>
        {{ partial "author/social" . }}
    </div>
    {{ with .Content }}
    <div class="author-bio cell medium-12 large-8 grid-y">
        <h1>Biography</h1>
        {{ . | emojify }}
    </div>
    {{ end }}
</div>

{{ range $i, $widget := where .Params.widgets ".active" "!=" false }}
    {{ $widget_path := printf "widgets/%s.html" $widget.name }}
    <hr>
    {{ $ctx := dict "widget" $widget "root" $ }}
    {{ partial $widget_path $ctx }}
{{ end }}
{{ end }}

The widgets are configured through taxonomy frontmatter.

title: .....
...
widgets:
  - name: pages
     .....
     .....

I hope this helps.

gcushen commented 3 years ago

Closing due to little demand and the discussion going stale with no contributions. May re-open after Widget Pages v2 #2049 is implemented.