Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docs site #6

Merged
merged 7 commits into from
Oct 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions .github/workflows/build-test.yml

This file was deleted.

21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,22 @@
src/packages
# build output
dist/
# generated types
.astro/

# dependencies
node_modules/

# logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*


# environment variables
.env
.env.production

# macOS-specific files
.DS_Store
4 changes: 4 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"recommendations": ["astro-build.astro-vscode"],
"unwantedRecommendations": []
}
12 changes: 12 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "./node_modules/.bin/astro dev",
"cwd": "${workspaceFolder}/PwshSpectreConsole.Docs",
"name": "Docs Development server",
"request": "launch",
"type": "node-terminal"
}
]
}
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
58 changes: 58 additions & 0 deletions PwshSpectreConsole.Docs/UpdateDocs.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#requires -Modules HelpOut

$ErrorActionPreference = "Stop"

Import-Module "..\PwshSpectreConsole\PwshSpectreConsole.psd1" -Force
Remove-Item -Recurse -Path ".\src\content\docs\reference\*" -Force
Get-Module PwshSpectreConsole | Save-MarkdownHelp -OutputPath ".\src\content\docs\reference\" -IncludeYamlHeader -YamlHeaderInformationType Metadata -ExcludeFile "*.gif", "*.png"

# Post-processing for astro stuff
$groups = @(
@{ Name = "Prompts"; Matches = @("read-") }
@{ Name = "Formatting"; Matches = @("format-") }
@{ Name = "Progress"; Matches = @("invoke-", "job") }
@{ Name = "Images"; Matches = @("image") }
@{ Name = "Writing"; Matches = @("write-", "escaped") }
@{ Name = "Config"; Matches = @("set-") }
)
$remove = @("Start-SpectreDemo.md")
$docs = Get-ChildItem ".\src\content\docs\reference\" -Filter "*.md" -Recurse
foreach($doc in $docs) {
if($remove -contains $doc.Name) {
Remove-Item $doc.FullName
continue
}

$group = $null
foreach($testGroup in $groups) {
foreach($match in $testGroup.Matches) {
if($doc.Name -like "*$match*") {
$group = $testGroup
break
}
}
}

$outLocation = ".\src\content\docs\reference\$($group.Name)\$($doc.Name)"
if($null -eq $group) {
$outLocation = $doc.FullName
}
New-Item -ItemType Directory -Path ".\src\content\docs\reference\$($group.Name)" -Force | Out-Null
$content = Get-Content $doc.FullName -Raw
Remove-Item $doc.FullName
$content -replace '```PowerShell', '```powershell' -replace '(?m)^.+\n^[\-]{10,99}', '' | Out-File $outLocation
}

# Build the docs site
npm run build --prefix .\

# Yeet it to cloudflare
$choice = Read-Host "`nDeploy to CF pages? (y/n)"
if($choice -eq "y") {
if(npx wrangler whoami | Where-Object { $_ -like "*You are logged in*" }) {
Write-Host "Already logged into cloudflare"
} else {
npx wrangler login
}
npx wrangler pages deploy .\dist --project-name pwshspectreconsole --commit-dirty=true --branch=main
}
51 changes: 51 additions & 0 deletions PwshSpectreConsole.Docs/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { defineConfig } from "astro/config";
import starlight from "@astrojs/starlight";

import tailwind from "@astrojs/tailwind";

// https://astro.build/config
export default defineConfig({
integrations: [
starlight({
title: "PwshSpectreConsole",
editLink: {
baseUrl: "https://github.com/ShaunLawrie/PwshSpectreConsole/edit/main/PwshSpectreConsole.Docs/",
},
favicon: "/favicon.png",
customCss: ["./src/tailwind.css"],
social: {
github: "https://github.com/ShaunLawrie/PwshSpectreConsole",
twitter: "https://twitter.com/Shaun_Lawrie",
},
sidebar: [
{
label: "Guides",
items: [
{
label: "Install",
link: "/guides/install/",
},
{
label: "Getting Started",
link: "/guides/get-started/",
},
{
label: "FAQs",
link: "/guides/faqs/",
},
],
},
{
label: "Command Reference",
autogenerate: {
directory: "reference",
collapsed: true,
},
},
],
}),
tailwind({
applyBaseStyles: false,
}),
],
});
Loading