Skip to content

Commit

Permalink
Upgrade Hugo to 0.141.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ibrahimjaved12 committed Feb 13, 2025
1 parent f3b09a5 commit f997686
Show file tree
Hide file tree
Showing 13 changed files with 90 additions and 80 deletions.
4 changes: 2 additions & 2 deletions base-theme/layouts/partials/featured_course_cards.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ <h2 class="{{ $klass }}">Featured Courses</h2>
{{ range $index, $courseItem := $courses }}
{{- $urlPath := partial "site_root_url.html" $courseItem.id -}}
{{- $url := delimit (slice (strings.TrimSuffix "/" $staticApiBaseUrl) $urlPath "/data.json") "" -}}
{{ with resources.GetRemote $url }}
{{ with try (resources.GetRemote $url) }}
{{ with .Err }}
{{ errorf "Failed to fetch featured course info from %v with error %v" $url . }}
{{ else }}
{{ else with .Value }}
{{- $courseData := . | unmarshal -}}
{{ partial "course_carousel_card.html" (dict "itemsInCarousel" $itemsInCarousel "courseData" $courseData "index" $index "urlPath" $urlPath "numCourses" (len $courses))}}
{{ end }}
Expand Down
6 changes: 4 additions & 2 deletions base-theme/layouts/partials/get_instructors.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
{{ range . }}
{{ $staticApiBaseUrl := getenv "STATIC_API_BASE_URL" }}
{{ $url := (print (strings.TrimSuffix "/" $staticApiBaseUrl) "/instructors/" . "/index.json") }}
{{ with resources.GetRemote $url }}
{{ with try (resources.GetRemote $url) }}
{{ with .Err }}
{{ errorf "Failed to fetch instructors from %v with error %v" $url . }}
{{ else }}
{{ else with .Value }}
{{ $data := (. | unmarshal).data }}
{{ $searchUrl := partial "get_search_url.html" (dict "key" "instructors" "value" (title $data.title)) }}
{{ $instructor := merge $data (dict "url" $searchUrl) }}
{{ $instructors = $instructors | append $instructor }}
{{ else }}
{{ errorf "Failed to fetch instructors from %v" $url }}
{{ end }}
{{ else }}
{{ errorf "Failed to fetch instructors from %v" $url }}
Expand Down
4 changes: 2 additions & 2 deletions base-theme/layouts/partials/get_site_metadata.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{{ $courseData := slice }}
{{ $staticApiBaseUrl := getenv "STATIC_API_BASE_URL" }}
{{ $url := (print (strings.TrimSuffix "/" $staticApiBaseUrl) "/" . "/data.json") }}
{{ with resources.GetRemote $url }}
{{ with try (resources.GetRemote $url) }}
{{ with .Err }}
{{ errorf "Failed to fetch course data from %v with error %v" $url . }}
{{ else }}
{{ else with .Value }}
{{ $courseData = unmarshal . }}
{{ end }}
{{ else }}
Expand Down
10 changes: 5 additions & 5 deletions fields/layouts/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ <h1>
{{- range (first 5 $subfield.Params.courses) -}}
{{- $id := .id -}}
{{- $url := delimit (slice (strings.TrimSuffix "/" $staticApiBaseUrl) "/" $id "/data.json") "" -}}
{{ with resources.GetRemote $url }}
{{ with try (resources.GetRemote $url) }}
{{ with .Err }}
{{- $errorMessage := printf "Failed to fetch sub-fields on %v via %v with error: %v" site.BaseURL $url . -}}
{{- partial "sentry_capture_message.html" $errorMessage -}}
{{ else }}
{{- partial "sentry_capture_message.html" $errorMessage -}}
{{ else with .Value }}
{{- $data := . | unmarshal -}}
{{- $data = merge $data (dict "url_path" $id) -}}
{{- $subfield_data = $subfield_data | append (dict $id $data) -}}
{{- $data = merge $data (dict "url_path" $id) -}}
{{- $subfield_data = $subfield_data | append (dict $id $data) -}}
{{ end }}
{{ else }}
{{ $errorMessage := printf "Failed to fetch sub-fields through %v on %v" $url site.BaseURL }}
Expand Down
4 changes: 2 additions & 2 deletions fields/layouts/subfields/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
{{- range $courselist.Params.courses -}}
{{- $id := .id -}}
{{- $url := delimit (slice (strings.TrimSuffix "/" $staticApiBaseUrl) "/" .id "/data.json") "" -}}
{{ with resources.GetRemote $url }}
{{ with try (resources.GetRemote $url) }}
{{ with .Err }}
{{- $errorMessage := printf "Failed to fetch sub-field on %v via %v with error: %v" site.BaseURL $url . -}}
{{- partial "sentry_capture_message.html" $errorMessage -}}
{{ else }}
{{ else with .Value }}
{{- $data := . | unmarshal -}}
{{- $data = merge $data (dict "url_path" $id) -}}
{{- $courseListData = $courseListData | append (dict $id $data) -}}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
"eslint-plugin-react-hooks": "^4.6.0",
"exec-sh": "^0.4.0",
"file-loader": "^5.0.2",
"hugo-bin-extended": "^0.139.0",
"hugo-bin-extended": "^0.141.0",
"imports-loader": "^0.8.0",
"inquirer": "^12.0.0",
"jest": "^27.4.7",
Expand Down
4 changes: 2 additions & 2 deletions www/layouts/collections/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ <h1>
{{- range (first 5 $course_list.Params.courses) -}}
{{- $id := .id -}}
{{- $url := delimit (slice (strings.TrimSuffix "/" $staticApiBaseUrl) "/" $id "/data.json") "" -}}
{{ with resources.GetRemote $url }}
{{ with try (resources.GetRemote $url) }}
{{ with .Err }}
{{- $errorMessage := printf "Failed to fetch collections on %v via %v with error: %v" site.BaseURL $url . -}}
{{- partial "sentry_capture_message.html" $errorMessage -}}
{{ else }}
{{ else with .Value }}
{{- $data := . | unmarshal -}}
{{- $data = merge $data (dict "url_path" $id) -}}
{{- $course_list_data = $course_list_data | append (dict $id $data) -}}
Expand Down
6 changes: 3 additions & 3 deletions www/layouts/course-lists/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
{{- range $courselist.Params.courses -}}
{{- $id := .id -}}
{{- $url := delimit (slice (strings.TrimSuffix "/" $staticApiBaseUrl) "/" $id "/data.json") "" -}}
{{ with resources.GetRemote $url }}
{{ with try (resources.GetRemote $url) }}
{{ with .Err }}
{{- $errorMessage := printf "Something went wrong while fetching course list on %v via %v with error: %v" site.BaseURL $url . -}}
{{- partial "sentry_capture_message.html" $errorMessage -}}
{{ else }}
{{ else with .Value }}
{{- $data := . | unmarshal -}}
{{- $data = merge $data (dict "url_path" $id) -}}
{{- $courseListData = $courseListData | append (dict $id $data) -}}
Expand All @@ -35,4 +35,4 @@
window.courseListsData = JSON.parse("{{ $courseListsData | jsonify }}");
</script>
</div>
{{ end }}
{{ end }}
70 changes: 36 additions & 34 deletions www/layouts/partials/new_course_cards.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,48 @@
{{ $courseStarterSlug := getenv "OCW_COURSE_STARTER_SLUG" }}
{{ $coursesQuery := querify "type" $courseStarterSlug "limit" 12 }}
{{ $coursesURL := (print (strings.TrimSuffix "/" $studioBaseUrl) "/api/websites/?" $coursesQuery) }}
{{ with resources.GetRemote $coursesURL }}
{{ with try (resources.GetRemote $coursesURL) }}
{{ if not .Err }}
{{ $results := (. | unmarshal).results }}
{{ if $results }}
{{ $breakdowns := (dict "xs-sm" (dict "size" 1 "class" "d-flex d-md-none") "md" (dict "size" 2 "class" "d-none d-md-flex d-lg-none") "lg" (dict "size" 3 "class" "d-none d-lg-flex d-xl-none") "xl" (dict "size" 4 "class" "d-none d-xl-flex")) }}
<!-- list adapted from https://getbootstrap.com/docs/4.0/utilities/display/#hiding-elements -->
{{ range $breakpoint, $carouselInfo := $breakdowns }}
{{ $itemsInCarousel := index $carouselInfo "size" }}
{{ $breakpointVisibilityClass := index $carouselInfo "class" }}
{{ $isMobile := (eq $itemsInCarousel 1) }}
{{ $carouselId := (printf "new-course-carousel-%v" $breakpoint) }}
<div class="{{ $breakpointVisibilityClass }}">
<div id="{{ $carouselId }}" class="carousel slide" data-interval="false" data-touch="true" data-ride="carousel">
<div class="carousel-header d-flex flex-row justify-content-between font-weight-bold">
<h2>New Courses</h2>
{{ partial "carousel_controls.html" $carouselId }}
</div>
<div class="carousel-inner d-flex {{ if not $isMobile }}container{{ end }} mt-2 px-0">
{{ $resultsSlice := first 12 $results }}
{{ range $index, $courseItem := $resultsSlice }}
{{- if $courseItem.url_path -}}
{{- $url := delimit (slice (strings.TrimSuffix "/" $staticApiBaseUrl) "/" $courseItem.url_path "/data.json") "" -}}
{{ with resources.GetRemote $url }}
{{ with .Err }}
{{ errorf "Failed to fetch new course info from %v with error %v" $url . }}
{{ with .Value }}
{{ $results := (. | unmarshal).results }}
{{ if $results }}
{{ $breakdowns := (dict "xs-sm" (dict "size" 1 "class" "d-flex d-md-none") "md" (dict "size" 2 "class" "d-none d-md-flex d-lg-none") "lg" (dict "size" 3 "class" "d-none d-lg-flex d-xl-none") "xl" (dict "size" 4 "class" "d-none d-xl-flex")) }}
<!-- list adapted from https://getbootstrap.com/docs/4.0/utilities/display/#hiding-elements -->
{{ range $breakpoint, $carouselInfo := $breakdowns }}
{{ $itemsInCarousel := index $carouselInfo "size" }}
{{ $breakpointVisibilityClass := index $carouselInfo "class" }}
{{ $isMobile := (eq $itemsInCarousel 1) }}
{{ $carouselId := (printf "new-course-carousel-%v" $breakpoint) }}
<div class="{{ $breakpointVisibilityClass }}">
<div id="{{ $carouselId }}" class="carousel slide" data-interval="false" data-touch="true" data-ride="carousel">
<div class="carousel-header d-flex flex-row justify-content-between font-weight-bold">
<h2>New Courses</h2>
{{ partial "carousel_controls.html" $carouselId }}
</div>
<div class="carousel-inner d-flex {{ if not $isMobile }}container{{ end }} mt-2 px-0">
{{ $resultsSlice := first 12 $results }}
{{ range $index, $courseItem := $resultsSlice }}
{{- if $courseItem.url_path -}}
{{- $url := delimit (slice (strings.TrimSuffix "/" $staticApiBaseUrl) "/" $courseItem.url_path "/data.json") "" -}}
{{ with try (resources.GetRemote $url) }}
{{ with .Err }}
{{ errorf "Failed to fetch new course info from %v with error %v" $url . }}
{{ else with .Value }}
{{- $courseData := . | unmarshal -}}
{{ partial "course_carousel_card.html" (dict "itemsInCarousel" $itemsInCarousel "courseData" $courseData "index" $index "urlPath" $courseItem.url_path "numCourses" (len $resultsSlice))}}
{{ end }}
{{ else }}
{{- $courseData := . | unmarshal -}}
{{ partial "course_carousel_card.html" (dict "itemsInCarousel" $itemsInCarousel "courseData" $courseData "index" $index "urlPath" $courseItem.url_path "numCourses" (len $resultsSlice))}}
{{ errorf "Failed to fetch new course info from %v" $url }}
{{ end }}
{{ else }}
{{ errorf "Failed to fetch new course info from %v" $url }}
{{ end }}
{{- end -}}
{{ end }}
{{- end -}}
{{ end }}
</div>
</div>
</div>
</div>
{{ end }}
{{ else }}
No new courses found
{{ end }}
{{ else }}
No new courses found
{{ end }}
{{ end }}
{{ else }}
Expand Down
4 changes: 2 additions & 2 deletions www/layouts/partials/ocw_news.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
{{ $studioBaseUrl := partial "ocw_studio_base_url.html" }}
{{ if $studioBaseUrl }}
{{- $url := (print (strings.TrimSuffix "/" $studioBaseUrl) "/api/news/") -}}
{{ with resources.GetRemote $url }}
{{ with try (resources.GetRemote $url) }}
{{ with .Err }}
{{ $errorMessage := printf "OCW News on %v failed to fetch %v with error: %v" site.BaseURL $url . }}
{{ partial "sentry_capture_message.html" $errorMessage }}
{{ else }}
{{ else with .Value }}
{{ $items := (. | unmarshal).items }}
{{ if $items }}
{{ $breakdowns := (dict "xs-sm" (dict "size" 1 "class" "d-flex d-lg-none") )}}
Expand Down
14 changes: 7 additions & 7 deletions www/layouts/resource_collections/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ <h1>
{{- $urlPath := index . 1 -}}
{{- if not (isset $contentMap $urlPath) -}}
{{- $url := delimit (slice (strings.TrimSuffix "/" $staticApiBaseUrl) "/" $urlPath "/content_map.json") "" -}}
{{- with resources.GetRemote $url -}}
{{- with try (resources.GetRemote $url) -}}
{{ with .Err }}
{{- $errorMessage := printf "Failed to fetch resource collections on %v via %v with error: %v" site.BaseURL $url . -}}
{{- partial "sentry_capture_message.html" $errorMessage -}}
{{ else }}
{{ else with .Value }}
{{- $mapData := . | unmarshal -}}
{{- $mapData = merge $mapData (dict "url_path" $urlPath) -}}
{{- $contentMap = dict $urlPath $mapData | merge $contentMap -}}
Expand All @@ -40,11 +40,11 @@ <h1>
{{- end -}}
{{- if not (isset $courseJSONMap $urlPath) -}}
{{- $url := delimit (slice (strings.TrimSuffix "/" $staticApiBaseUrl) "/" $urlPath "/data.json") "" -}}
{{- with resources.GetRemote $url -}}
{{- with try (resources.GetRemote $url) -}}
{{ with .Err }}
{{- $errorMessage := printf "Failed to fetch resource collections on %v via %v with error: %v" site.BaseURL $url . -}}
{{- partial "sentry_capture_message.html" $errorMessage -}}
{{ else }}
{{ else with .Value }}
{{- $data := . | unmarshal -}}
{{- $data = merge $data (dict "url_path" $urlPath) -}}
{{- $courseJSONMap = merge $courseJSONMap (dict $urlPath $data) -}}
Expand All @@ -56,11 +56,11 @@ <h1>
{{- end -}}
{{- $courseJSONRelpath := index (index $contentMap $urlPath) $itemUUID -}}
{{- $url := delimit (slice (strings.TrimSuffix "/" $staticApiBaseUrl) $courseJSONRelpath) "" -}}
{{- with resources.GetRemote $url -}}
{{- with try (resources.GetRemote $url) -}}
{{ with .Err }}
{{- $errorMessage := printf "Failed to fetch resource collections on %v via %v with error: %v" site.BaseURL $url . -}}
{{- partial "sentry_capture_message.html" $errorMessage -}}
{{ else }}
{{ else with .Value}}
{{- $resourceJSON := . | unmarshal -}}
{{- $resourceJSONMap = dict $itemUUID $resourceJSON | merge $resourceJSONMap -}}
{{- $resourceURLMap = dict $itemUUID $url | merge $resourceURLMap -}}
Expand All @@ -75,4 +75,4 @@ <h1>
window.resourceCollectionData = JSON.parse("{{- $resourceCollectionData | jsonify -}}");
</script>
</div>
{{ end }}
{{ end }}
32 changes: 19 additions & 13 deletions www/layouts/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,26 @@
{{- if and $studioBaseUrl (ne $apiBearerToken "") -}}
{{- $apiUrl := printf "%v/api/publish?%v" (strings.TrimSuffix "/" $studioBaseUrl) $queryString -}}
{{- $apiHeaders := dict "headers" (dict "Authorization" (printf "Bearer %v" $apiBearerToken)) -}}
{{- $coursesJson := resources.GetRemote $apiUrl $apiHeaders -}}
{{- with transform.Unmarshal $coursesJson -}}
{{- $sites := .sites -}}
{{- if $sites -}}
{{ range $index, $courseItem := $sites }}
{{- $path := strings.TrimPrefix "/" (strings.TrimSuffix "/" $courseItem.base_url) -}}
{{- if not (eq $path "") -}}
{{- $url := printf "https://%v/%v/sitemap.xml" $sitemapDomain $path -}}
<sitemap>
<loc>{{ $url }}</loc>
</sitemap>
{{- with try (resources.GetRemote $apiUrl $apiHeaders) -}}
{{- with .Err -}}
{{ errorf "Failed to fetch sitemap from studio: %v" . }}
{{- end -}}
{{- with .Value -}}
{{- with transform.Unmarshal . -}}
{{- $sites := .sites -}}
{{- if $sites -}}
{{ range $index, $courseItem := $sites }}
{{- $path := strings.TrimPrefix "/" (strings.TrimSuffix "/" $courseItem.base_url) -}}
{{- if not (eq $path "") -}}
{{- $url := printf "https://%v/%v/sitemap.xml" $sitemapDomain $path -}}
<sitemap>
<loc>{{ $url }}</loc>
</sitemap>
{{- end -}}
{{ end }}
{{- end -}}
{{ end }}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
</sitemapindex>
</sitemapindex>
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8096,15 +8096,15 @@ __metadata:
languageName: node
linkType: hard

