在 github/netlify 上使用 hugo 从 markdown 自动构建 PDF

Automatically build PDF from markdown using hugo on github/netlify

我正在使用 hugoacademic 主题)从 github 上的源代码构建网站,在 netlify.

上构建和托管

在这个站点中,我有一个特定的页面,它是从 markdown 文件 (.md) 呈现的,我也希望将其作为 .pdf 提供。 目前,每次对 .md 源进行编辑时,我都必须手动生成并推送 .pdf,但我希望这是自动化的。

我尝试过的一种方法是在页面中嵌入一个JavaScript window.print()按钮,以便用户可以将页面打印到文件中,但这有点不雅。

我不确定这是否可以通过 hugogithubnetlify 挂钩或其他方式完成。

非常感谢任何指向正确方法的指示。

经过更多研究, 似乎实现这一目标的最佳方法是使用持续集成工具,例如 Travis。 有几种可能的方法,包括:

  1. https://harshjv.com/blog/setup-latex-pdf-build-using-travis-ci/
  2. https://github.com/PHPirates/travis-ci-latex-pdf
  3. https://gist.github.com/willprice/e07efd73fb7f13f917ea
  4. https://vaibhavsagar.com/blog/2015/02/26/automate-resume/
  5. https://github.com/livioso/pandoc-travis-setup

所有的方法都非常相似,基本上都是这样做的:

  1. 创建一个 GitHub 授权令牌
  2. 指示 Travis-CI 在新提交时构建 PDF
  3. 将 PDF 上传到您选择的分支机构和位置