-
I am trying to include a markdown file in a golem app.
app_ui <- function(request) {
tagList(
navbarPage(
"Title",
tabPanel(
"Home",
icon = icon("home"),
mod_markdown_ui("home")
))}
app_server <- function(input, output, session) {
# Markdown content
mod_markdown_server("home", "home.md")
}
#' Markdown UI Module
#'
#' @param id Module ID
#'
#' @return A UI output for rendering Markdown inside a fixed column layout
#' @noRd
mod_markdown_ui <- function(id) {
ns <- NS(id)
fluidRow(
col_6(
offset = 2,
uiOutput(ns("markdown_content"))
)
)
}
#' Markdown Server Module
#'
#' @param id Module ID
#' @param file_name Name of the Markdown file
#'
#' @noRd
mod_markdown_server <- function(id, file_name) {
moduleServer(id, function(input, output, session) {
output$markdown_content <- renderUI({
req(file_name) # Ensure file_name is provided
includeMarkdown(system.file(
"assets",
file_name,
package = golem::pkg_name()
))
})
})
}
## To be copied in the UI
# mod_markdown_ui("markdown_1")
## To be copied in the server
# mod_markdown_server("markdown_1")
*Hello world!* This code works if I execute: devtools::load_all()
run_app() (or similar local installation), but it doesn't if I do the following: devtools::build() and then if I do an Instead of rendering the markdown, what I get in the terminal is the following prompt, that prevents the correct execution of the app: The golem-config.yml file doesn't exist.
It's possible that you might not be in a {golem} based project.
Do you want to create the {golem} files?
1: Yes
2: No Please note that the What am I doing wrong? Is it the way I'm referencing the markdown file path? Thanks a lot for your help. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I learned a couple of things while writing this question, and I assume the answer is the same as in here: #903. In particular, I think my mistake was using It's a pity that the error message is not extra clear though. |
Beta Was this translation helpful? Give feedback.
I learned a couple of things while writing this question, and I assume the answer is the same as in here: #903. In particular, I think my mistake was using
golem::pkg_name()
in production, instead of hardcoding the app's name. Usingapp_sys()
is of course the way to go.It's a pity that the error message is not extra clear though.