biaslab / hugo-academic-group

An academic group website theme for Hugo.
MIT License
52 stars 18 forks source link

can publications be displayed automatically in the member page? #56

Closed pzhaonet closed 3 years ago

pzhaonet commented 3 years ago

This is an amazing theme. Thanks! I am using this theme for building a website for my research group. It is only one step from perfection: can publications be displayed automatically on the member page?

I found that the projects appear automatically on the member page (member/xxx), and tried adding the following codes into https://github.com/biaslab/hugo-academic-group/tree/master/layouts/member/single.html#L115 but I failed:

           {{ .Scratch.Add "found" false }}
            {{ $member_id:= .Params.id }}
            {{ $publications:= where .Site.Pages "Section" "publication" }}
            {{ range $publications }}
                {{ $current_project := . }}
                {{ range .Params.authors }}
                    {{ if eq .id $member_id }}
                    {{ if not ($.Scratch.Get "found") }}
                        <div class="row">
                        <div class="col-sm-12">
                            <h3>Publications</h3>
                            <ul>
                        {{ $.Scratch.Set "found" true }}
                    {{ end }}
                    <li>
                        <a href="{{$current_publication.Permalink}}">{{ $current_publication.Title }}</a>
                    </li>
                    {{ end }}
                {{ end }}
            {{ end }}
            {{ if (.Scratch.Get "found") }}
                </ul>
                </div>
            </div>
            {{ end }}
            {{ .Scratch.Delete "found" }}

Sorry that I have little knowledge in these codes.

ivan-bocharov commented 3 years ago

Hi @pzhaonet! Thanks a lot for your kind words. I am glad that you enjoy working with the theme.

The code snippet that you have submitted is actually very close to displaying a publication list in a member profile. hugo was giving an error because of a wrong assignment on line 5 ({{ $current_project := . }}). If you replace it with {{ $current_project := . }} the code will generate a list of member's publications.

However, if a member has more than 4-5 publications, the list becomes prohibitively long and the page doesn't look good anymore. We've been thinking about adding a list of "selected" publications to user's page, but haven't implemented it yet. If you feel that publication lists are not too long in your case, you could use the code that you've written. Otherwise I suggest that you simply add a section with selected publications to member's biography in markdown source file.

pzhaonet commented 3 years ago

Hi @ivan-bocharov. Thank you so much for your kind reply! It is awesome!

haz commented 3 years ago

Hey both. Just wanted to highlight the work-around we just put in: https://github.com/QuMuLab/hugo-academic-group/commit/cdbf67595698bde13bc143168919c98752150a70

Lines 125-133 are more verbose than I'd like, but if you check the support forum I link to there, you'll see that there aren't a lot of options.

Lists the publication section only if relevant (like projects), and caps it at 5. I'll be putting together a separate (non-hugo) page for all publications using bibbase (so you can click and see all by an author, get the bibtex, etc).