Layout


This can be used to build, modify, or reconstruct the _quarto.yml page.


library(ramp.uganda)

In a Quarto website, the sidebar layout is found in _quarto.yml. The sidebar is formatted in text that creates the nested menus at the right hand side of the webpage, with nested sub-menus that link to view information by region or district. The following creates a new _quarto.yml file.

If it ever needs to be updated, follow the instructions.


NOTE: Proceed with Caution! the suffix yml tells us we’re working with a yaml stands for yet another markup language. Markup languages are a “best bad solution” to document preparation. Syntax is a glorious pain in the butt to learn and implement. Before you modify something, it’s good practice to save a backup that works.


top

This is the text at the top of _quarto.yml

top = paste(
"project:\n",
"  type: website\n",
"  output-dir: ../UW/uganda_intelligence\n",
"\n",
"website:\n",
"  title: Malaria in Uganda\n",
"  navbar:\n",
"    left:\n",
"      - href: index.qmd\n",
"        text: Home\n",
"      - facility_data.qmd\n",
"      - text: Vector Control\n",
"        menu:\n",
"          - irs.qmd\n",
"          - itn.qmd\n",
"      - text: Site\n",
"        menu:\n",
"          - maintain/layout.qmd\n",
"          - maintain/region_pages.qmd\n",
"          - maintain/district_pages.qmd\n",
"      - about.qmd\n",
"  sidebar:\n",
"    style: \"docked\"\n",
"    search: true\n",
"    collapse-level: 1\n",
"    contents:\n",
"      - section: uganda.qmd\n",
"        contents:\n",
"        - irs.qmd\n",
"        - itn.qmd      \n", sep="")

bottom

This is the text at the bottom of _quarto.yml

bottom = paste(
"format:\n",
"  html:\n", 
"    theme: cosmo\n", 
"    css: styles.css\n", 
"    toc: true\n\n", 
"editor: visual\n", sep="")

make_sidebar

This pastes the top, then builds the menus, then pastes the bottom

make_sidebar = function(){
  ofile = paste("./_quarto.yml", sep="") 
  cat(top, file=ofile)
  for(i in c(1:15)[-7]){
    rdir = region_dir$region_dir[i]
    rname = region_dir$region_name[i]
    ix = which(district_dir$in_region == rname) 
    cat(paste("      - section: ", rdir, "/", rdir, ".qmd\n", sep=""), file=ofile, append=TRUE)
    cat(paste("        contents: \n"), file=ofile, append=TRUE) 
    ix = which(district_dir$in_region == rname)
    for(j in ix){
      ddir = district_dir$dir[j]
      cat(paste("        - section: ", ddir, "/", ddir, ".qmd\n", sep=""), file=ofile, append=TRUE)
      cat("          contents: \n", file=ofile, append=TRUE)
      cat(paste("           - ", ddir, "/facility_data.qmd\n", sep=""), file=ofile, append=TRUE)
      cat(paste("           - ", ddir, "/vector_control.qmd\n", sep=""), file=ofile, append=TRUE)
      cat(paste("           - ", ddir, "/movies.qmd\n", sep=""), file=ofile, append=TRUE)
    }
  }
  cat("      - section: kampala_district/kampala_district.qmd\n", file=ofile, append=TRUE)
  cat("        contents: \n", file=ofile, append=TRUE)
  cat(paste("         - kampala_district/facility_data.qmd\n", sep=""), file=ofile, append=TRUE)
  cat(paste("         - kampala_district/vector_control.qmd\n", sep=""), file=ofile, append=TRUE)
  cat(paste("         - kampala_district/movies.qmd\n", sep=""), file=ofile, append=TRUE)
  cat(bottom, file=ofile, append=TRUE)
  print(ofile)
}

Updating

To rebuild (or to modify) _quarto.yml

  • Modify the top or the bottom or make_sidebar

  • Run make_sidebar

make_sidebar()
  • Open the new _quarto.yml and check it for errors

  • Back up the old _quarto.yml

file.copy("../_quarto.yml", "./_old_quarto.yml")
  • Replace the existing
file.copy("./_quarto.yml", "../_quarto.yml", overwrite=TRUE)