简体   繁体   English

在 TOC 之前将代码添加到 Bookdown gitbook 模板

[英]Add code to Bookdown gitbook template before TOC

I'm creating a gitbook using bookdown, and the designer wants to put a banner at the top of the book, that is, across the entire page above both the TOC and the chapter text.我正在使用 bookdown 创建一个 gitbook,设计者想在书的顶部放置一个横幅,即横跨 TOC 和章节文本上方的整个页面。

If I use the before_body attribute in the YAML, bookdown inserts the code after the TOC, so the banner is only at the top of the chapter.如果我在 YAML 中使用before_body属性,bookdown 会在 TOC 之后插入代码,所以横幅只在章节顶部。 Gitbook doesn't seem to allow for the template: attribute. Gitbook 似乎不允许使用template:属性。

Any suggestions for how I can squeeze a line of HTML right after the < body > tag to make my designer happy?关于如何在 <body> 标记之后挤压一行 HTML 以使我的设计师满意的任何建议? :) :)

I managed to solve this myself--it turns out that although officially the gitbook theme doesn't allow the template: attribute, in practice it does.我自己设法解决了这个问题——事实证明,虽然官方的 gitbook 主题不允许template:属性,但实际上它确实允许。 So I just grabbed the existing template, hard-coded my banner after the < body > tag, and referenced my new template in the YAML.所以我只是抓住了现有的模板,在 <body> 标签之后硬编码了我的横幅,并在 YAML 中引用了我的新模板。 I hope this is helpful for anybody else who runs into this problem!我希望这对遇到此问题的其他人有所帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM