name: template
functions:
  # API
  renderTemplate:
    path: api.ts:renderTemplate
  cleanTemplate:
    path: api.ts:cleanTemplate

  insertTemplateText:
    path: template.ts:insertTemplateText


  indexTemplate:
    path: ./index.ts:indexTemplate
    events:
    - page:indexTemplate

  templateSlashCommand:
    path: ./template.ts:templateSlashComplete
    events:
    - slash:complete

  insertSlashTemplate:
    path: ./template.ts:insertSlashTemplate

  # Template commands
  applyLineReplace:
    path: ./template.ts:applyLineReplace
  insertFrontMatter:
    redirect: insertTemplateText
    slashCommand:
      name: frontmatter
      description: Insert page frontmatter
      value: |
        ---
        |^|
        ---
  makeH1:
    redirect: applyLineReplace
    slashCommand:
      name: h1
      description: Turn line into h1 header
      match: "^#*\\s*"
      replace: "# "
  makeH2:
    redirect: applyLineReplace
    slashCommand:
      name: h2
      description: Turn line into h2 header
      match: "^#*\\s*"
      replace: "## "
  makeH3:
    redirect: applyLineReplace
    slashCommand:
      name: h3
      description: Turn line into h3 header
      match: "^#*\\s*"
      replace: "### "
  makeH4:
    redirect: applyLineReplace
    slashCommand:
      name: h4
      description: Turn line into h4 header
      match: "^#*\\s*"
      replace: "#### "
  insertCodeBlock:
    redirect: insertTemplateText
    slashCommand:
      name: code
      description: Insert fenced code block
      value: |
        ```|^|
        
        ```

  insertHRTemplate:
    redirect: insertTemplateText
    slashCommand:
      name: hr
      description: Insert a horizontal rule
      value: "---"
  insertTable:
    redirect: insertTemplateText
    slashCommand:
      name: table
      description: Insert a table
      boost: -1 # Low boost because it's likely not very commonly used
      value: |
        | Header A | Header B |
        |----------|----------|
        | Cell A|^| | Cell B |
  quickNoteCommand:
    path: ./template.ts:quickNoteCommand
    command:
      name: "Quick Note"
      key: "Alt-Shift-n"
  dailyNoteCommand:
    path: ./template.ts:dailyNoteCommand
    command:
      name: "Open Daily Note"
      key: "Alt-Shift-d"
  weeklyNoteCommand:
    path: ./template.ts:weeklyNoteCommand
    command:
      name: "Open Weekly Note"
      key: "Alt-Shift-w"

  instantiateTemplateCommand:
    path: ./template.ts:instantiateTemplateCommand
    command:
      name: "Template: Instantiate Page"
  insertSnippet:
    path: ./template.ts:insertSnippet
    command:
      name: "Template: Insert Snippet"
    slashCommand:
      name: snippet
      description: Insert a snippet
  applyPageTemplateCommand:
    path: ./template.ts:applyPageTemplateCommand
    slashCommand:
      name: page-template
      description: Apply a page template
  insertTodayCommand:
    path: "./template.ts:insertTemplateText"
    slashCommand:
      name: today
      description: Insert today's date
      value: "{{today}}"
  insertTomorrowCommand:
    path: "./template.ts:insertTemplateText"
    slashCommand:
      name: tomorrow
      description: Insert tomorrow's date
      value: "{{tomorrow}}"