Skip to content

Feature: implement 'formats.pdf.url' #61

Open
@nbanyan

Description

As discussed in issue #59, this config option does not seem to be used. The use case presented is that when hosting the website in GitLab the site is placed in a sub-site directory user.gitlab.com/docs/.... For the download buttons this is less of an issue when the href method works. Another possible use case could be wanting all the PDFs for the entire site as a single directory for easy copy and distribution.

Possible initial scripting to integrate this with the download.href method.

def href(page: Page, **kwargs) -> str:
  """The value of the 'href' attribute."""
  
  # Custom website sub-directory to prepend to URLs
  url_prefix = 'prefix_directory_from_yaml'
  
  # Add relative pathing to docs_dir
  for i in range(len(page.ancestors)):
    url_prefix = os.path.join(os.path.pardir, url_prefix)

  # Append the PDF URL for the page and normalize
  return os.path.normpath(os.path.join(url_prefix, page.formats['pdf']['url']))

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions