# eleventy-plugin-standard-site

[11ty](https://www.11ty.dev/) plugin to generate and publish [Standard.site](https://standard.site/) records on your [AT Protocol](https://atproto.com/) PDS for your site.

## Installation

This project supports Node.js 18 and later. You can install the plugin from `npm`:

```bash
npm install eleventy-plugin-standard-site
```

You can view package details on [npmjs.com](https://www.npmjs.com/package/eleventy-plugin-standard-site) or [npmx.dev](https://npmx.dev/package/eleventy-plugin-standard-site).

## Usage

Add the plugin to your Eleventy configuration file, e.g.:

```js
import pluginStandardSite from "eleventy-plugin-standard-site";

export default function (eleventyConfig) {
  eleventyConfig.addPlugin(pluginStandardSite, {
    // Publication details for your site
    publicationName: "My Site",
    publicationUrl: "https://example.com",
    // You can use your ATProto DID or handle
    identifier: "did:plc:abc123",
    // Please use an app-password!
    password: "app-password-xyz",

    // Optional: brief description of the publication
    publicationDescription: "A blog where I write about my life!",
    // Optional: whether to automatically extract text content from posts
    // and include in their document records, defaults to true
    includeTextContent: true,
    // Optional: whether the publication should appear in discovery feeds, defaults to true
    showInDiscover: true,
    // Optional: PDS URL, defaults to "https://bsky.social"
    pds: "https://bsky.social",
    // Optional: path to an icon image file to be used in the publication record
    publicationIconPath: "./path/to/icon/image.jpg",
    // Optional: theme definition for the publication; if set, must include all colors
    themeColors: {
      bg: { r: 255, g: 255, b: 255 },
      fg: { r: 31, g: 41, b: 55 },
      accent: { r: 59, g: 130, b: 246 },
      accentFg: { r: 255, g: 255, b: 255 }
    }
  });
}
```

The plugin will get triggered on build time after Eleventy has generated the output files, and will integrate your website with Standard.site lexicons as follows:

- One `site.standard.publication` record will be created (or updated) for the site as a whole, containing the publication metadata you provided in the plugin options.
- The `.well-known/site.standard.publication` endpoint will be created in your output directory, verifying the publication record's AT URI.
- Each generated HTML page will get a `<link rel="site.standard.publication" ... />` tag in its `<head>`, pointing to the publication record URI.
- One `site.standard.document` record will be created (or updated) for each page whose front matter sets `standardSiteDocument: true`, containing page metadata and a reference to the page URL.
- Each generated HTML page published as a `site.standard.document` will get a `<link rel="site.standard.document" ... />` tag in its `<head>`, pointing to the document record URI.

Metadata for documents will be taken from the page's front matter. The example below lists all supported fields:

```yaml
---
# Required
title: "My First Post"
date: 2026-06-20
standardSiteDocument: true

# Optional
description: "This is the description of my first post."
bskyPostRef: "at://did:plc:abc123/app.bsky.feed.post/def456"
coverImagePath: "./path/to/cover/image.jpg"
---
```

The `date` field is used as the `publishedAt` value for the document record. You can refer to [Eleventy documentation on content dates](https://www.11ty.dev/docs/dates/) for alternatives.

The `textContent` field of the document record is automatically derived from the page's rendered HTML output (with tags stripped), unless `includeTextContent` is set to `false` on the plugin config.

Additionally, after publishing, a generated document page will include the following two `link` tags (and any other HTML page will include the first one):

```html
<link rel="site.standard.publication" href="at://did:plc:yourDID/site.standard.publication/rkey" />
<link rel="site.standard.document" href="at://did:plc:yourDID/site.standard.document/rkey" />
```

## Contributing

To set up the development environment, clone the repository and install dependencies with `npm install`. Development environment requires Node.js 22 or later.

Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
