feat: Add content adapter for videos
This commit is contained in:
parent
a9bd2c2c40
commit
5b33f8d98a
1 changed files with 51 additions and 0 deletions
51
content/videos/_content.gotmpl
Normal file
51
content/videos/_content.gotmpl
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
{{ $data := dict }}
|
||||||
|
{{ $url := "https://video.millironx.com/api/v1/accounts/millironx/videos?skipCount=true" }}
|
||||||
|
{{ with resources.GetRemote $url }}
|
||||||
|
{{ with .Err }}
|
||||||
|
{{ errorf "Unable to get remote resource %s: %s" $url . }}
|
||||||
|
{{ else }}
|
||||||
|
{{ $data = . | transform.Unmarshal }}
|
||||||
|
{{ end }}
|
||||||
|
{{ else }}
|
||||||
|
{{ errorf "Unable to get remote resource %s" $url }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{ range $data.data }}
|
||||||
|
{{ $content := dict "mediaType" "text/markdown" "value" .description }}
|
||||||
|
{{ $dates := dict "date" (time.AsTime (default .publishedAt .originallyPublishedAt)) }}
|
||||||
|
{{ $categories := slice "video" }}
|
||||||
|
{{ $people := slice "Thomas A. Christensen II" }}
|
||||||
|
{{ $link := .url }}
|
||||||
|
{{ $params := dict
|
||||||
|
"categories" $categories
|
||||||
|
"people" $people
|
||||||
|
"link" $link
|
||||||
|
}}
|
||||||
|
{{ $page := dict
|
||||||
|
"content" $content
|
||||||
|
"dates" $dates
|
||||||
|
"title" .name
|
||||||
|
"path" .name
|
||||||
|
"params" $params
|
||||||
|
}}
|
||||||
|
{{ $.AddPage $page }}
|
||||||
|
|
||||||
|
{{ $item := . }}
|
||||||
|
{{ with $thumbnailPath := $item.thumbnailPath }}
|
||||||
|
{{ $url := print "https://video.millironx.com" $thumbnailPath }}
|
||||||
|
{{ with resources.GetRemote $url }}
|
||||||
|
{{ with .Err }}
|
||||||
|
{{ errorf "Unable to get remote resource %s: %s" $url . }}
|
||||||
|
{{ else }}
|
||||||
|
{{ $content := dict "mediaType" .MediaType.Type "value" .Content }}
|
||||||
|
{{ $resource := dict
|
||||||
|
"content" $content
|
||||||
|
"path" (print $item.name "/thumbnail." .MediaType.SubType)
|
||||||
|
}}
|
||||||
|
{{ $.AddResource $resource }}
|
||||||
|
{{ end }}
|
||||||
|
{{ else }}
|
||||||
|
{{ errorf "Unable to get remote resource %s" $url }}
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
Loading…
Reference in a new issue