User input on page from template for suggestedName

I have this template frontmatter:

tags: template
description: 'Page creation.'
hooks.newPage:
  suggestedName: "{{today}} {{userInput}}"
  confirmName: true
  command: "Page create"
frontmatter: |
  date: "{{today}}"

and this added to my space scripts:

silverbullet.registerFunction({name: 'userInput'}, (string) => {
  out = editor.prompt("Enter input:", "Name");
  return out;
})

My idea was to have the placeholder userInput which would ask the user for a string which could be used in the suggestedName. It partially works. The problem is that I get the prompt twice.

Am I doing something wrong, is this a bug, or doesn’t this work (intentionally) at all?

Thanks for any help!

1 Like

I would never use a function to get interactive input, but I suppose works :laughing: I guess setting confirmName to false will avoid a second prompt.

2 Likes

Hey Zef, thanks for the reply. This kind of solves the problem. Now I only get the userInput prompt, but not the suggestedName prompt anymore. This could work for me, but still I would like to ask: would it be possible as well to get one prompt for userInput but still the suggestedName prompt as well, in case I want to get sure how the final page name will be?