"hugo-bin-extended@npm:^0.139.0":
version: 0.139.4
resolution: "hugo-bin-extended@npm:0.139.4"
"hugo-bin-extended@npm:^0.141.0":
version: 0.141.0
resolution: "hugo-bin-extended@npm:0.141.0"
dependencies:
"@xhmikosr/bin-wrapper": ^13.0.5
package-config: ^5.0.0
bin:
hugo: bin/cli.js
checksum: 64919c80a22663c85ab0650522785066c077eff06a3e2dbaf027908e42448005de0649b41140fdb91fa0ff29fd32ea5d06772764cef3b10e3e8534091d49e424
checksum: 4885b9e79e88acc89123bad47c24a8b7f30ae9393c687b9dbecedc6fe912a525fe535eddc55aeca9790ff0cda58f9e1e87f9f8017b37743931e6fc95eda74919
languageName: node
linkType: hard

Expand Down Expand Up @@ -11277,7 +11277,7 @@ __metadata:
file-loader: ^5.0.2
fuse.js: ^6.6.2
history: ^5.3.0
hugo-bin-extended: ^0.139.0
hugo-bin-extended: ^0.141.0
imports-loader: ^0.8.0
inquirer: ^12.0.0
isomorphic-fetch: ^3.0.0
Expand Down

0 comments on commit f997686

Please sign in to comment.