fix index files being ignored

This commit is contained in:
protodrew 2024-06-08 17:44:02 -04:00
parent cbe1be0a45
commit 042b032728
1 changed files with 28 additions and 17 deletions

View File

@ -7,9 +7,11 @@ function obsidian-ssg
set vault_path $argv[1] # ~/path/to/obsidian-vault/
set site_path $argv[2] # ~/path/to/final-site/
# must be compliant with pandoc's html template language
set html_template $argv[3] # /path/to/pandoc-template.html
mkdir $site_path"/rss"
set blog_template $argv[3] # /path/to/pandoc-template.html
set note_template $argv[4] # /path/to/pandoc-template.html
set recipe_template $note_template # /path/to/pandoc-template.html
set
mkdir $site_path"rss"
# Atom file and header creation (creates a blog feed and a notes feed)
set feeds $site_path"rss/blog.xml" $site_path"rss/notes.xml" $site_path"rss/recipes.xml"
@ -58,34 +60,44 @@ function obsidian-ssg
set modified (yq -e -N --front-matter=extract '.date-modified' $file) # frontmatter 'date-modified' YYYY-MM-DDTHH:MM:SS
set title (string sub -s 4 -e -1 \"(yq -e -N --front-matter=extract '.aliases' $file)[1]\") # frontmatter 'first alias'
set type (yq -e -N --front-matter=extract '.type' $file) # frontmatter 'type'
set page_tags (yq -e -N --front-matter=extract '.tags' $file) # frontmatter 'tags'
set page_tags (string sub -s 2 \"(string trim --chars=\"- \" \"(yq -e -N --front-matter=extract '.tags' $file )\")\") # frontmatter 'tags'
set date_created (string sub -l 10 $created) # frontmatter 'date-created' YYYY-MM-DD
set date_modified (string sub -l 10 $modified) # frontmatter 'date-modified' YYYY-MM-DD
# convert markddown to html
pandoc $file --standalone --template $html_template --metadata title="$title" -o "$site_path$page_name"
# populate both rss feeds
if not string match -rq 'index|old|draft' $type
# set destination file
set html_template $note_template
switch $type
case blog
set html_template $blog_template
set atom_file $feeds[1] # sets active feed to blog if the input file is of type: blog
case note
set html_template $note_template
set atom_file $feeds[2] # sets active feed to notes if the is of type: note
case recipe
set html_template $recipe_template
set atom_file $feeds[3] # sets active feed to recipes if the is of type: recipe
end
# create entry
echo " <entry>" >>"$atom_file"
echo " <title>"$title"</title>" >>"$atom_file"
echo " <summary>$summary</summary>" >>"$atom_file"
echo " <published>$created""Z""</published>" >>"$atom_file"
echo " <updated>$modified""Z""</updated>" >>"$atom_file"
echo " <link href=\"https://proto.garden/$page_name\"/>" >>"$atom_file"
echo " <id>tag:proto.garden,"$date_created":$path</id>" >>"$atom_file"
echo " <content type=\"xhtml\"><div xmlns=\"http://www.w3.org/1999/xhtml\">$content</div></content>" >>"$atom_file"
echo " </entry>" >>"$atom_file"
end
# convert markddown to html
pandoc $file --standalone --template $html_template --metadata title="$title" --metadata date-modified="$date_modified" --metadata date-created="$date_created" -o "$site_path$page_name"
# create entry
echo " <entry>" >>"$atom_file"
echo " <title>"$title"</title>" >>"$atom_file"
echo " <summary>$summary</summary>" >>"$atom_file"
echo " <published>$created""Z""</published>" >>"$atom_file"
echo " <updated>$modified""Z""</updated>" >>"$atom_file"
echo " <link href=\"https://proto.garden/$page_name\"/>" >>"$atom_file"
echo " <id>tag:proto.garden,"$date_created":$path</id>" >>"$atom_file"
# TODO; ftx to allow for multi-line tags
# set categories (string trim --chars=, "$page_tags")
# for category in (string split " " ",$categories")
# echo "<category term=\"$category\"/>" >>"$atom_file"
# end
echo " <content type=\"xhtml\"><div xmlns=\"http://www.w3.org/1999/xhtml\">$content</div></content>" >>"$atom_file"
echo " </entry>" >>"$atom_file"
end
for file in **/*.html
@ -109,5 +121,4 @@ function obsidian-ssg
# cleanup markdown files
cd $site_path
rm **/*.md
# sitemap-generator https://proto.garden
end