Best way to provide Generic Support

Hi - First post !

I have a function create UI help buttons by id
and a function invoked from within sever when corresponding id is clicked



#'' Create button input for Help (classed help for .css)
#' @param id The inputId for the help button
#' @label label for help button
help_ui <- function(id, label){
  actionButton(inputId = id,  label=label, icon = icon("info-circle"), class="help")

#' Show modal help file corresponding to input name
#' @param ref - Name of an input$ref
showHelp <- function(ref){

# Define a help file where we keep markdown docs
  f <- paste0("./doc/en/", ref)
# Define a fall back if help files have not been maintained
    f <- paste0("./doc/en/", "")
# Display help 
    easyClose=TRUE, size= "l"

I define help buttons within UI.R as follows

shinyUI(fluidPage( # flexible layout function
  # Title
  titlePanel("Minimal application"),
  sidebarLayout(  # standard inputs on sidebar, outputs in main area layout
    sidebarPanel( # sidebar configuration

     help_ui("", label = "Menu Help"),

      textInput(inputId = "comment",      # this is the name of the
                # variable- this will be passed to server.R
                label = "Say something?", # display label for the variable
                value = ""                # initial value
    # Show a plot of the generated distribution
    mainPanel( # main output configuration
      h3("This is you saying it"), # title with HTML helper
      help_ui("", label = "What to expect"),
      textOutput("textDisplay")    # this is the name of the output
      # element as defined in server.R

And have corresponding observrs to throws up modal help when wanted


library(shiny) # load Shiny at the top of both scripts

shinyServer(function(input, output) { # define application in here

  output$textDisplay <- renderText({ # mark function as reactive
    # and assign to output$textDisplay for passing to ui.R
    paste0("You said '", input$comment,           # from the text
           "'. There are ", nchar(input$comment), # input control as
           " characters in this.")                # defined in ui.R

  observeEvent(input$, showHelp(""))
  observeEvent(input$, showHelp(""))
  # Many more help texts here...

Finally I have simple help texts in markdown

Eg. ./doc/en/"

# Apologies - This help file is undergoing maintenance
This is horribly unhelpful but a mistake - so we have logged the error and will act soon

Eg ./doc/en/

# Navigation help
Click on stuff !

My Question

I would like to replace the many obervers with one generic for input ids that are the same name as a markdown file

#  Replace  these 
observeEvent(input$, showHelp(""))

(of which there are very many) with something generic

    # Define values of input that have ".md in their name"
      input_defs <- reactiveValuesToList(input)
      the_names = names(input_defs)
      help_inputs = grep(".md", the_names, value = TRUE )

    # Excuse for loop its just easy to grasp is a variable holding some input$`` 
    for ( in help_inputs) {

      # Select input button that has been incremented ( if any )
       if(  LOGIC NEEDED < was clicked>  )   showHelp(

Any help greatfully received (and a completely different approach also welcomed)