* [#858,site][xl]: add Examples to the Navbar, rename gallery to showcases, remove examples from showcases, move github stars to the navbar, add view on github button to the hero section, reduce padding on buttons, add RHS image to the hero * [#858,site][xl]: make sidebar consistent on all pages * [site][xs]: fix ts error on GitHub button component * [site][xs]: fix external links on navbar needing two clicks to open * [site, hero][xs]: align RHS image to the top
47 lines
1.2 KiB
TypeScript
47 lines
1.2 KiB
TypeScript
import fs from 'fs';
|
|
|
|
import Community from '@/components/Community';
|
|
import Features from '@/components/Features';
|
|
import Showcases from '@/components/Showcases';
|
|
import Layout from '../components/Layout';
|
|
import { useRouter } from 'next/router';
|
|
import { useEffect, useState } from 'react';
|
|
import { collectHeadings } from '@flowershow/core';
|
|
|
|
export default function Home({ sidebarTree }) {
|
|
const router = useRouter();
|
|
|
|
const [tableOfContents, setTableOfContents] = useState([]);
|
|
|
|
useEffect(() => {
|
|
const headingNodes = document.querySelectorAll(
|
|
'h2,h3'
|
|
) as NodeListOf<HTMLHeadingElement>;
|
|
const toc = collectHeadings(headingNodes);
|
|
setTableOfContents(toc ?? []);
|
|
}, [router.asPath]); // update table of contents on route change with next/link
|
|
|
|
return (
|
|
<>
|
|
<Layout isHomePage={true} tableOfContents={tableOfContents} sidebarTree={sidebarTree} >
|
|
<Features />
|
|
<Showcases />
|
|
<Community />
|
|
</Layout>
|
|
</>
|
|
);
|
|
}
|
|
|
|
export function getStaticProps() {
|
|
const tree = fs.readFileSync('content/assets/sidebar.json', {
|
|
encoding: 'utf-8',
|
|
});
|
|
const sidebarTree = JSON.parse(tree);
|
|
|
|
return {
|
|
props: {
|
|
sidebarTree,
|
|
},
|
|
};
|
|
}
|