aboutsummaryrefslogtreecommitdiff
path: root/pages/home.sh
blob: 49094fcc25c583c6991870d251bdffa825727f3b (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash

welcome () {
  cat <<WELCOME
<section class="conainer" id="welcome">
  <hgroup>
    <h1>Bem-vindo ao meu blog :3</h1>
    <h4>Aqui escrevo sobre programação e mostro o meu trabalho.</h4>
  </hgroup>
  <hr/>
</section>
WELCOME
}

all-articles-sort-by-last-modification () {
  # Find all articles and sort by date of creation
  cat <<HEADER
  <h4>Últimas atividades</h4>
HEADER
  IFS=';' read -ra ARTICLE_LIST <<< "$(
    find $ARTICLES_PATH \
      -type f \
      -regex ".*\.$(scape-regex "($ARTICLES_EXTS)")" \
      -printf "%T@ %p\n" |
    sort -rn |
    cut -b 23- |
    sed 's/^ //g' |
    tr '\n' ';'
  )"

  for i in "${ARTICLE_LIST[@]}"; do
    ARTICLE_FILE="$i" source $SCRIPT_DIR/components/post-preview.sh
  done
}

cat <<PAGE
<article class="home-feed container">
  $(welcome)
  $(all-articles-sort-by-last-modification)
</article>
PAGE