Managing hugo blog entries in Obsidian

To make using and blogging simpler I have made some scripts, templates and quickadd commands to make a new article for my blog and then be able to run a PowerShell script to publish it.

Environment

For this process to work you will need the following.

Setup

---
title: "{{VALUE:articleName}}"
date: 2022-03-04T15:48:38
tags: ["git"]
categories: ["Development"]
author: ""
toc: false
draft: false
description: "{{VALUE:articleDescription}}"
---

{{VALUE:articleDescription}}

Add more details here before the continue reading link...

<!--more-->

## First heading
module.exports = async (params) => {
    QuickAdd = params;
    const name = await QuickAdd.quickAddApi.inputPrompt("Blog - Article Name");
    const description = await QuickAdd.quickAddApi.inputPrompt("Blog - Article Description");
    const folderName = name.toLowerCase().replace(/ /g, "-");

    QuickAdd.variables["articleName"] = name;
    QuickAdd.variables["articleDescription"] = description;
    QuickAdd.variables["articleFolder"] = folderName;

    console.log(QuickAdd.variables);
};
```dataviewjs
dv.table(["Title","Date"],dv.pages('"400 Reference/Blog/personal"')
    .sort(p => p.date, 'desc')
    .map(b => ['[['+b.file.path+'|'+b.title+']]', b.date])
)
```

# This needs to be the root of the vault. I store this script in Datastore/scripts
# so this goes up two levels.
$root = "$PSScriptRoot/../.."
# This is the path to the content of your blog.
$blogContentRoot = "$root/400 Reference/Blog/personal"
$blogContentRoot = Resolve-Path $blogContentRoot

$checkoutPath = $env:TEMP
$repoFolder = Join-Path $checkoutPath "personal-blog$(Get-Date -Format 'yyyyMMddhhmmss')"
$repoUri = '<git repo path to clone locally.>'

Push-Location

if (!(Test-Path -Path $checkoutPath)) {
    New-Item -ItemType directory -Path $checkoutPath
}
Set-Location $checkoutPath

if (!(Test-Path -Path $repoFolder)) {
    Write-Host("Cloning $repoUri into $repoFolder")
    git clone --depth 1 $repoUri $repoFolder 2>&1 | Write-Host
}
Set-Location $repoFolder

# This is an alias I have to set name and email for local repo, comment
# out if you have this globally set.
git pid

# Copy the blog content to the repo, update the destination path as needed.
Copy-Item -Path $blogContentRoot/* -Destination "$repoFolder/hugo-blog/content/" -Recurse -Force

git status

[string] $status = (& git status)
if (!$status.Contains('working tree clean')) {
    git add .
    git commit -m 'blog update from obsidian'
}

git push origin master

Pop-Location
Remove-Item -Path $repoFolder -Force -Recurse