dok
dok
CDCloudflare Developers
Created by dok on 10/17/2024 in #pages-help
How do you set the "copyright year" dynamically in Pages?
Thank you very much for confirming, @Walshy | Out of office ! I'll hardcode the year for now and will revisit at a later stage. I am happy to mark this as resolved.
11 replies
CDCloudflare Developers
Created by dok on 10/17/2024 in #pages-help
How do you set the "copyright year" dynamically in Pages?
The postinstall script runs during the build process but neither return the correct year.
11 replies
CDCloudflare Developers
Created by dok on 10/17/2024 in #pages-help
How do you set the "copyright year" dynamically in Pages?
I have attempted two things so far: 1. Setting a const
const currentYear = new Date().getFullYear();
const currentYear = new Date().getFullYear();
and passing that to
copyrightText: `© Foo ${currentYear}`
copyrightText: `© Foo ${currentYear}`
2. Updated my package.json with a postinstall like so:
"scripts": {
"postinstall": "echo 'BUILD_YEAR=$(date +%Y)' >> .env"
}
"scripts": {
"postinstall": "echo 'BUILD_YEAR=$(date +%Y)' >> .env"
}
then similarly to #1,
const currentYear = process.env.BUILD_YEAR || new Date().getFullYear();
const currentYear = process.env.BUILD_YEAR || new Date().getFullYear();
and passing that to
copyrightText: `© Foo ${currentYear}`
copyrightText: `© Foo ${currentYear}`
11 replies