39 lines
712 B
Markdown
39 lines
712 B
Markdown
status: #dir-page
|
|
Date: 2024-01-17
|
|
___
|
|
# html-css
|
|
|
|
```dataviewjs
|
|
const A_BUNCH_OF_FILES = ['html.md','css.md']
|
|
|
|
for (const eachFile of A_BUNCH_OF_FILES) {
|
|
const page = dv.page(eachFile)
|
|
if (!page) continue
|
|
const startAtLevel = 2
|
|
const content = await dv.io.load(page.file.path)
|
|
const toc = content.match(new RegExp(`^#{${startAtLevel},} \\S.*`, 'mg'))
|
|
.map(heading => {
|
|
const [_, level, text] = heading.match(/^(#+) (.+)$/)
|
|
const link = dv.current().file.path + '#' + text
|
|
return '\t'.repeat(level.length - startAtLevel) + `1. [[${link}|${text}]]`
|
|
})
|
|
dv.header(2, 'Table of contents for ' + page.file.name)
|
|
dv.paragraph(toc.join('\n'))
|
|
}
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---
|
|
# References
|
|
|
|
|
|
|