Skip to content

Commit

Permalink
update some more docs
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzolewis committed May 21, 2024
1 parent ac93be5 commit 8cdaef6
Show file tree
Hide file tree
Showing 13 changed files with 93 additions and 35 deletions.
7 changes: 6 additions & 1 deletion docs/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { defineConfig } from "astro/config";
import starlight from "@astrojs/starlight";
import starlightLinksValidatorPlugin from "starlight-links-validator";
import starlightUtils from "@lorenzo_lewis/starlight-utils";

// https://astro.build/config
export default defineConfig({
Expand All @@ -16,12 +17,16 @@ export default defineConfig({
label: "Docs",
autogenerate: { directory: "/docs" },
},
{
label: "Utilities",
autogenerate: { directory: "/utilities" },
},
{
label: "References",
autogenerate: { directory: "/references" },
},
],
plugins: [starlightLinksValidatorPlugin()],
plugins: [starlightLinksValidatorPlugin(), starlightUtils()],
}),
],
});
2 changes: 1 addition & 1 deletion docs/src/content/docs/_quick-start.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ import { PackageManagers } from "starlight-package-managers";
});
```

4. Go to the [Configuration Guide](/configuration) to continue setting up!
4. Go to the [Configuration Guide](/docs/configuration) to learn how to set up the different utilities

</Steps>
5 changes: 0 additions & 5 deletions docs/src/content/docs/configuration.md

This file was deleted.

24 changes: 23 additions & 1 deletion docs/src/content/docs/docs/recommended.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
---
title: Recommended Plugins
title: Recommended Resources
---

import { LinkCard, CardGrid } from "@astrojs/starlight/components";

## Plugins

These are plugins not included in this utility but are fantastic to add to your Starlight site.

<CardGrid>
<LinkCard
title="Starlight Links Validator"
description="Starlight plugin to validate internal links."
href="https://starlight-links-validator.vercel.app"
/>
</CardGrid>

---

<LinkCard
title="More Resources"
description="Visit the Starlight Plugins and Integrations page for even more amazing resources!"
href="https://starlight.astro.build/resources/plugins/"
/>
13 changes: 2 additions & 11 deletions docs/src/content/docs/index.mdx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
title: 🧰 Starlight Utils
description: A collection of utilities to build on top of your 🌟 Starlight site.
description: Utilities to use with your 🌟 Starlight site
tableOfContents: false
template: splash
hero:
tagline: A collection of utilities to build on top of your 🌟 Starlight site.
tagline: Utilities to use with your 🌟 Starlight site
image:
file: ../../assets/houston.webp
actions:
Expand All @@ -14,14 +13,6 @@ hero:
variant: primary
---

import { LinkCard, CardGrid } from "@astrojs/starlight/components";

<CardGrid stagger>
<LinkCard />
<LinkCard />
<LinkCard />
</CardGrid>

import QuickStart from "./_quick-start.mdx";

## Quick Start
Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/references/index.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: References
title: API Reference
sidebar:
order: 1
---
3 changes: 3 additions & 0 deletions docs/src/content/docs/utilities/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
title: List of Utilities
---
43 changes: 43 additions & 0 deletions docs/src/content/docs/utilities/multi-sidebar.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
title: Multi-Sidebar
---

There are cases where having multiple sidebars for a Starlight site can be useful. [Starlight does not currently support this natively](https://github.com/withastro/starlight/discussions/959), but this utility gives a minimal implementation of this.

## Demo

import { Sidebar } from "@lorenzo_lewis/starlight-utils/components";

## Configuration

See below for how to configure each of these actions.

```ts {12-14}
// astro.config.mjs
import { defineConfig } from "astro/config";
import starlight from "@astrojs/starlight";
import starlightUtils from "@lorenzo_lewis/starlight-utils";

// https://astro.build/config
export default defineConfig({
integrations: [
starlight({
plugins: [
starlightUtils({
multiSidebar: {
switcherStyle: "horizontalList",
},
}),
],
}),
],
});
```

## `switcherStyle`

**Type:** `"dropdown" | "horizontalList"`

**Default:** `"horizontalList"`

Specifies which style should be used for the sidebar.
2 changes: 1 addition & 1 deletion packages/starlight-utils/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# 🗄️ Starlight Utils

A collection of utilities to build on top of your 🌟 [Starlight](https://starlight.astro.build) site.
Utilities to use with your 🌟 [Starlight](https://starlight.astro.build) site.

Visit the documentation for instructions on how to use: https://starlight-utils.pages.dev
3 changes: 3 additions & 0 deletions packages/starlight-utils/components/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Sidebar from "../overrides/Sidebar.astro";

export { Sidebar };
8 changes: 6 additions & 2 deletions packages/starlight-utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ import { AstroError } from "astro/errors";
import { z } from "astro/zod";

export const configSchema = z
.object({ switcherStyle: z.enum(["dropdown", "horizontalList"]) })
.object({
multiSidebar: z.object({
switcherStyle: z.enum(["dropdown", "horizontalList"]),
}),
})
.optional()
.default({ switcherStyle: "horizontalList" });
.default({ multiSidebar: { switcherStyle: "horizontalList" } });

export function validateConfig(userConfig: unknown): StarlightUtilsConfig {
const config = configSchema.safeParse(userConfig);
Expand Down
8 changes: 1 addition & 7 deletions packages/starlight-utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,7 @@ function plugin(userConfig?: StarlightUtilsConfig): StarlightPlugin {
return {
name: "starlight-utils",
hooks: {
setup({ config, updateConfig, addIntegration }) {
updateConfig({
components: {
...config.components,
Sidebar: "@lorenzo_lewis/starlight-utils/overrides/Sidebar.astro",
},
});
setup({ addIntegration }) {
addIntegration(integration(multiSidebarConfig));
},
},
Expand Down
8 changes: 3 additions & 5 deletions packages/starlight-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
"author": "Lorenzo Lewis",
"version": "0.0.1",
"license": "MIT",
"description": "A collection of utilities to build on top of your 🌟 Starlight site.",
"description": "Utilities to use with your 🌟 Starlight site.",
"type": "module",
"exports": {
".": "./index.ts",
"./overrides/Sidebar.astro": "./overrides/Sidebar.astro"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"./components": "./components/index.ts"
},
"scripts": {},
"devDependencies": {
"@astrojs/starlight": "^0.23.1",
"astro": "^4.8.6"
Expand Down

0 comments on commit 8cdaef6

Please sign in to comment.