Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/liruifengv/starlight-head

A Starlight plugin for easy to add <head> for your Starlight site
https://github.com/liruifengv/starlight-head

astro head plugin starlight

Last synced: about 2 months ago
JSON representation

A Starlight plugin for easy to add <head> for your Starlight site

Awesome Lists containing this project

README

        

## starlight-head

A Starlight plugin for easy to add `` for your Starlight site.

### Installation

```bash
npm install -D starlight-head
```

### Usage

```js
// astro.config.mjs
import { defineConfig } from "astro/config";
import starlight from "@astrojs/starlight";
import starlightHead from "starlight-head";

export default defineConfig({
integrations: [
starlight({
title: "My Docs",
plugins: [
starlightHead({
path: "./src/components/head.astro",
}),
],
}),
],
});
```

```astro
// src/components/head.astro
---
---

window.onload = function() {
console.log("Page loaded");
}

```

It will be covert to Starlight config:

```js
starlight({
head: [
{
tag: "meta",
attributes: {
name: "description",
content: "This is a description by starlight-head-plugin",
},
},
{
tag: "script",
content: 'window.onload = function() {\n\tconsole.log("Page loaded");\n}',
},
],
});
```

### Features

- [x] Add `` content to Starlight by `.astro` component.
- [ ] Support expressions in `.astro` component.
- [ ] Supports importing variables from other files.
- [ ] Support add `` for certain page.

### Configuration Reference

#### path (required)

**type:** `string`

A path to the file that contains the `` content. Like `./src/components/head.astro`.

### License

MIT