From d61a4275f0ed12dd9c61ed85359994912121d721 Mon Sep 17 00:00:00 2001 From: Arlo Godfrey Date: Fri, 29 Mar 2024 11:40:31 -0500 Subject: [PATCH 1/2] Handle when component has no samples folder --- Build-Toolkit-Docs.ps1 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Build-Toolkit-Docs.ps1 b/Build-Toolkit-Docs.ps1 index 097ff36..ff910c5 100644 --- a/Build-Toolkit-Docs.ps1 +++ b/Build-Toolkit-Docs.ps1 @@ -93,9 +93,15 @@ $componentsRoot = Resolve-Path $PSScriptRoot/../components/ # For each component foreach ($componentFolder in Get-ChildItem -Path $componentsRoot -Directory) { + # Add component to TOC $componentName = $componentFolder.Name - # Add component to TOC + # Check if /samples folder exists + if (-not (Test-Path "$componentFolder/samples")) { + continue + } + + # Get markdown docs from samples folder $markdownFiles = Get-ChildItem -Recurse -Path "$componentFolder/samples/**/*.md" | Where-Object { $_.FullName -notlike "*\bin\*" -and $_FullName -notlike "*\obj\*" } # If there's only one markdown file, append it to the root of the TOC From 719d8024cb978d85c7f19b94a9acfb760c6cc035 Mon Sep 17 00:00:00 2001 From: Arlo Godfrey Date: Fri, 29 Mar 2024 11:40:52 -0500 Subject: [PATCH 2/2] Use forward slash instead of backslash for ToC hrefs --- Build-Toolkit-Docs.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Build-Toolkit-Docs.ps1 b/Build-Toolkit-Docs.ps1 index ff910c5..2f8f5fb 100644 --- a/Build-Toolkit-Docs.ps1 +++ b/Build-Toolkit-Docs.ps1 @@ -109,7 +109,7 @@ foreach ($componentFolder in Get-ChildItem -Path $componentsRoot -Directory) { $header = GetTitleFrontMatterFromMarkdownFile $markdownFiles[0] $mdOutputFile = ProcessMarkdownFile $markdownFiles[0] - $tocHref = $mdOutputFile.Trim('/').Replace($OutputDir, '').Trim('\') + $tocHref = $mdOutputFile.Trim('/').Replace($OutputDir, '').Trim('\').Replace('\', '/') $tocContents += AppendTocItem $header 1 @{ "href" = $tocHref } } else { @@ -120,7 +120,7 @@ foreach ($componentFolder in Get-ChildItem -Path $componentsRoot -Directory) { $header = GetTitleFrontMatterFromMarkdownFile $markdownFile $mdOutputFile = ProcessMarkdownFile $markdownFile - $tocHref = $mdOutputFile.Trim('/').Replace($OutputDir, '').Trim('\') + $tocHref = $mdOutputFile.Trim('/').Replace($OutputDir, '').Trim('\').Replace('\', '/') $tocContents += AppendTocItem $header 2 @{ "href" = $tocHref } } }