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

@ -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)) {