---
title: "minidown::mini_document"
author: "Atsushi Yasumoto"
date: "`r Sys.Date()`"
output:
  minidown::mini_document:
    framework: all
    code_folding:
      source: show
      output: show
      message: hide
      warning: hide
      error: show
    results_folding: hide
    toc: true
    toc_float: true
    toc_highlight: true
    tabset: true
    number_sections: true
    anchor_sections: false
    self_contained: false
    code_download: false
    keep_md: false
---

<!-- Include skeleton.Rmd and serve download button -->

::: {style='text-align: right'}
[Manual](pkgdown/index.html){.button}
[Download Rmd](skeleton.Rmd){download=minidown.Rmd .button}
:::

```{r include=FALSE}
file.copy(
  system.file(package = "minidown", "rmarkdown", "templates", "mini_document", "skeleton", "skeleton.Rmd"),
  "skeleton.Rmd",
  overwrite = TRUE
)
```

```{r child="skeleton.Rmd"}

```

<!-- Theme changer -->

```{r, include=FALSE}
all_framework <- identical(
  rmarkdown::metadata$output[["minidown::mini_document"]]$framework,
  "all"
)
```

```{=html}
<script src="themer.js"></script>
<link rel="stylesheet" href="themer.css"></link>
```

```{r, echo=FALSE, eval=all_framework}
htmltools::tags$aside(htmltools::tags$p(
  htmltools::tags$label("Framework:", "for" = "select-framework"),
  htmltools::tags$select(
    purrr::imap(minidown:::frameworks, function(framework, nm) {
      htmltools::tags$option(
        nm, value = nm, "data-version" = framework$version
      )
    }),
    id = "select-framework",
    `data-minidown` = packageVersion("minidown")
  ),
  htmltools::tags$label("Theme:", id = "label-select-theme"),
  purrr::imap(minidown:::frameworks, function(framework, fnm) {
    htmltools::tags$select(
      purrr::map(names(framework$stylesheet), function(tnm) {
        htmltools::tags$option(tnm, value = paste0(fnm, '-', tnm, '.css'))
      }),
      id = paste0("select-theme-", fnm)
    )
  }),
  htmltools::tags$button("Apply!", id = "button-go")
), id = "aside-select-framework")
```
