Refactor _blogs function in qsgen2 file to extract blog title based on generator type (native/markdown)
This commit is contained in:
parent
f7e542c749
commit
73dfd0446d
23
qsgen2
23
qsgen2
@ -696,22 +696,23 @@ function _blogs() {
|
|||||||
# Array sdate = Name day=1, Year=2, Month=3, Number day=4
|
# Array sdate = Name day=1, Year=2, Month=3, Number day=4
|
||||||
sdate=( $( echo ${content} | grep DATE | sed "s|DATE\ ||" | sed "s|\-|\ |g" ) )
|
sdate=( $( echo ${content} | grep DATE | sed "s|DATE\ ||" | sed "s|\-|\ |g" ) )
|
||||||
if [[ ${generator} == "native" ]]; then
|
if [[ ${generator} == "native" ]]; then
|
||||||
if [[ "${content}" =~ "^BLOG_TITLE (.*)$" ]]; then
|
while IFS= read -r line; do
|
||||||
btitle=$match[1]
|
if [[ "$line" == "BLOG_TITLE "* ]]; then
|
||||||
#btitle=$( echo ${content} | grep BLOG_TITLE | cut -d' ' -f2- )
|
btitle="${line#BLOG_TITLE }"
|
||||||
|
break
|
||||||
fi
|
fi
|
||||||
|
done <<< "$content"
|
||||||
elif [[ ${generator} == "markdown" ]]; then
|
elif [[ ${generator} == "markdown" ]]; then
|
||||||
while IFS= read -r line
|
local b_title=""
|
||||||
do
|
while IFS= read -r line; do
|
||||||
# Check if the line starts with '#' and capture the line
|
|
||||||
if [[ "$line" == \#* ]]; then
|
if [[ "$line" == \#* ]]; then
|
||||||
# Remove all leading '#' characters and the first space (if present)
|
b_title="${line#\#}" # Remove the first '#' character
|
||||||
btitle="${line#\#}" # Remove the first '#' character
|
b_title="${b_title#\#}" # Remove the second '#' character if present
|
||||||
btitle="${btitle#\#}" # Remove the second '#' character if present
|
b_title="${b_title#"${b_title%%[![:space:]]*}"}" # Trim leading whitespace
|
||||||
btitle="${btitle#"${btitle%%[![:space:]]*}"}" # Trim leading whitespace
|
|
||||||
break # Exit the loop after finding the first heading
|
break # Exit the loop after finding the first heading
|
||||||
fi
|
fi
|
||||||
done <<< ${content}
|
done <<< "$content"
|
||||||
|
btitle=${b_title}
|
||||||
fi
|
fi
|
||||||
ingress=$( echo ${content} | sed "s/'/\\\'/g" | xargs | grep -Po "#INGRESS_START\K(.*?)#INGRESS_STOP" | sed "s|\ \#INGRESS_STOP||" | sed "s|^\ ||" )
|
ingress=$( echo ${content} | sed "s/'/\\\'/g" | xargs | grep -Po "#INGRESS_START\K(.*?)#INGRESS_STOP" | sed "s|\ \#INGRESS_STOP||" | sed "s|^\ ||" )
|
||||||
body=$( echo ${content} | sed "s/'/\\\'/g" | xargs | grep -Po "#BODY_START\K(.*?)#BODY_STOP" | sed "s|\ \#BODY_STOP||" | sed "s|^\ ||" )
|
body=$( echo ${content} | sed "s/'/\\\'/g" | xargs | grep -Po "#BODY_START\K(.*?)#BODY_STOP" | sed "s|\ \#BODY_STOP||" | sed "s|^\ ||" )
|
||||||
|
Loading…
Reference in New Issue
Block a user