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

Change from "aka" field to "guest_group" field for multi-guest #159

Closed
mattstratton opened this issue Mar 7, 2018 · 4 comments · Fixed by #271
Closed

Change from "aka" field to "guest_group" field for multi-guest #159

mattstratton opened this issue Mar 7, 2018 · 4 comments · Fixed by #271

Comments

@mattstratton
Copy link
Owner

If there are multiple guests, they should all have a matching guest_group field, which ties them together.

This is an optional field and only used if you have multiple versions of a guest.

@mattstratton mattstratton self-assigned this Mar 7, 2018
@mattstratton mattstratton added this to the Sprint 1 milestone Mar 7, 2018
@mattstratton
Copy link
Owner Author

Make sure to update the REFERENCE file with this.

@mattstratton
Copy link
Owner Author

I think that for #137, the way this will be handled is like this:

we have the part where it selects all the guests:

{{ $paginator := .Paginate (where .Data.Pages.ByTitle "Type" "guest") }}
    {{ range $paginator.Pages }}

now what we would do is check to see if guest_group is set:

{{- if and (isset .Params "guest_group") (ne .Params.guest_group "") -}}

then inside here we will do another range to return all the guests in that group, sorted by date, but returning only the most recent one

{{ range first 1 (where .Data.Pages. "Type" "in" site.Params.mainSections).ByDate.Reverse }}

NOTE: actually maybe something like this:

<!-- Groups content according to the "param_key" field in front matter -->
{{ range .Pages.GroupByParam "param_key" }}
<h3>{{ .Key }}</h3>
<ul>
    {{ range .Pages }}
    <li>
    <a href="{{ .Permalink }}">{{ .Title }}</a>
    <div class="meta">{{ .Date.Format "Mon, Jan 2, 2006" }}</div>
    </li>
    {{ end }}
</ul>
{{ end }}

what I don't know happens is if the range in the .GroupByParam does not HAVE that parameter. So I mean, it would ideally look like this maybe?

{{ $paginator := .Paginate (where .Data.Pages.ByTitle "Type" "guest") }}
    {{ range $paginator.Pages.GroupByParam "guest_group" }}
		{{ range first 1 .Pages.ByDate.Reverse }}
			// display guest nonsense
		{{ end }}
	{{ end }}
{{ end }}

then, in guest/single.html

{{- if and (isset .Params "guest_group") (ne .Params.guest_group "") -}}
	// do something to get all the guests in the guest group
	// note: might need to put .Params "guest_group" into a Scratch for use in the next query
	{{ range where .Site.Pages "Params.guest_group" (.Params "guest_group") }}
	
		// shove all those guest names into an array (using Scratch probably)
		{{ .Scratch.Add "guest-names" (slice .File.BaseFileName) }}
	{{ end }}
	// step through the array and list every episode for each of those guests
{{- else -}}
	{{ $.Scratch.Add "guest-names" (slice .File.BaseFileName) }}
{{ end }}

{{ range $name := $.Scratch.Get "guest-names") }}
	{{- $.Scratch.Set "guest-name" $name -}}
		{{- range $page := where $.Site.Pages "Type" "episode" -}}
			{{- range $page.Params.guests -}}
				{{- if eq  . ($.Scratch.Get "guest-name") -}}
					<a href = "{{$page.Permalink}}" class = "guest_page_episode_link list-group-item list-group-item-action">{{$page.Title}}</a>
				{{- end -}}
			{{- end -}}
		{{- end -}}
	{{- end -}}
{{- end -}}

@mattstratton
Copy link
Owner Author

One thing that isn't handled is backward-compatibility with "aka"...I don't think we need to do it for guest/list.html, but we do need it for guest/single.html (maybe? I don't know if anyone is really using aka anyway)

If we wanted to be fancy though, it would look like this:

{{- else -}}
	{{- with .Params.Aka -}}
    	{{ range $name := . }}
			{{ .Scratch.Add "guest-names" (slice .File.BaseFileName) }}
		{{- end -}}	
	{{- end -}}
	{{ $.Scratch.Add "guest-names" (slice .File.BaseFileName) }}
{{ end }}

that's not super elegant, since aka using guests will end up duplicated in the slice, but I think that it just adds a little bit of overhead and won't end up with duplication, etc

@mattstratton
Copy link
Owner Author

ooh. it might be more elegant to do this:

{{- with .Params.guest_group -}}
	{{- range where .Site.Pages "Params.guest_group" . -}}
		{{- .Scratch.Add "guest-names" (slice .File.BaseFileName) -}}
	{{- end -}}
{{- end -}}

{{- with .Params.Aka -}}
	{{- range $name := . -}}
		{{- $.Scratch.Set "guest-names" (slice $name) -}}
	{{- end - }}
{{- end -}}
{{ $.Scratch.Add "guest-names" (slice .File.BaseFileName) }}

mattstratton added a commit that referenced this issue Apr 23, 2020
mattstratton added a commit that referenced this issue Apr 23, 2020
* Fix typo in REFERENCE

* Update REFERENCE with guest_group

* Add support for grouping guests on guest list page

Fixes #137

* Add support for guest_group to guest pages

Fixes #159

* Fix AKA bug

Signed-off-by: Matt Stratton <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant