Add featured post flag for homepage
Some checks failed
Build / build (push) Has been cancelled

This commit is contained in:
Neeldhara Misra 2026-06-22 13:08:56 +05:30
parent e7227844c7
commit 3ced32a4d0
19 changed files with 63 additions and 5 deletions

View file

@ -34,7 +34,10 @@ Search for **Blog Family Sync** in the command palette:
Preview starts the matching Astro dev server if the configured local URL is not
already responding. Publish syncs first, runs that target's build command,
commits staged content changes, and pushes to Forgejo.
commits staged content changes, and pushes to Forgejo. For the seven `allblogs`
targets, publish also refreshes and pushes the `home` repo's
`content/blog-index.json` so `neeldhara.blog` redeploys with the newest
featured/latest entries.
## Notes

View file

@ -11,6 +11,7 @@ const NPM = `${NODE_BIN}/npm`;
const BLOGS_ROOT = "/Users/neeldhara/forgejo/blogs";
const ALLBLOGS_REPO = `${BLOGS_ROOT}/allblogs`;
const MICRO_REPO = `${BLOGS_ROOT}/micro`;
const HOME_REPO = `${BLOGS_ROOT}/home`;
const DEFAULT_TARGETS = [
{
@ -557,14 +558,41 @@ module.exports = class BlogFamilySyncPlugin extends Plugin {
this.updateStatusBar(`Blog sync: pushing ${target.label}...`);
const output = await this.runShellCommand(publishCommand, repoFolder);
let homeOutput = "";
if (path.resolve(target.repoFolder) === path.resolve(ALLBLOGS_REPO)) {
homeOutput = await this.publishHomeIndex();
}
this.updateStatusBar("Blog sync: published");
new Notice(
output.includes("No staged changes")
? `No ${target.label} changes to publish.`
: `${target.label} changes pushed.`,
[
output.includes("No staged changes")
? `No ${target.label} changes to publish.`
: `${target.label} changes pushed.`,
homeOutput
? homeOutput.includes("No homepage index changes")
? "Homepage index unchanged."
: "Homepage index pushed."
: "",
]
.filter(Boolean)
.join(" "),
);
}
async publishHomeIndex() {
this.updateStatusBar("Blog sync: refreshing homepage index...");
const command = [
`${shellQuote(NPM)} run refresh:index`,
"git add content/blog-index.json",
'if git diff --cached --quiet; then echo "No homepage index changes to publish."; else git commit -m "Refresh homepage blog index"; fi',
"git push",
].join(" && ");
return await this.runShellCommand(command, HOME_REPO);
}
async ensureDevServer(target) {
const baseUrl = normalizeBaseUrl(target.devServerUrl);
if (await urlResponds(baseUrl)) {

View file

@ -1,7 +1,7 @@
{
"id": "microblog-sync",
"name": "Blog Family Sync",
"version": "0.4.0",
"version": "0.5.0",
"minAppVersion": "1.5.0",
"description": "Sync the public Obsidian blog folders with the local Astro blog repos.",
"author": "Neeldhara Misra",