about summary refs log tree commit diff
path: root/gen
diff options
context:
space:
mode:
authorPatryk Niedźwiedziński <pniedzwiedzinski19@gmail.com>2021-03-15 00:18:46 +0100
committerPatryk Niedźwiedziński <pniedzwiedzinski19@gmail.com>2021-03-15 00:18:46 +0100
commit1761bc8a19e1da18bc9a6733185785d13aef6261 (patch)
tree212e326fd64fe4c8068535a189f130722688fadb /gen
parent7703c4d8ecf321a046f95ee47167b7f6bff35f90 (diff)
downloadkronika-1761bc8a19e1da18bc9a6733185785d13aef6261.tar.gz
kronika-1761bc8a19e1da18bc9a6733185785d13aef6261.zip
Add more styling
Diffstat (limited to 'gen')
-rwxr-xr-xgen34
1 files changed, 32 insertions, 2 deletions
diff --git a/gen b/gen
index 9d7f8d3..fbabfdf 100755
--- a/gen
+++ b/gen
@@ -8,16 +8,46 @@ mkdir dest
 export PATH="$PWD/.jekyll-cache:$PATH"
 ./tools/compile
 
+
+function post_link() {
+  path=$1
+  title=$2
+  photo=$3
+  description=$4
+  cat << EOF
+<div class="post-link">
+  <a href="$path">
+    <div>
+      <div class="image" style="background-image: url('$photo')"></div>
+      <div class="post-container">
+        <h4 class="post-title">$title</h4>
+        <p class="post-description">$description</p>
+      </div>
+    </div>
+  </a>
+</div>
+EOF
+}
+
 cat > wpisy/kronika.html << EOF
+<link href="/kronika.css" rel="stylesheet">
 <h2>Ostatnie wpisy</h2>
 
 <a href="rss.xml"><img alt="" src="/assets/rss.svg" style="height:1em">RSS</a>
-<div>
+<div class="content post-list">
 EOF
 
+i=0
 for f in `find wpisy/kronika/20* -name '*.md' | sort -r`; do
   path=`echo $f | sed 's/wpisy//;s/.md//'`
-  echo "<a href=\"$path\"><div>$path</div></a>" >> wpisy/kronika.html
+  title=`grep "^# " $f | head -n 1 | cut -c 2-`
+  photo=`grep "!\[.*\]\(.*\)" $f | head -n 1 | cut -d "(" -f2 | cut -d ")" -f1`
+  [ -z $photo ] && photo="/assets/default_tree.jpg"
+  description=`grep -E "^[A-Z]" $f | grep -v "|" | head -n 1 | cut -d" " -f1-30`
+  post_link "$path" "$title" "$photo" "$description" >> wpisy/kronika.html
+  [ $i -lt 4 ] && \
+    # post_link "$path" "$title" "$photo" "$description" >> wpisy/index.md && \
+    i=$(($i+1))
 done
 echo "</div>" >> wpisy/kronika.html