Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable search #495

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions R/build_site.R
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ build_site <- function(path = ".", quiet = !interactive(), preview = TRUE, overr

# At the end, a sitemap is created with our aggregated pages.
build_sitemap(pkg$dst_path, paths = html_pages$paths, quiet = quiet)
pkgdown::build_search(pkg)

pkgdown::preview_site(pkg, "/", preview = preview)

Expand Down
2 changes: 1 addition & 1 deletion R/utils-xml.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ fix_callouts <- function(nodes = NULL) {
xml2::xml_set_attr(h3, "class", "callout-title")
inner_div <- xml2::xml_parent(h3)
# remove the "section level3 callout-title" attrs
xml2::xml_set_attr(inner_div, "class", "callout-inner")
xml2::xml_set_attr(inner_div, "class", "callout-inner section")
# Get the heading IDS (because we use section headings, the IDs are anchored
# to the section div and not the heading element)
# <div class="section level3 callout-title callout-inner">
Expand Down
3 changes: 3 additions & 0 deletions R/utils-yaml.R
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,16 @@ create_pkgdown_yaml <- function(path) {
handout <- if (is.null(usr$handout)) "~" else siQuote(usr$handout)
handout <- if (isTRUE(handout)) "files/code-handout.R" else handout
yaml <- get_yaml_text(template_pkgdown())
calls <- sys.calls()
is_prod <- in_production(calls)
# Should we display DOI info? If so, parse the URL and return the doi
# note that a missing doi will return nothing
doi <- sub("^[/]", "", xml2::url_parse(usr$doi)$path)
doi <- if (length(doi) == 1L && nzchar(doi)) siQuote(doi) else "~"
yaml <- whisker::whisker.render(yaml,
data = list(
# Basic information
url = if (is_prod) metadata_url(usr) else "~",
version = siQuote(utils::packageVersion("sandpaper")),
config = siQuote(path_config(path)),
title = siQuote(usr$title),
Expand Down
1 change: 1 addition & 0 deletions inst/templates/pkgdown-yaml-template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# If you want to make changes, please edit {{ config }}
# ------------------------------------------------------------------ information
title: {{ title }} # needed to set the site title
url: {{ url }}
home:
title: Home
strip_header: true
Expand Down