Set frontmatter variables from templates? How?

Another option is to adapt this script to your use case: