feat: Add content adapter for code projects
This commit is contained in:
parent
5b33f8d98a
commit
c25401e6a2
1 changed files with 50 additions and 0 deletions
50
content/code/_content.gotmpl
Normal file
50
content/code/_content.gotmpl
Normal file
|
@ -0,0 +1,50 @@
|
|||
{{ $data := dict }}
|
||||
{{ $url := "https://code.millironx.com/api/v1/users/millironx/repos" }}
|
||||
{{ 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 }}
|
||||
{{ $content := dict "mediaType" "text/markdown" "value" .description }}
|
||||
{{ $dates := dict "date" (time.AsTime .updated_at) }}
|
||||
{{ $categories := slice "code" }}
|
||||
{{ $people := slice "Thomas A. Christensen II" }}
|
||||
{{ $link := .html_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 $url := $item.avatar_url }}
|
||||
{{ 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