bookdown icon indicating copy to clipboard operation
bookdown copied to clipboard

TOC page

Open hadley opened this issue 3 years ago • 3 comments

It would be useful to have complete (at least up to third level) table of contents on a single page. Would link to it from "Table of contents" in left hand sidebar, and maybe introduce it as a virtual first chapter that's linked from index?

hadley avatar Nov 05 '20 18:11 hadley

Similar request for gitbook() format in #967

cderv avatar Mar 30 '21 17:03 cderv

As it won't originate from an Rmd it'd be important for its name to be very specific.

I'd like it to have a single name so that it's easy to tackle for OG/Twitter metadata. I'll pretend it's called "table-of-contents.html" in that PR, but if there's an Rmd whose title gets the same path, that path needs to be changed.

maelle avatar Jun 14 '21 12:06 maelle

When adding the TOC it will be important to tweak the metadata description accordingly. Rough code via #1034

    if (file == "table-of-contents.html") {
      description_string <- if (!is.na(xml2::xml_attr(og_description, "content"))) {
        paste(
          "Table of contents;",
          xml2::xml_attr(og_description, "content")
        )
      } else {
        "Table of contents"
      }

      set_content(og_description, description_string)
      set_content(general_description, description_string)
    }

maelle avatar Jun 25 '21 08:06 maelle