on master help sign in
docs: add dot
commit628d7921da746131ebf2aec7b6fa6b1dd53b6a6b authorMatilde Park <matilde@tlon.io> dateTue 22 Jun 2021, 15:57 (5 years ago) parent67eb468
2 files changed+19−5
pages/docs/[...slug].js+11−5 styles/globals.css+8
pages/docs/[...slug].js+11−5
@@ -35,23 +35,29 @@ const childPages = (thisLink, children, level = 0) => (
3535
3636const pageTree = (thisLink, tree, level = 0) => {
3737 const router = useRouter();
38− const firstCrumb = "/" + router.asPath.split("/").slice(1).join("/");
38+ const firstCrumb = "/" + router.asPath.split("/").slice(1, -1).join("/");
3939
40− const thisPage = firstCrumb.includes(thisLink);
41− const [isOpen, toggleTree] = useState(thisPage);
40+ const includesThisPage = firstCrumb.includes(thisLink);
41+ const isThisPage = firstCrumb === thisLink;
42+ const [isOpen, toggleTree] = useState(includesThisPage);
43+
44+ console.log(thisLink);
45+ console.log(firstCrumb);
4246
4347 const activeClasses = classnames({
4448 hidden: !isOpen,
4549 });
4650
4751 const headerClass = classnames({
48− "text-gray": !thisPage,
52+ "text-gray": !isThisPage,
53+ dot: isThisPage,
4954 });
5055 return (
5156 <>
5257 <span
5358 className={
54− "font-medium text-lg cursor-pointer hover:text-black " + headerClass
59+ "font-medium text-lg cursor-pointer hover:text-black relative " +
60+ headerClass
5561 }
5662 onClick={() => toggleTree(!isOpen)}
5763 >
styles/globals.css+8
@@ -137,3 +137,11 @@ a:hover {
137137 transform: translateX(100vw);
138138 transition: transform 200ms;
139139}
140+
141+.dot::before {
142+ content: "·";
143+ position: absolute;
144+ left: -16px;
145+ margin-top: -2px;
146+ font-size: 3rem;
147+}