diff --git a/src/components/on-this-page.tsx b/src/components/on-this-page.tsx index 2c271a5..b7f75e8 100644 --- a/src/components/on-this-page.tsx +++ b/src/components/on-this-page.tsx @@ -18,6 +18,7 @@ type Header = { }; const OnThisPage = ({ page }: { page: DocsContentMetadata }): ReactElement => { + const [loading, setLoading] = useState(true); const [headers, setHeaders] = useState([]); const [activeHeader, setActiveHeader] = useState( undefined @@ -45,6 +46,7 @@ const OnThisPage = ({ page }: { page: DocsContentMetadata }): ReactElement => { } setHeaders(extractedHeaders); + setLoading(false); }, [page.content]); useEffect(() => { @@ -94,8 +96,10 @@ const OnThisPage = ({ page }: { page: DocsContentMetadata }): ReactElement => { {/* Headers */}
    - {headers.length === 0 ? ( + {loading ? ( + ) : headers.length === 0 ? ( + Nothing ): ) : ( headers.map((header: Header) => (
  • => { // Pull the latest changes from the repo if we don't have it if (!fs.existsSync(cacheDir) || fs.readdirSync(cacheDir).length < 1) { - console.log("Fetching initial docs from Git..."); + console.log("Cloning initial docs content from Git..."); try { await simpleGit().clone(DOCS_DIR, cacheDir, { "--depth": 1 }); storeUpdatedRepoTime(); @@ -55,7 +55,7 @@ const getDocsDirectory = cache(async (): Promise => { } } else if (shouldUpdateRepo()) { // Pull the latest changes from Git - console.log("Updating docs content from Git..."); + console.log("Pulling docs content from Git..."); await simpleGit(cacheDir) .reset(["--hard"]) // Reset any local changes .pull(); // Pull latest changes