Skip to content

Commit 83605fa

Browse files
authored
Merge pull request #92 from zihanKuang/delete-banner
Refactor: Update asset handling to use Page Bundles
2 parents c9d6264 + 598a4b5 commit 83605fa

File tree

5 files changed

+24
-16
lines changed

5 files changed

+24
-16
lines changed

layouts/partials/badge.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{{- $b := .badge -}}
22
{{- $contentId := .curriculaId -}}
3-
{{- $orgId := .orgId | default "" -}}
3+
{{- $page_ctx := .page -}}
44

5-
{{- $svg := cond (partial "is-url.html" $b.svg) $b.svg (partial "banner-url.html" (dict "uuid" $orgId "banner" $b.svg )) -}}
6-
{{- $png := cond (partial "is-url.html" $b.png) $b.png (partial "banner-url.html" (dict "uuid" $orgId "banner" $b.svg )) -}}
5+
{{- $svg := cond (partial "is-url.html" $b.svg) $b.svg (partial "resolve-local-resource.html" (dict "page" $page_ctx "path" $b.svg)) -}}
6+
{{- $png := cond (partial "is-url.html" $b.png) $b.png (partial "resolve-local-resource.html" (dict "page" $page_ctx "path" $b.png)) -}}
77

88
{{- $badge := "nil" -}}
99

layouts/partials/banner-url.html

Lines changed: 0 additions & 7 deletions
This file was deleted.

layouts/partials/common-curricula-properties.html

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11

22
{{- $page := .page -}}
3-
{{- $uuid := .uuid -}}
43
{{- $type := or $page.Params.Type "default" -}}
5-
{{- $banner_url := partial "banner-url.html" (dict "uuid" $uuid "banner" $page.Params.Banner) -}}
4+
{{- $banner_url := partial "resolve-local-resource.html" (dict "page" .page "path" .page.Params.Banner) -}}
65
{{- $id := partial "id.html" .page -}}
76

8-
9-
107
"title": {{ $page.Title | jsonify }},
118
"slug": {{ or $page.Slug $page.File.ContentBaseName | jsonify }},
129
"id": {{ $id | jsonify }},

layouts/partials/learning-path.json.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{{- $ctx := partial "resolve-tenant.html" . -}}
44
{{- $uuid := $ctx.uuid -}}
55
{{- $level := partial "validate-level.html" . -}}
6-
{{- $banner_url := partial "banner-url.html" (dict "uuid" $uuid "banner" .Params.Banner) -}}
6+
{{- $banner_url := partial "resolve-local-resource.html" (dict "page" . "path" .Params.Banner) -}}
77
{{- $id := partial "id.html" . -}}
88

99

@@ -27,7 +27,7 @@
2727
"title": {{ .Title | jsonify }},
2828
"description": {{ .Description | jsonify }},
2929
"banner": {{ $banner_url | jsonify }},
30-
"badge": {{ partial "badge.html" (dict "badge" .Params.badge "curriculaId" $id "orgId" $uuid ) | jsonify }},
30+
"badge": {{ partial "badge.html" (dict "page" . "badge" .Params.badge "curriculaId" $id ) | jsonify }},
3131
"certificate": {{ .Params.certificate | jsonify }},
3232
"permalink": {{ .Permalink | jsonify }},
3333
"categories": {{ .Params.Categories | jsonify }},
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{{/*
2+
//revice a page and a path, return the final url of the resource in the page bundle.
3+
@param {dict} . - A dictionary containing:
4+
- "page" {page}: The current page context.
5+
- "path" {string}: The filename of the resource.
6+
*/}}
7+
{{- $page_ctx := .page -}}
8+
{{- $resource_path := .path -}}
9+
10+
{{- $resolved_url := "" -}}
11+
12+
{{- if and $page_ctx $resource_path -}}
13+
{{- with $page_ctx.Resources.GetMatch $resource_path -}}
14+
{{- $resolved_url = .Permalink -}}
15+
{{- end -}}
16+
{{- end -}}
17+
18+
{{- return $resolved_url -}}

0 commit comments

Comments
 (0)