Repository navigation
Link calendar entries back to their user group #526
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2bea6c8
Link calendar entries back to their user group
HeyItsGilbert e765ced
Regenerate purged Tailwind CSS for calendar badge classes
HeyItsGilbert e18ad5f
Pin calendar badge logo to 20x20 with native width/height attrs
HeyItsGilbert f94ff29
Address review feedback
HeyItsGilbert a91f5a3
Address second round of review feedback
HeyItsGilbert 0298ba5
Scope case-insensitive matching to host; require real locale convention
HeyItsGilbert 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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,41 @@ | ||
| # Calendar entries link back to their user group by matching the Meetup URL host at render time, not an explicit stored field | ||
|
|
||
| Calendar entries (`content/calendar/meetup-*.md`) are generated by | ||
| `.github/scripts/sync-meetup-events.mjs` from each user group's | ||
| `links[].url` on `meetup.com`; manual entries like | ||
| `ohio-powershell-user-group.md` also happen to carry a `meetup.com` | ||
| `externalUrl`. To show a group's logo/name badge on the calendar page and | ||
| link it back to `/user-groups/<slug>/`, the template | ||
| (`themes/powershell-community/layouts/_default/calendar.html`) matches each | ||
| entry's `externalUrl` host against every user group's `links[].url` host at | ||
| render time, rather than the sync script stamping a `userGroup: <slug>` | ||
| field into generated frontmatter. | ||
|
|
||
| ## Considered options | ||
|
|
||
| - **Explicit `userGroup` field, written by the sync script** — rejected (for | ||
| now). More "obviously correct" in the abstract, but the script currently | ||
| discards the per-group URL once it flattens all groups' Meetup slugs into | ||
| one set (`groups()` in `sync-meetup-events.mjs`), so this would mean | ||
| threading that mapping through, resyncing/backfilling the 13 existing | ||
| generated entries, and still leaving manual entries unmatched unless an | ||
| author remembers to set the field by hand. | ||
| - **Runtime match on Meetup URL host** — chosen. The join key (the Meetup | ||
| group slug embedded in both the calendar entry's `externalUrl` and the | ||
| user group's `links[].url`) is already 100% reliable across every existing | ||
| entry, synced or manual, with no script change and no backfill. It also | ||
| means Ohio's hand-authored entry matches for free, since its | ||
| `externalUrl` happens to be a `meetup.com` link too. | ||
|
|
||
| ## Consequences | ||
|
|
||
| - Linking is **implicitly scoped to Meetup-sourced events.** A future | ||
| non-Meetup user-group event (e.g. Eventbrite) will render with no group | ||
| badge unless this matching logic is extended to other hosts, or unless we | ||
| revisit this decision in favor of an explicit field. | ||
| - The match is **deliberately on URL host, not on a link's declared `icon` or | ||
| `name`.** A user group that mislabels its Meetup link's icon still matches | ||
| correctly, because the template never looks at it. | ||
| - The calendar template now has to enumerate `/user-groups/` pages per | ||
| rendered event to find a match. This is a cheap, build-time cost (list | ||
| sizes are small), not a runtime one — Hugo is a static site generator. |
This file contains hidden or 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 hidden or 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 hidden or 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
37 changes: 37 additions & 0 deletions
37
themes/powershell-community/layouts/partials/calendar-matched-user-group.html
This file contains hidden or 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 @@ | ||
| {{/* | ||
| Resolves a calendar entry's Meetup externalUrl to the user group that owns | ||
| it, by matching the Meetup group slug embedded in the calendar entry's URL | ||
| against the slug embedded in each user group's `links[].url`. See | ||
| docs/adr/0006-calendar-user-group-linking.md for why this is a runtime | ||
| match rather than a stored field. | ||
|
|
||
| @param .externalUrl string: the calendar entry's `externalUrl` param | ||
| @param .site Site: the site context, for GetPage | ||
| @returns Page|string: the matched user-group page, or "" if none | ||
| */}} | ||
| {{- $url := .externalUrl -}} | ||
| {{- $site := .site -}} | ||
| {{- /* Case-insensitive on scheme+host only: a locale prefix is only | ||
| recognized in Meetup's own convention (lowercase language, UPPERCASE | ||
| region, e.g. "de-DE") so it isn't confused with a lowercase two-letter- | ||
| pair group slug like "ps-ug". */ -}} | ||
| {{- $slugPattern := `^(?i:https?://(?:www\.)?meetup\.com)/(?:[a-z]{2}-[A-Z]{2}/)?([^/?#]+).*$` -}} | ||
| {{- $match := "" -}} | ||
| {{- if $url -}} | ||
| {{- $eventSlug := replaceRE $slugPattern "$1" $url -}} | ||
| {{- if ne $eventSlug $url -}} | ||
| {{- $groupsPage := $site.GetPage "/user-groups" -}} | ||
| {{- if $groupsPage -}} | ||
| {{- range $groupsPage.Pages -}} | ||
| {{- $group := . -}} | ||
| {{- range .Params.links -}} | ||
| {{- $linkSlug := replaceRE $slugPattern "$1" .url -}} | ||
| {{- if and (ne $linkSlug .url) (eq (lower $linkSlug) (lower $eventSlug)) -}} | ||
| {{- $match = $group -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
| {{- return $match -}} |
16 changes: 16 additions & 0 deletions
16
themes/powershell-community/layouts/partials/calendar-user-group-badge.html
This file contains hidden or 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,16 @@ | ||
| {{/* | ||
| Renders a small logo/icon + name badge linking to a user group's page. | ||
|
|
||
| @param . Page: the user-group page to render a badge for | ||
| */}} | ||
| {{- $group := . -}} | ||
| <a href="{{ $group.RelPermalink }}" class="inline-flex items-center gap-1.5 text-blue-600 hover:text-blue-700 underline"> | ||
| <span class="inline-flex items-center justify-center w-5 h-5 rounded-full bg-blue-100 overflow-hidden flex-shrink-0"> | ||
| {{ if $group.Params.logo }} | ||
| <img src="{{ $group.Params.logo }}" alt="" width="20" height="20" class="w-full h-full object-contain"> | ||
| {{ else }} | ||
| <i class="fas fa-people-group text-xs" aria-hidden="true"></i> | ||
| {{ end }} | ||
| </span> | ||
| {{ $group.Title }} | ||
| </a> |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.