Add gemini site builder

This commit is contained in:
Erick Ruiz de Chavez 2024-12-21 12:08:08 -05:00
parent 329e3b24f7
commit c13d147ac6
11 changed files with 138 additions and 31 deletions

1
.gitignore vendored
View file

@ -3,3 +3,4 @@
.jekyll-metadata
vendor
_site
_capsule

6
Dockerfile.gemini Normal file
View file

@ -0,0 +1,6 @@
FROM alpine:latest
RUN apk add perl lowdown
WORKDIR /app
COPY generate_capsule.sh .
ENTRYPOINT [ "./generate_capsule.sh" ]

View file

@ -12,23 +12,28 @@ stop:
docker compose down
clean:
\rm -rf .jekyll-cache _site
\rm -rf .jekyll-cache .saas-cache _site _capsule
docker compose down -v
logs:
docker compose logs --follow --since 1m
build:
docker compose run --rm -e JEKYLL_ENV=production jekyll build
build: build-jekyll build-gemini
build-gemini:
docker compose run --rm gemini
build-jekyll:
docker compose run --rm jekyll build
install:
docker compose run --rm --entrypoint bash jekyll -c bundle add ${args}
make draft:
draft:
docker compose run --rm jekyll draft ${args}
make publish:
publish:
docker compose run --rm jekyll publish ${args}
make unpublish:
unpublish:
docker compose run --rm jekyll unpublish ${args}

View file

@ -2,20 +2,11 @@ title: Erick Ruiz de Chavez
author: Erick Ruiz de Chavez
url: https://erickruizdechavez.com
site_links:
- title: 💼 LinkedIn
url: https://linkedin.com/in/erickruizdechavez
- title: 🐙 GitHub
url: https://github.com/eruizdechavez
- title: 🗣 Fediverse
url: https://erick.social/@erick
- title: 🦋 Bluesky
url: https://bsky.app/profile/erick.social
exclude:
- Dockerfile
- Dockerfile*
- compose.yaml
- Makefile
- generate_capsule.sh
jekyll_compose:
default_front_matter:

1
_includes/header.gmi Normal file
View file

@ -0,0 +1 @@
# Erick Ruiz de Chavez

View file

@ -5,18 +5,21 @@
alt="Generated Image of an anthropomorphic Panda wearing a sweater and jeans, sitting on a couch, using a laptop."
/>
{%- if site.site_links -%}
<nav class="site_links">
{%- if page.url != "/" -%}
<a class="site_links__link" href="{{ "/" | relative_url }}">🏡 Front Page</a>
{%- endif -%}
{%- for my_page in site.site_links -%}
{%- if my_page.title -%}
<a class="site_links__link" href="{{ my_page.url }}" rel="me noreferrer" target="_blank">
{{ my_page.title | escape }}
</a>
{%- endif -%}
{%- endfor -%}
</nav>
{%- endif -%}
<nav class="site_links">
{%- if page.url != "/" -%}
<a class="site_links__link" href="{{ "/" | relative_url }}">🏡 Front Page</a>
{%- endif -%}
<a class="site_links__link" href="https://linkedin.com/in/erickruizdechavez" rel="me noreferrer" target="_blank">
💼 LinkedIn
</a>
<a class="site_links__link" href="https://github.com/eruizdechavez" rel="me noreferrer" target="_blank">
🐙 GitHub
</a>
<a class="site_links__link" href="https://erick.social/@erick" rel="me noreferrer" target="_blank">
🗣 Fediverse
</a>
<a class="site_links__link" href="https://bsky.app/profile/erick.social" rel="me noreferrer" target="_blank">
🦋 Bluesky
</a>
</nav>
</header>

6
_includes/links.gmi Normal file
View file

@ -0,0 +1,6 @@
## Links
=> https://linkedin.com/in/erickruizdechavez LinkedIn
=> https://github.com/eruizdechavez GitHub
=> https://erick.social/@erick Fediverse
=> https://bsky.app/profile/erick.social Bluesky

5
_layouts/article.gmi Normal file
View file

@ -0,0 +1,5 @@
%%header%%
=> index.gmi Front page
## %%title%%
%%body%%
%%links%%

5
_layouts/home.gmi Normal file
View file

@ -0,0 +1,5 @@
%%header%%
%%body%%
%%articles%%
%%drafts%%
%%links%%

View file

@ -7,3 +7,10 @@ services:
- 35729:35729
volumes:
- .:/app
gemini:
build:
context: .
dockerfile: Dockerfile.gemini
platform: linux/amd64
volumes:
- .:/app

77
generate_capsule.sh Executable file
View file

@ -0,0 +1,77 @@
#!/usr/bin/env sh
mkdir -p _capsule
articles_list=""
header_body=$(cat _includes/header.gmi)
links_body=$(cat _includes/links.gmi)
for post in $(ls _posts/*.md); do
article_title=$(lowdown -X title $post)
article_date=$(lowdown -X date $post | awk '{print $1}')
article_body=$(lowdown -tgemini $post)
echo "Rendering post $article_title..."
gemfile=$post
gemfile=${gemfile/_posts/_capsule}
gemfile=${gemfile/.md/.gmi}
cat _layouts/article.gmi \
| perl -pe "s|%%header%%|${header_body}|" \
| perl -pe "s|%%links%%|${links_body}|" \
| perl -pe "s|%%title%%|${article_title}\n${article_date}\n|" \
| perl -pe "s|%%body%%|${article_body}|" \
> $gemfile
articles_list="$articles_list=> ${gemfile/_capsule\//} $article_date $article_title\n"
done
drafts_list=""
if [ "${GEMINI_ENV}" != 'production' ]; then
for post in $(ls _drafts/*.md); do
article_title=$(lowdown -X title $post)
article_body=$(lowdown -tgemini $post)
echo "Rendering draft $article_title..."
gemfile=$post
gemfile=${gemfile/_drafts/_capsule}
gemfile=${gemfile/.md/.gmi}
cat _layouts/article.gmi \
| perl -pe "s|%%header%%|${header_body}|" \
| perl -pe "s|%%links%%|${links_body}|" \
| perl -pe "s|%%title%%|${article_title}|" \
| perl -pe "s|%%body%%|${article_body}|" \
> $gemfile
drafts_list="$drafts_list=> ${gemfile/_capsule\//} $article_title\n"
done
fi
echo "Rendering index..."
index_body=$(lowdown -tgemini index.md)
articles=""
if [ ! -z "$articles_list" ]; then
articles="## Articles\n\n${articles_list}"
fi
drafts=""
if [ ! -z "$drafts_list" ]; then
drafts="## Drafts\n\n${drafts_list}"
fi
cat _layouts/home.gmi \
| perl -pe "s|%%header%%|${header_body}|" \
| perl -pe "s|%%links%%|${links_body}|" \
| perl -pe "s|%%body%%|${index_body}|" \
| perl -pe "s|%%articles%%|${articles}|" \
| perl -pe "s|%%drafts%%|${drafts}|" \
> _capsule/index.gmi
echo "Done"