Bereinigt von Pilot-Spezifika (echte Inhalte, Erzbistum-Hamburg-Bezuege, Domain-Werte) - install.env und hugo.toml [params] mit generischen Platzhaltern. docs/ komplett entfernt: Konzept, Manifest, Installations- anleitungen leben jetzt auf der Projekt-Website statt redundant im Repo, README verweist dorthin. Decap-CMS-Version von einer floatenden ^3.0.0 auf ein festes 3.15.1 gepinnt.
36 lines
1.6 KiB
Ruby
Executable File
36 lines
1.6 KiB
Ruby
Executable File
#!/usr/bin/env ruby
|
|
# Translates the form field "veroeffentlicht" (Decap, positive polarity: on
|
|
# = published) into Hugo's native draft field (inverted: draft: true =
|
|
# unpublished) - only in the local _content copy (not in the content repo),
|
|
# before every Hugo build. Decap cannot write a boolean field inverted into
|
|
# a differently named frontmatter field, hence this translation step
|
|
# instead of a direct CMS mapping. Must run before
|
|
# compute-methoden-sichtbarkeit.rb, which in turn reads the draft field set
|
|
# here for variants (that script aborts if it still finds untranslated
|
|
# "veroeffentlicht" fields, see there).
|
|
require_relative 'lib/frontmatter'
|
|
|
|
root = File.expand_path('..', __dir__)
|
|
varianten_dir = File.join(root, '_content', 'varianten')
|
|
|
|
changed = 0
|
|
if Dir.exist?(varianten_dir)
|
|
Dir.glob(File.join(varianten_dir, '*', 'index.md')).each do |file|
|
|
result = Frontmatter.read(file)
|
|
next unless result
|
|
fm, body = result
|
|
|
|
# Missing "veroeffentlicht" (e.g. a variant committed directly via the
|
|
# PR path, bypassing Decap's boolean widget with its "default: false")
|
|
# must translate to unpublished, not be skipped untranslated - a
|
|
# missing "draft" frontmatter key defaults to visible in Hugo, so
|
|
# skipping this file entirely would publish it unintentionally.
|
|
veroeffentlicht = fm.key?('veroeffentlicht') ? fm.delete('veroeffentlicht') == true : false
|
|
fm['draft'] = !veroeffentlicht
|
|
Frontmatter.write(file, fm, body, feldreihenfolge: Frontmatter::VARIANTEN_FELDER)
|
|
changed += 1
|
|
end
|
|
end
|
|
|
|
puts "veroeffentlicht -> draft übersetzt: #{changed} Variante(n)"
|