From c78d68dc0b6c7982bf27ec9cb1e9242671d31fb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nuno=20Cora=C3=A7=C3=A3o?= Date: Thu, 2 Nov 2023 23:30:55 +0000 Subject: [PATCH] made github and gitlab shortcodes dynamic --- layouts/shortcodes/github.html | 39 ++++++++++++++++++++++++++-------- layouts/shortcodes/gitlab.html | 30 +++++++++++++++++++++----- 2 files changed, 55 insertions(+), 14 deletions(-) diff --git a/layouts/shortcodes/github.html b/layouts/shortcodes/github.html index efb46de3..393586ee 100644 --- a/layouts/shortcodes/github.html +++ b/layouts/shortcodes/github.html @@ -1,26 +1,32 @@ -{{- $githubData := getJSON (print "https://api.github.com/repos/" (.Get "repo")) -}} +{{ $id := delimit (slice "github" .Ordinal now.UnixNano) "-" }} +{{- $githubURL := print "https://api.github.com/repos/" (.Get "repo") -}} +{{- $githubData := getJSON ($githubURL) -}} {{- $githubColors := .Site.Data.githubColors -}} {{- with $githubData -}} - -
+ +
{{ partial "icon.html" "github" }} -
+
{{ .full_name | markdownify | emojify }}
-

+

{{ .description | markdownify | emojify }}

- - + +
{{ if .language }} {{ .language }} {{ else }} null {{ end }}
@@ -28,19 +34,34 @@ {{ partial "icon.html" "star" }} -
+
{{ .stargazers_count }}
{{ partial "icon.html" "fork" }} -
+
{{ .forks }}
+
{{- end -}} \ No newline at end of file diff --git a/layouts/shortcodes/gitlab.html b/layouts/shortcodes/gitlab.html index bf56536c..1f2a8fa9 100644 --- a/layouts/shortcodes/gitlab.html +++ b/layouts/shortcodes/gitlab.html @@ -1,4 +1,7 @@ -{{- $gitLabData := getJSON (print (default "https://gitlab.com/" (.Get "baseURL")) "api/v4/projects/" (.Get "projectID")) -}} +{{ $id := delimit (slice "gitlab" .Ordinal now.UnixNano) "-" }} +{{- $gitlabURL := print (default "https://gitlab.com/" (.Get "baseURL")) "api/v4/projects/" (.Get "projectID") -}} + +{{- $gitLabData := getJSON ($gitlabURL) -}} {{- with $gitLabData -}} @@ -8,12 +11,12 @@ {{ partial "icon.html" "gitlab" }} -
+
{{ .name_with_namespace | markdownify | emojify }}
-

+

{{ .description | markdownify | emojify }}

@@ -21,19 +24,36 @@ {{ partial "icon.html" "star" }} -
+
{{ .star_count }}
{{ partial "icon.html" "fork" }} -
+
{{ .forks_count }}
+
{{- end -}}