27 lines
1,021 B
Text
27 lines
1,021 B
Text
#!/usr/bin/env nu
|
|
# on-content-published.nu
|
|
#
|
|
# Triggered by NATS subject: evol.website.prod.content.published
|
|
#
|
|
# Environment:
|
|
# NATS_SUBJECT — matched NATS subject string
|
|
# NATS_PAYLOAD — JSON payload from the publisher
|
|
#
|
|
# Expected payload shape:
|
|
# { content_type: "blog", language: "en", id: "my-new-post" }
|
|
|
|
let payload = $env.NATS_PAYLOAD | from json
|
|
|
|
print $"[content-published] type=($payload.content_type) lang=($payload.language) id=($payload.id)"
|
|
|
|
# Rebuild the content index for this type/language so the next request
|
|
# picks it up immediately (complements the in-memory cache flush done
|
|
# by the cache_invalidate step before this script runs).
|
|
# Adjust path to your actual content build script.
|
|
let build_script = $"($env.SITE_CONTENT_PATH)/scripts/content/build-localized-content.sh"
|
|
|
|
if ($build_script | path exists) {
|
|
run-external $build_script $payload.content_type $payload.language
|
|
} else {
|
|
print $"[content-published] build script not found at ($build_script), skipping rebuild"
|
|
}
|