aboutsummaryrefslogtreecommitdiff
path: root/pages/home.sh
blob: ebb399df2b0e9cff2e5f3c78389e7a13f6970a96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/bash

print-all-articles () {
  for i in $(find ./pages/articles -type f -name '*.txt'); do
    ARTICLE_CONTENT=$(tail -n +3 $i)
    cat <<POST
<section class="post-preview">
  <div class="post-header-preview">
    <h5 class="post-title">stat -c "%w %z" $i</h5>
    <time>$(stat --format="Criado em: %w<br/>Última atualização: %z" $i)</time>
  </div>

  <p>$(echo "$ARTICLE_CONTENT" | head -c 120)...</p>

  <a href="/artigo/$(basename $i)">Ler artigo completo</a>
</section>
POST
  done
}

cat <<PAGE
<article class="home-feed container">
  $(print-all-articles)
</article>
PAGE