From 53a1dfbefd1f5d085d17417e1b4f007d4d6ec510 Mon Sep 17 00:00:00 2001 From: -k Date: Fri, 26 Jan 2024 22:21:10 -0800 Subject: [PATCH] feat: support URLs in `project` --- content/pages/projects.md | 18 +++++++++--------- content/posts/project/index.md | 25 +++++++++++++++++++++++++ templates/shortcodes/project.html | 16 +++++++++------- 3 files changed, 43 insertions(+), 16 deletions(-) create mode 100644 content/posts/project/index.md diff --git a/content/pages/projects.md b/content/pages/projects.md index bf21a77..1d06311 100644 --- a/content/pages/projects.md +++ b/content/pages/projects.md @@ -5,20 +5,20 @@ template = "page.html" draft = false +++ -{{ project(gh_repo="halve-z") }} +{{ project(link="https://github.com/charlesrocket/halve-z") }} -{{ project(gh_repo="dorst") }} +{{ project(link="https://github.com/charlesrocket/dorst") }} -{{ project(gh_repo="freebsd-collection") }} +{{ project(link="https://github.com/charlesrocket/freebsd-collection") }} -{{ project(gh_repo="essential-collection") }} +{{ project(link="https://github.com/charlesrocket/essential-collection") }} -{{ project(gh_repo="webpixels") }} +{{ project(link="https://github.com/charlesrocket/webpixels") }} -{{ project(gh_repo="pixelmosh") }} +{{ project(link="https://github.com/charlesrocket/pixelmosh") }} -{{ project(gh_repo="skully") }} +{{ project(link="https://github.com/charlesrocket/skully") }} -{{ project(gh_repo="beastie") }} +{{ project(link="https://github.com/charlesrocket/beastie") }} -{{ project(gh_repo="frightcrawler") }} +{{ project(link="https://github.com/charlesrocket/frightcrawler") }} diff --git a/content/posts/project/index.md b/content/posts/project/index.md new file mode 100644 index 0000000..ca90777 --- /dev/null +++ b/content/posts/project/index.md @@ -0,0 +1,25 @@ ++++ +title = "Projects" +date = 2022-12-31 +[taxonomies] +categories = ["usage"] +tags = ["content", "features"] +[extra] +subtitle = "Project cards" ++++ + +input: + +```rs +{{/* project(link="https://github.com/charlesrocket/halve-z") */}} +``` + +- `link`: the address of the repository (mandatory) + +output: + +```html +{{ project(link="https://github.com/charlesrocket/halve-z") }} +``` + +{{ project(link="https://github.com/charlesrocket/halve-z") }} diff --git a/templates/shortcodes/project.html b/templates/shortcodes/project.html index 12e74df..aba7b25 100644 --- a/templates/shortcodes/project.html +++ b/templates/shortcodes/project.html @@ -1,17 +1,19 @@ -{% set gh_repo_link = "https://api.github.com/repos/charlesrocket/" ~ gh_repo %} -{% set gh_repo_data = load_data(url=gh_repo_link, format="json") %} +{%- if link is starting_with("https://github.com") %} + {%- set gh_repo_link = link | replace(from="https://github.com", to="https://api.github.com/repos") %} + {%- set gh_repo_data = load_data(url=gh_repo_link, format="json") %} +{%- endif %}

{{ gh_repo_data["name"] }}