Skip to content

Commit 75c53c4

Browse files
authored
Move to Docusaurus (#1291)
* Initial switch to docusaurus * Update md files to be compatible with docusaurus * Do not render links to pages that don't exist * Fix incorrect URLs in documents: path, casing, and scheme issues. * Fail build on broken links and images * run build again so we can get a green build with a minor change * approve builds for packages
1 parent dd8a1ab commit 75c53c4

File tree

360 files changed

+14897
-39380
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

360 files changed

+14897
-39380
lines changed

.cursor/mcp.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"mcpServers": {
3+
"chrome-devtools": {
4+
"command": "npx",
5+
"args": ["-y", "chrome-devtools-mcp@latest"]
6+
}
7+
}
8+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
description: Docusaurus App
3+
alwaysApply: true
4+
---
5+
6+
# Docusaurus App
7+
8+
- This is a Docusaurus react app, written in Typescript using pnpm package manager.
9+
- Try to reuse existing state instead of creating new state
10+
- Check for existing components before suggesting new ones
11+
- Ensure react code is performance optimized: Use useMemo, useCallback, and React.memo where needed.
12+
- Ensure minimal re-renders: Suggest best state management practices, as much as possible stay away from external libraries. Let's prioritize React's native state management capabilities.

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,17 @@ yarn-error.log
6767
.pnp.js
6868
# Yarn Integrity file
6969
.yarn-integrity
70+
71+
# Production
72+
/build
73+
74+
# Generated files
75+
.docusaurus
76+
.cache-loader
77+
78+
.env.local
79+
.env.development.local
80+
.env.test.local
81+
.env.production.local
82+
83+
src/data/device-metadata.json

README.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,22 @@ Go to <https://devices.esphome.io> to view the website.
88

99
## How To Contribute
1010

11-
Content on devices.esphome.io is generated by [Gatsby](https://www.gatsbyjs.com/). Pages are written in Markdown which anyone can learn. How to add a new device is [documented here](https://devices.esphome.io/adding-devices).
11+
Content on devices.esphome.io is generated by [Docusaurus](https://docusaurus.io/). Pages are written in Markdown which anyone can learn. How to add a new device is [documented here](https://devices.esphome.io/adding-devices).
1212

1313
When you create a merge request, Netlify will automatically compile your proposed changes for you to preview what gets rendered. It puts a comment in the PR on Github.
1414

1515
## Development of site
1616

17-
The site requires Node 18 to build. Once that is running, to build locally:
17+
The site requires Node 20 and pnpm to build. Once that is running, to build locally:
1818

1919
```bash
20-
# Now install gatsby as configured in the esphome-devices repository:
21-
npm install
22-
# Run a development gatsby server so you can see your copy of the site:
23-
npm run start
24-
# Open a browser to http://localhost:8000/
20+
# Now install Docusaurus as configured in the esphome-devices repository:
21+
pnpm install
22+
# Run a development Docusaurus server so you can see your copy of the site:
23+
pnpm start
24+
# A browser will open to http://localhost:3000/
2525
```
2626

27-
You can learn more about [Gatsby develop mode here](https://www.gatsbyjs.com/docs/reference/gatsby-cli#develop).
28-
2927
## Code of Conduct
3028

3129
When contributing to this project please abide by our [Code of Conduct](CODE-OF-CONDUCT.md)

docusaurus.config.ts

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
import { themes as prismThemes } from "prism-react-renderer";
2+
import type { Config } from "@docusaurus/types";
3+
import type * as Preset from "@docusaurus/preset-classic";
4+
5+
// This runs in Node.js - Don't use client-side code here (browser APIs, JSX...)
6+
7+
const config: Config = {
8+
title: "ESPHome Devices",
9+
tagline:
10+
"This website is a repository of device configuration templates and setup guides for devices running ESPHome firmware.",
11+
favicon: "img/favicon.png",
12+
13+
// Future flags, see https://docusaurus.io/docs/api/docusaurus-config#future
14+
future: {
15+
v4: true, // Improve compatibility with the upcoming Docusaurus v4
16+
},
17+
18+
// Set the production url of your site here
19+
url: "https://devices.esphome.io",
20+
// Set the /<baseUrl>/ pathname under which your site is served
21+
// For GitHub pages deployment, it is often '/<projectName>/'
22+
baseUrl: "/",
23+
24+
// GitHub pages deployment config.
25+
// If you aren't using GitHub pages, you don't need these.
26+
organizationName: "esphome", // Usually your GitHub org/user name.
27+
projectName: "esphome-devices", // Usually your repo name.
28+
29+
onBrokenLinks: "throw",
30+
31+
// Even if you don't use internationalization, you can use this field to set
32+
// useful metadata like html lang. For example, if your site is Chinese, you
33+
// may want to replace "en" with "zh-Hans".
34+
i18n: {
35+
defaultLocale: "en",
36+
locales: ["en"],
37+
},
38+
39+
presets: [
40+
[
41+
"classic",
42+
{
43+
docs: {
44+
sidebarPath: "./sidebars.ts",
45+
routeBasePath: "/devices",
46+
path: "src/docs/devices",
47+
48+
// Please change this to your repo.
49+
// Remove this to remove the "edit this page" links.
50+
editUrl:
51+
"https://github.com/esphome/esphome-devices/tree/main/",
52+
},
53+
blog: false,
54+
theme: {
55+
customCss: "./src/css/custom.css",
56+
},
57+
} satisfies Preset.Options,
58+
],
59+
],
60+
61+
themes: [
62+
["@getcanary/docusaurus-theme-search-pagefind",
63+
{
64+
styles: {
65+
"--canary-color-primary-c": 0.15,
66+
"--canary-color-primary-h": 150,
67+
},
68+
includeRoutes: ["/devices/**/*"]
69+
}
70+
]
71+
],
72+
73+
markdown: {
74+
hooks: {
75+
onBrokenMarkdownImages: "throw",
76+
},
77+
},
78+
79+
themeConfig: {
80+
// Replace with your project's social card
81+
image: "img/social-card.svg",
82+
colorMode: {
83+
respectPrefersColorScheme: true,
84+
},
85+
navbar: {
86+
title: "ESPHome Devices",
87+
logo: {
88+
alt: "ESPHome Devices Logo",
89+
src: "img/logo.svg",
90+
},
91+
items: [],
92+
},
93+
footer: {
94+
style: "dark",
95+
links: [],
96+
copyright: `Built by the ESPHome community.`,
97+
},
98+
prism: {
99+
theme: prismThemes.oneLight,
100+
darkTheme: prismThemes.oneDark,
101+
},
102+
plugins: [
103+
[
104+
"@docusaurus/plugin-ideal-image",
105+
{
106+
quality: 70,
107+
max: 1030, // max resized image's size.
108+
min: 640, // min resized image's size. if original is lower, use that size.
109+
steps: 2, // the max number of images generated between min and max (inclusive)
110+
disableInDev: true,
111+
},
112+
],
113+
[
114+
"@docusaurus/plugin-sitemap",
115+
{
116+
lastmod: null,
117+
changefreq: "weekly",
118+
priority: 0.5,
119+
// ignorePatterns: ["/tags/**"],
120+
filename: "sitemap.xml",
121+
// createSitemapItems: async (params) => {
122+
// const { defaultCreateSitemapItems, ...rest } = params;
123+
// const items = await defaultCreateSitemapItems(rest);
124+
// return items.filter((item) => !item.url.includes("/page/"));
125+
// },
126+
},
127+
],
128+
],
129+
} satisfies Preset.ThemeConfig,
130+
};
131+
132+
export default config;

gatsby-config.js

Lines changed: 0 additions & 80 deletions
This file was deleted.

netlify.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build]
2+
command = "pnpm build"
3+
publish = "build"

0 commit comments

Comments
 (0)