newsroom img paths fix

This commit is contained in:
timurgordon
2022-09-01 16:30:09 +03:00
parent b84e4ea069
commit c65b9f9266
4 changed files with 4443 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
#/bin/bash
dir="threefold_data/content/blog"
for file in $(grep -ril 'authors:' $dir);
@@ -82,3 +83,88 @@ $IMAGE\\
#mv 'static/'$IMG_PATH $FPATH
#sed -i "" "s|$IMG_PATH|$IMG_NAME|g" "$file"
done;
dir="threefold_data/content/news"
for file in $(grep -ril 'authors:' $dir);
do
echo $file
#FPATH="${file%/*}"
#AUTHOR="$(grep -n 'author:' "$file" | sed -n -e 's/^.*\(\(author:\).*\)/\1/p')"
#LINE1="$(grep -n 'author:' "$file" | head -n1 | sed 's/:.*//')"
#LINE2="$(grep -n 'authorImg:' "$file" | head -n1 | sed 's/:.*//')"
#AUTHOR_NAME="${AUTHOR#* }"
#echo $AUTHOR_NAME | sed 's/[A-Z]/\L&/g'
#AUTHOR_NAME=$(echo "$AUTHOR_NAME" | tr '[:upper:]' '[:lower:]')
#AUTHOR_SNAKE=${AUTHOR_NAME// /_}
# move created field below excerpt
DATE="$(grep -n 'created:' "$file" | sed -n -e 's/^.*\(\(created:\).*\)/\1/p')"
LINE_NUM="$(grep -n 'created:' "$file" | head -n1 | sed 's/:.*//')"
sed -i "" "${LINE_NUM}d" "$file"
LINE_NUM="$(grep -n 'excerpt:' "$file" | head -n1 | sed 's/:.*//')"
sed -a -i "" "${LINE_NUM}i\\
$DATE\\
" "$file"
# sed -i "" "${LINE1}d" "$file"
#template: blogPage.html
# move category field below people
CATEGORY="$(grep -n 'category:' "$file" | sed -n -e 's/^.*\(\(category:\).*\)/\1/p')"
LINE_NUM="$(grep -n 'category:' "$file" | head -n1 | sed 's/:.*//')"
sed -i "" "${LINE_NUM}d" "$file"
LINE_NUM="$(grep -n 'authors:' "$file" | head -n1 | sed 's/:.*//')"
LINE_NUM="$(($LINE_NUM + 1))"
sed -a -i "" "${LINE_NUM}i\\
$CATEGORY\\
" "$file"
# move tags field below people
TAGS="$(grep -n 'tags:' "$file" | sed -n -e 's/^.*\(\(tags:\).*\)/\1/p')"
LINE_NUM="$(grep -n 'tags:' "$file" | head -n1 | sed 's/:.*//')"
sed -i "" "${LINE_NUM}d" "$file"
LINE_NUM="$(grep -n 'authors:' "$file" | head -n1 | sed 's/:.*//')"
LINE_NUM="$(($LINE_NUM + 1))"
sed -a -i "" "${LINE_NUM}i\\
$TAGS\\
" "$file"
# move image field below category
IMAGE="$(grep -n 'image:' "$file" | sed -n -e 's/^.*\(\(image:\).*\)/\1/p')"
LINE_NUM="$(grep -n 'image:' "$file" | head -n1 | sed 's/:.*//')"
sed -i "" "${LINE_NUM}d" "$file"
LINE_NUM="$(grep -n 'category:' "$file" | head -n1 | sed 's/:.*//')"
LINE_NUM="$(($LINE_NUM + 1))"
sed -a -i "" "${LINE_NUM}i\\
$IMAGE\\
" "$file"
# Change field names
sed -i "" "s|category:|categories:|g" "$file"
sed -i "" "s|created:|date:|g" "$file"
sed -i "" "s|excerpt:|description:|g" "$file"
sed -i "" "s| ---|---|g" "$file"
sed -i "" "s|authors:|taxonomies:\\
people:|g" "$file"
sed -i "" "s|image: ./|extra:\\
imgPath: |g" "$file"
mv $file ${file%/*}/index.md
mv ${file%/*} content/newsroom
#mv 'static/'$IMG_PATH $FPATH
#="$(grep -n 'imgPath:' "$file")"
#ECHO $NUM
#IMG_PATH="$(echo $NUM | sed -n -e 's/^.*\(\(images\/blog\/\).*\)/\1/p')"
#echo $IMG_PATH
#IMG_NAME="${IMG_PATH##*/}"
#echo $IMG_NAME
#mv 'static/'$IMG_PATH $FPATH
#sed -i "" "s|$IMG_PATH|$IMG_NAME|g" "$file"
break
done;

File diff suppressed because one or more lines are too long

View File

@@ -62,7 +62,8 @@
</section>
</div>
<section class="post-image mx-auto w-full">
<img src="/{{page.extra.imgPath}}" />
{% set img_url = get_url(path='/' ~ page.relative_path | replace(from='_', to='-') | replace(from='index.md', to=page.extra.imgPath)) %}
<img src="{{img_url}}" />
</section>
<div class="py-12">

View File

@@ -2,7 +2,8 @@
<div class="flex-1">
<a href={{ post.permalink }} class="block">
<div class="flex-shrink-0">
<img class="h-48 w-full mx-auto object-cover" src=/{{post.extra.imgPath}} alt="" />
{% set img_url = get_url(path='/' ~ post.relative_path | replace(from='_', to='-') | replace(from='index.md', to=post.extra.imgPath)) %}
<img class="h-48 w-full mx-auto object-cover" src={{img_url}} alt="" />
</div>
<div class="flex-1 bg-white p-4 flex flex-col justify-between">