···16161717<script
1818 is:inline
1919- define:vars={{ contentWidth: SITE.contentWidth, centeredLayout: SITE.centeredLayout }}
1919+ define:vars={{
2020+ contentWidth: SITE.contentWidth,
2121+ centeredLayout: SITE.centeredLayout,
2222+ toc: SITE.toc
2323+ }}
2024>
2125 ;(function () {
2226 // Adjust back button position based on layout and screen size
···3539 const pageWidth = window.innerWidth
3640 const contentWidthValue = parseFloat(contentWidth)
3741 const margin = (pageWidth - contentWidthValue * 16) / 2
3838- const minSpace = 11 * 16 // Minimum space needed
4242+ const baseMinSpace = 11 * 16 // Base minimum space needed
4343+ // If toc is enabled, need additional 2.5rem (40px) space
4444+ const minSpace = toc ? baseMinSpace + 40 : baseMinSpace
39454046 // Position button fixed on the left if there's enough space
4147 if (margin >= minSpace) {
4248 button.classList.add('fixed-position')
4343- button.style.left = `${margin - minSpace}px`
4949+ const basePosition = margin - baseMinSpace
5050+ // If toc is enabled, move 2.5rem (40px) further left
5151+ const leftPosition = toc ? basePosition - 40 : basePosition
5252+ button.style.left = `${leftPosition}px`
4453 } else {
4554 button.classList.remove('fixed-position')
4655 button.style.left = ''
···61706271<style>
6372 .back-button {
6464- width: 128px;
7373+ width: 8rem;
6574 display: inline-flex;
6675 align-items: center;
6776 gap: 0.375rem;
+24-15
src/components/ui/TableOfContents.astro
···10101111<script
1212 is:inline
1313- define:vars={{ contentWidth: SITE.contentWidth, centeredLayout: SITE.centeredLayout }}
1313+ define:vars={{
1414+ contentWidth: SITE.contentWidth,
1515+ centeredLayout: SITE.centeredLayout,
1616+ toc: SITE.toc
1717+ }}
1418>
1519 ;(function () {
1620 // TOC positioning logic (similar to BackButton)
1721 function adjustTOCPosition() {
1818- const toc = document.querySelector('.toc-container')
1919- if (!toc) return
2222+ const tocContainer = document.querySelector('.toc-container')
2323+ if (!tocContainer) return
20242125 // If not using centered layout, hide TOC
2226 if (!centeredLayout) {
2323- toc.style.display = 'none'
2727+ tocContainer.style.display = 'none'
2428 return
2529 }
2630···2832 const pageWidth = window.innerWidth
2933 const contentWidthValue = parseFloat(contentWidth)
3034 const margin = (pageWidth - contentWidthValue * 16) / 2
3131- const minSpace = 11 * 16 // Minimum space needed
3535+ const baseMinSpace = 11 * 16 // Base minimum space needed
3636+ // If toc is enabled, need additional 2.5rem (40px) space
3737+ const minSpace = toc ? baseMinSpace + 40 : baseMinSpace
32383339 // Show and position TOC fixed on the left if there's enough space
3440 if (margin >= minSpace) {
3535- toc.style.display = 'block'
3636- toc.classList.add('fixed-position')
3737- toc.style.left = `${margin - minSpace}px`
4141+ tocContainer.style.display = 'block'
4242+ tocContainer.classList.add('fixed-position')
4343+ const basePosition = margin - baseMinSpace
4444+ // If toc is enabled, move 2.5rem (40px) further left
4545+ const leftPosition = toc ? basePosition - 40 : basePosition
4646+ tocContainer.style.left = `${leftPosition}px`
3847 } else {
3939- toc.style.display = 'none'
4040- toc.classList.remove('fixed-position')
4141- toc.style.left = ''
4848+ tocContainer.style.display = 'none'
4949+ tocContainer.classList.remove('fixed-position')
5050+ tocContainer.style.left = ''
4251 }
4352 }
4453···7584 })
76857786 // Hide TOC if there are no headings (only title)
7878- const tocContainer = document.querySelector('.toc-container')
7979- if (tocContainer && tocItems.length === 0) {
8080- tocContainer.style.display = 'none'
8787+ const tocContainerElement = document.querySelector('.toc-container')
8888+ if (tocContainerElement && tocItems.length === 0) {
8989+ tocContainerElement.style.display = 'none'
8190 return
8291 }
8392···192201193202<style is:global>
194203 .toc-container {
195195- width: 128px;
204204+ width: 12rem;
196205 position: relative;
197206 left: -0.175em;
198207 }
+1-1
src/config.ts
···21212222 // POST SETTINGS ///////////////////////////////////////////////////////////////////////////////////////
2323 readingTime: false, // Show reading time in posts
2424- toc: true, // Show table of contents
2424+ toc: true, // Show the table of contents when there is enough page width
2525 imageViewer: true, // Enable image viewer
2626 copyCode: false // Enable copy button in code blocks
2727}