usnistgov / OSCAL-Pages

Open Security Controls Assessment Language (OSCAL) Website Content
https://pages.nist.gov/OSCAL/
Other
7 stars 12 forks source link

Add `date` to all articles correcting RSS timestamps #61

Closed nikitawootten-nist closed 10 months ago

nikitawootten-nist commented 10 months ago

This PR adds a date to all pages using the timestamp of the first commit. This corrects the RSS feeds generated in #47.

Also fixed:

For posterity, the following script was used:

#!/usr/bin/env bash
# dateify

set -Eeuo pipefail

function creation_date() {
    git log --follow --format=%ad --date=iso $1 | tail -1
}

while IFS= read -r -d '' file
do
    if [ "$(head -n1 $file)" = "---" ]; then
        if ! grep -q "date: " $file; then
            date=$(creation_date $file)
            echo $file $date
            awk "NR==3{print \"date: $date\"}1" "$file" > .temp_file && mv .temp_file "$file"
        fi
    fi
done <   <(git ls-files -z src/content | grep -z '.md$')