moved header export to inside module
[pinopress.git] / modules / md-header
1 #!/bin/sh
2
3 ## module to read meta in header of md file
4 ## usage: 
5 ##      md-header [md_filepath]
6
7 [ "$#" -ne 1 ] && { echo "Incorrect usage"; exit 1; }
8
9 # usage: getprop [path] [prop]
10 getprop() {
11     sed -nE "s/^-- $2: (.*)$/\1/p" "$1"
12 }
13
14 export ARTICLE_TITLE=`getprop "$1" name`
15 export PUBLISHED_DATE=`getprop "$1" published`
16 export DESCRIPTION=`getprop "$1" description`
17 export USERLOCAL1=`getprop "$1" userlocal1`
18 export USERLOCAL2=`getprop "$1" userlocal2`
19 # this only works when this script is called from pinopress script, as it inherits the required env variables. careful with this one, it's a bit hacky
20 export ARTICLE_URL="$SITEURL/$ARTICLE_PATH/$(echo $(basename "$1") | sed -e 's/\(.*\)\.html/\1\.md/')"