find-post script
This commit is contained in:
parent
207a503207
commit
b6ac06ecfd
@ -1,5 +1,5 @@
|
|||||||
+++
|
+++
|
||||||
title = "Example posts"
|
title = "2023-06"
|
||||||
sort_by = "date"
|
sort_by = "date"
|
||||||
template = "posts.html"
|
template = "posts.html"
|
||||||
page_template = "post.html"
|
page_template = "post.html"
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
+++
|
+++
|
||||||
title = "Example posts"
|
title = "2023-07"
|
||||||
sort_by = "date"
|
sort_by = "date"
|
||||||
template = "posts.html"
|
template = "posts.html"
|
||||||
page_template = "post.html"
|
page_template = "post.html"
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
+++
|
+++
|
||||||
title = "Example posts"
|
title = "2023-08"
|
||||||
sort_by = "date"
|
sort_by = "date"
|
||||||
template = "posts.html"
|
template = "posts.html"
|
||||||
page_template = "post.html"
|
page_template = "post.html"
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
+++
|
+++
|
||||||
title = "Example posts"
|
title = "2023-09"
|
||||||
sort_by = "date"
|
sort_by = "date"
|
||||||
template = "posts.html"
|
template = "posts.html"
|
||||||
page_template = "post.html"
|
page_template = "post.html"
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
+++
|
+++
|
||||||
title = "Example posts"
|
title = "2023-10"
|
||||||
sort_by = "date"
|
sort_by = "date"
|
||||||
template = "posts.html"
|
template = "posts.html"
|
||||||
page_template = "post.html"
|
page_template = "post.html"
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
+++
|
+++
|
||||||
title = "Example posts"
|
title = "2023-11"
|
||||||
sort_by = "date"
|
sort_by = "date"
|
||||||
template = "posts.html"
|
template = "posts.html"
|
||||||
page_template = "post.html"
|
page_template = "post.html"
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
+++
|
+++
|
||||||
title = "Example posts"
|
title = "2023-12"
|
||||||
sort_by = "date"
|
sort_by = "date"
|
||||||
template = "posts.html"
|
template = "posts.html"
|
||||||
page_template = "post.html"
|
page_template = "post.html"
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
+++
|
+++
|
||||||
title = "Example posts"
|
title = "2023"
|
||||||
sort_by = "date"
|
sort_by = "date"
|
||||||
template = "posts.html"
|
template = "posts.html"
|
||||||
page_template = "post.html"
|
page_template = "post.html"
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
+++
|
+++
|
||||||
title = "Example posts"
|
title = "2024-01"
|
||||||
sort_by = "date"
|
sort_by = "date"
|
||||||
template = "posts.html"
|
template = "posts.html"
|
||||||
page_template = "post.html"
|
page_template = "post.html"
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
+++
|
+++
|
||||||
title = "Example posts"
|
title = "2024-02"
|
||||||
sort_by = "date"
|
sort_by = "date"
|
||||||
template = "posts.html"
|
template = "posts.html"
|
||||||
page_template = "post.html"
|
page_template = "post.html"
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
+++
|
+++
|
||||||
title = "Example posts"
|
title = "2024-03"
|
||||||
sort_by = "date"
|
sort_by = "date"
|
||||||
template = "posts.html"
|
template = "posts.html"
|
||||||
page_template = "post.html"
|
page_template = "post.html"
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
+++
|
+++
|
||||||
title = "Example posts"
|
title = "2024-04"
|
||||||
sort_by = "date"
|
sort_by = "date"
|
||||||
template = "posts.html"
|
template = "posts.html"
|
||||||
page_template = "post.html"
|
page_template = "post.html"
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
+++
|
+++
|
||||||
title = "Example posts"
|
title = "2024-09"
|
||||||
sort_by = "date"
|
sort_by = "date"
|
||||||
template = "posts.html"
|
template = "posts.html"
|
||||||
page_template = "post.html"
|
page_template = "post.html"
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
+++
|
+++
|
||||||
title = "Example posts"
|
title = "2024-11"
|
||||||
sort_by = "date"
|
sort_by = "date"
|
||||||
template = "posts.html"
|
template = "posts.html"
|
||||||
page_template = "post.html"
|
page_template = "post.html"
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
+++
|
+++
|
||||||
title = "Example posts"
|
title = "2024"
|
||||||
sort_by = "date"
|
sort_by = "date"
|
||||||
template = "posts.html"
|
template = "posts.html"
|
||||||
page_template = "post.html"
|
page_template = "post.html"
|
||||||
|
|||||||
@ -1,9 +0,0 @@
|
|||||||
+++
|
|
||||||
title = "Zola Test"
|
|
||||||
description = "Test of Zola"
|
|
||||||
date = 2023-01-16
|
|
||||||
[taxonomies]
|
|
||||||
tags= ["Zola", "test"]
|
|
||||||
+++
|
|
||||||
|
|
||||||
This is a test of Zola as a website SSG.
|
|
||||||
34
find-post.sh
Executable file
34
find-post.sh
Executable file
@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Generated by Google Gemini 1.5 on 2025-01-02
|
||||||
|
|
||||||
|
# Function to extract the title from a file
|
||||||
|
extract_title() {
|
||||||
|
grep "^title =" "$1" | sed 's/^title = "//' | sed 's/"$//' | tr -d '\r'
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if the "content" directory exists
|
||||||
|
if [[ ! -d "content/posts" ]]; then
|
||||||
|
echo "Error: 'content/posts' directory not found." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Find all .md files in the "content" directory recursively
|
||||||
|
find content -type f -name "*.md" 2>/dev/null | while read file; do
|
||||||
|
title=$(extract_title "$file")
|
||||||
|
|
||||||
|
# Skip files with 4 or 6 character ISO date titles
|
||||||
|
if [[ ! -z "$title" ]] && [[ ! "$title" =~ ^[0-9]{4}(-[0-9]{2})?$ ]]; then
|
||||||
|
printf "%s\t%s\n" "$title" "$file"
|
||||||
|
fi
|
||||||
|
done | {
|
||||||
|
|
||||||
|
selected=$(fzf --delimiter='\t' --layout=reverse --preview 'cat {2}' --preview-window='right:50%')
|
||||||
|
|
||||||
|
if [[ -n "$selected" ]]; then
|
||||||
|
filepath=$(echo "$selected" | awk -F'\t' '{print $2}')
|
||||||
|
# Open the file in the editor using exec or by redirecting to /dev/tty
|
||||||
|
#exec "$EDITOR" "$filepath" # Most robust solution
|
||||||
|
#OR
|
||||||
|
"$EDITOR" "$filepath" </dev/tty >/dev/tty 2>/dev/tty # Alternative solution
|
||||||
|
fi
|
||||||
|
}
|
||||||
@ -51,14 +51,41 @@ if [[ $shortnote == false ]] ; then
|
|||||||
if ! [ -d $posts_root/$year ]; then
|
if ! [ -d $posts_root/$year ]; then
|
||||||
# Create new year
|
# Create new year
|
||||||
mkdir $posts_root/$year
|
mkdir $posts_root/$year
|
||||||
cp $posts_root/2023/_index.md $posts_root/$year/_index.md
|
|
||||||
|
read -r -d '' TEMPLATE << EOF
|
||||||
|
+++
|
||||||
|
title = "$year"
|
||||||
|
sort_by = "date"
|
||||||
|
template = "posts.html"
|
||||||
|
page_template = "post.html"
|
||||||
|
transparent = true
|
||||||
|
+++
|
||||||
|
|
||||||
|
Posts
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
echo "$TEMPLATE" >> $posts_root/$year/_index.md
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Verify month path
|
# Verify month path
|
||||||
if ! [ -d $posts_root/$year/$month ]; then
|
if ! [ -d $posts_root/$year/$month ]; then
|
||||||
# Create new year
|
# Create new year
|
||||||
mkdir $posts_root/$year/$month
|
mkdir $posts_root/$year/$month
|
||||||
cp $posts_root/2023/_index.md $posts_root/$year/$month/_index.md
|
read -r -d '' TEMPLATE << EOF
|
||||||
|
+++
|
||||||
|
title = "$year-$month"
|
||||||
|
sort_by = "date"
|
||||||
|
template = "posts.html"
|
||||||
|
page_template = "post.html"
|
||||||
|
transparent = true
|
||||||
|
+++
|
||||||
|
|
||||||
|
Posts
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
echo "$TEMPLATE" >> $posts_root/$year/$month/_index.md
|
||||||
fi
|
fi
|
||||||
|
|
||||||
post_path="$posts_root/$year/$month/$post_file_name"
|
post_path="$posts_root/$year/$month/$post_file_name"
|
||||||
Loading…
x
Reference in New Issue
Block a user