How can I set title based on the filename?

How everyone!

I’d like to make a book template, and I want to get the filename as a variable and set document title based on it, how can I make it?

For example, the file is named 01-mathematical-foundation.typ, I want to get the filename to use it in the document title, how to do it?

01-mathematical-foundation.typ => Chapter 1 Math Foundation

It is not possible to read the filename from within Typst. The only option would be to compile your document locally, use a script to read the filename and provide it to the document with sys.inputs:

typst compile --input "filename=$FILE" "$FILE"