Skip to content

Commit

Permalink
Add generated table of contents (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
Thalhammer authored Jul 4, 2024
1 parent c55133c commit e9f3224
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Install requirements
run: |
pip install -r requirements.txt
wget https://github.com/gohugoio/hugo/releases/download/v0.102.3/hugo_extended_0.102.3_Linux-64bit.deb -O /tmp/hugo.deb
wget https://github.com/gohugoio/hugo/releases/download/v0.128.2/hugo_extended_0.128.2_linux-amd64.deb -O /tmp/hugo.deb
sudo dpkg -i /tmp/hugo.deb
- name: Build Website
run: |
Expand Down
7 changes: 4 additions & 3 deletions grabrepos.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@ def dest_filepath(reponame, refname):
return "spec-"+reponame+"-"+refname.replace(".","_")

# Copy files to "docs/". Filter sections of file first. Add generated header to file.
def write_file(reponame, targetdir, srcdir, filename, data, tagname, date, absurl):
def write_file(reponame, targetdir, filename, data, tagname, date):
# Generate version select box html code
# Hide page in the left nav panel if not the latest
header = "---\n"
header += "path: "+absurl+"\n"
header += "source: "+filename+"\n"
header += "version: "+tagname+"\n"
header += "releasedate: "+date.strftime("%d. %B %Y")+"\n"
Expand Down Expand Up @@ -114,7 +113,9 @@ def checkout_repo(targetdir, reponame, repourl, checkoutdir, update_repos):
tagname = ref.name
date = ref.commit.committed_datetime
absurl = repourl.replace(".git","")+"/tree/"+ref.name
write_file(reponame, targetdir, localpath, mainfile, data, tagname, date, absurl)
write_file(reponame, targetdir, mainfile, data, tagname, date)

shutil.copyfile(os.path.join(targetdir,dest_filepath(reponame, "develop")+".md"), os.path.join(targetdir,"_index.md"))

refs = []
refs.extend(repo.tags)
Expand Down
23 changes: 21 additions & 2 deletions themes/b4/assets/scss/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,13 @@ main pre {
@media only screen and (min-width: 1500px) {
.md-sidebar {
display: block;
position: fixed;
position: absolute;
top: 4.8rem;
overflow: hidden;
bottom: 0;
overflow-y: auto;
overflow-x: hidden;
margin-left: 900px;
padding-right: 1rem;
}
}

Expand Down Expand Up @@ -308,4 +311,20 @@ a.md-source:hover {
table, h2+p, h3+p, h4+p, h5+p, code {
page-break-inside: avoid;
}
}

*::-webkit-scrollbar {
width: 12px;
}

*::-webkit-scrollbar-track {
border-radius: 8px;
background-color: #e7e7e7;
border: 1px solid #cacaca;
box-shadow: inset 0 0 6px rgba(0, 0, 0, .3);
}

*::-webkit-scrollbar-thumb {
border-radius: 8px;
background-color: #363636;
}
1 change: 1 addition & 0 deletions themes/b4/layouts/_default/specification.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ <h1 class="animated fadeIn" style="text-align: center">Homie: An MQTT Convention

<aside class="toc animated faster zoomIn md-sidebar md-sidebar--secondary d-print-none"
data-md-state="lock">
{{ replace .TableOfContents `href="#` (printf `href="%s#` .Permalink) | safeHTML }}
</aside>

<main class="md-content">
Expand Down

0 comments on commit e9f3224

Please sign in to comment.