Skip to content

使用 theme_inject 在指定目录下的所有子目录 html 中嵌入 css #35

Answered by stevenjoezhang
aoemon asked this question in Q&A
Discussion options

You must be logged in to vote

好的,我知道原因了。head 注入点在 page 变量被赋值前,被 Nunjucks 预处理了,因此导致 page.pathundefined;如果直接修改 layout 目录下的模版就不会有这个问题。
这个改起来需要一些时间,不过你的需求其实可以绕开这个问题,那就是用 CSS 的相邻元素选择器

.sub-menu + .content {
  padding-top: 40px;
}

这样就不需要对路径进行判断。

Replies: 5 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by stevenjoezhang
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #35 on December 12, 2020 09:34.