Skip to content

Commit

Permalink
Merge pull request #44 from Pitayan/43-failing-in-ci-build
Browse files Browse the repository at this point in the history
[FIX] Failing in ci build due to missing heading tag in post markdown file
  • Loading branch information
daiyanze authored Feb 23, 2023
2 parents 4a96fd8 + 856e8f0 commit 6e8fbee
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ import React, { memo, useRef, useLayoutEffect, forwardRef } from "react"
const Content: React.FC<any> = forwardRef(({
items,
levels,
lvlRef,
currentLevel = 1,
}, ref) => {
if (lvlRef.current < levels) {
lvlRef.current++
} else {
if (currentLevel >= levels) {
return <></>
}

Expand All @@ -17,7 +15,7 @@ const Content: React.FC<any> = forwardRef(({
return (
<li className="mt-2" key={index}>
<a className="site-link" href={data.url}>{data.title}</a>
{data.items && <Content items={data.items} levels={levels} lvlRef={lvlRef} />}
{data.items && <Content items={data.items} levels={levels} currentLevel={currentLevel + 1} />}
</li>
)
})}
Expand All @@ -30,9 +28,10 @@ const TableOfContents: React.FC<any> = ({
className = "",
title = "Table of Contents",
levels = 2,
items,
items = [],
}, articleRef) => {
const lvlRef = useRef(0)
if (!items.length) return <></>

const listRef = useRef(null)
const nodesMap = new Map<HTMLElement, {
prev: HTMLElement,
Expand Down Expand Up @@ -93,7 +92,7 @@ const TableOfContents: React.FC<any> = ({
return (
<div className={`table-of-contents ${className}`}>
<h5>{title}</h5>
<Content ref={listRef} items={items} levels={levels} lvlRef={lvlRef} />
<Content ref={listRef} items={items} levels={levels} />
</div>
)
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions packages/www/content/posts/2023-02-12-no-heading-post/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
title: No heading post
author:
- Yanze Dai
date: 2023-02-12
categories:
- post
- example
description: This is a post page with no headings
hero: images/demo_1.jpg
slug: posts/no-heading-post
---


Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus pharetra egestas odio id accumsan. In vel ipsum quam. Fusce scelerisque rutrum tempus. Mauris in velit sapien. In mi nibh, dignissim in ligula ut, faucibus lacinia libero. Etiam volutpat turpis est, a scelerisque sem commodo eu. Morbi lectus quam, molestie eget vestibulum in, porta ac tellus. Aliquam feugiat, orci non vehicula tristique, augue ex congue dui, non suscipit velit purus vitae diam. Phasellus dui augue, faucibus sed neque id, pellentesque porta magna. Cras nec lacinia dui. Pellentesque lacinia, nisi non porta condimentum, risus nisi semper erat, vel ullamcorper neque justo sit amet erat. Mauris lacinia dolor in arcu tempor pretium.

Donec venenatis blandit erat. In a sodales neque, sit amet dignissim eros. Donec sit amet semper ligula. Praesent vel ligula ultrices, efficitur nisi non, tincidunt dolor. Proin a dolor dolor. Fusce malesuada ornare felis eu auctor. Morbi vestibulum venenatis lectus scelerisque tempus.

Vivamus hendrerit eleifend nunc sed imperdiet. Ut sed sem at nisi rhoncus faucibus. Cras varius ex quis semper lacinia. Sed eu leo lectus. Quisque pellentesque condimentum metus, non dapibus justo lobortis mattis. Suspendisse sit amet eros justo. Cras iaculis elementum nisl, quis vehicula diam tincidunt quis. Aliquam id aliquam odio, bibendum tristique nibh. Suspendisse mattis pharetra turpis, et pharetra urna eleifend quis. Proin tempor molestie magna in egestas. Vivamus arcu ante, eleifend eget mattis ac, aliquam at lorem. Nulla vehicula consectetur pulvinar. Quisque sit amet ligula ac ipsum eleifend ultrices. Suspendisse potenti. Aenean a massa iaculis, posuere elit in, vehicula arcu. Aliquam erat volutpat.

Sed tempus velit augue, fringilla mollis dui bibendum non. Vestibulum volutpat nisi ut dolor pretium, quis euismod tellus pulvinar. Vestibulum ut ligula vitae elit lobortis scelerisque eget a nisl. Nam libero nibh, euismod in pulvinar ut, venenatis id odio. Mauris varius vel lectus sed sagittis. Nulla facilisi. Fusce suscipit lectus eros, vel viverra eros posuere a. Vivamus gravida, tellus vitae varius consectetur, eros nisl malesuada mauris, eget malesuada mi est sit amet nisl. Ut vitae mauris sit amet justo congue iaculis. Nullam vestibulum dapibus velit. Sed mauris nunc, aliquam ac nisl eget, tincidunt sollicitudin orci. Nullam dictum efficitur tincidunt. Proin sollicitudin mi vitae purus iaculis, ut interdum libero fermentum.

Donec at lorem commodo, facilisis nunc eu, facilisis magna. Praesent nec pharetra dolor, sit amet vehicula turpis. Cras eros turpis, commodo eu cursus sed, molestie et nibh. Fusce tempus orci orci, ac ultricies tortor venenatis nec. Maecenas eu interdum nulla, quis sodales diam. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Etiam sem ligula, aliquam in luctus ut, finibus eu lectus.

0 comments on commit 6e8fbee

Please sign in to comment.