希望增加页面目录功能

之前有人做过有序列表的CSS hack,我用的就是他的方案,但是我忘了在哪儿看到的了。只能把代码分享一下了,下面CSS放在custom.css里,用的时候在块上给个 #ol的tag就可以了。例如:

image


/* Ordered list */
/* numbered lists 0.3 20210605 */
/* usage : tag parent block with #ol or #.v-ol*/

.ls-block[data-refs-self*="ol"]
  > .block-children-container
  > .block-children
  > .ls-block {
  counter-increment: lvlNumber;
}
.ls-block[data-refs-self*="ol"]
  > .block-children-container
  > .block-children
  > .ls-block
  > div
  > div
  > a
  > .bullet-container:before {
  content: counters(lvlNumber, ".") ".";
  position: absolute;
  display: block;
}
.ls-block[data-refs-self*="ol"]
  > .block-children-container
  > .block-children
  > .ls-block
  > .block-children-container
  > .block-children
  > .ls-block {
  counter-increment: sublvlNumber;
}
.ls-block[data-refs-self*="ol"]
  > .block-children-container
  > .block-children
  > .ls-block
  > .block-children-container
  > .block-children
  > .ls-block
  > div
  > div
  > a
  > .bullet-container:before {
  content: counters(lvlNumber, ".") "." counters(sublvlNumber, ".") ".";
  position: absolute;
  max-width: 60px;
  padding-right: 0px;
  width: 40px;
}
.ls-block[data-refs-self*="ol"]
  > .block-children-container
  > .block-children
  > .ls-block
  > .block-children-container
  > .block-children
  > .ls-block
  > div
  > div
  > .block-control {
  width: 30px !important;
  margin-left: -0.75em;
}
.ls-block[data-refs-self*="ol"]
  > .block-children-container
  > .block-children
  > .ls-block
  > .block-children-container
  > .block-children {
  padding-left: 0.4em;
}

/* hide bullets */
.ls-block[data-refs-self*="ol"]
  > .block-children-container
  > .block-children
  > .ls-block
  > .block-children-container
  > .block-children
  div
  .bullet-container:before {
  content: "";
}
.ls-block[data-refs-self*="ol"]
  > .block-children-container
  > .block-children
  > .ls-block
  > div
  > div
  > a
  > .bullet-container
  > .bullet {
  visibility: hidden;
}
.ls-block[data-refs-self*="ol"]
  > .block-children-container
  > .block-children
  > .ls-block
  > .block-children-container
  > .block-children
  > .ls-block
  > div
  > div
  > a
  > .bullet-container
  > .bullet {
  visibility: hidden;
}

这个插件导出html的时候样式就失效了

应该是Logseq的导出不支持macro renderer,你可以尝试在github上给Logseq报个bug。

这三个插件我都安装了,非常实用,感谢开发者! 遗憾就是现在移动端还不支持插件,在移动端没法显示目录。

从直观上来看,右栏的目录如果能实时同步地生成文章的大纲就太好了。 :face_with_raised_eyebrow:

有相关目录的插件的。你可以去插件市场搜搜,我记得是TOC-Generator好像,sethyuan大佬开发的

是的,插件名是TOC Generator。“同步正文的大纲”这可以通过在右侧栏的某个页面,例如Contents里插入一个动态TOC来实现。我个人就是这么用的,项目的README里有说明和动图。