-
Notifications
You must be signed in to change notification settings - Fork 370
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
chore: replatform docs site to Astro + Starlight #7012
Conversation
4140021
to
2b9ddfd
Compare
# Netlify CLI command reference | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Starlight uses the title
front the frontmatter as the h1
[build.environment] | ||
# cannot use node 18, as we use x0 which uses webpack 4 | ||
NODE_VERSION = "16" | ||
AWS_LAMBDA_JS_RUNTIME = "nodejs16.x" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh look, the point of the PR 😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yay
## Architecture | ||
|
||
All the command reference pages and the list of commands are automatically generated from the CLI code. This is | ||
automatically inserted into the existing, committed, semi-manually-written pages in `../docs/`. Here's how the flow | ||
works: | ||
|
||
1. The `docs.js` script replaces the content between the auto-generation marker comments in the files in `../docs/`; the | ||
rest you can update manually. | ||
2. The `sync.js` script copies these over to this Astro Starlight site, into `src/content/docs/`. It may also perform | ||
some minor transformations. | ||
3. From there, it's any old Astro/Starlight docs site, as documented. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😅 This doesn't seem that complex but it took me a lot of trial-and-error and poking around to understand the whole flow. I hope this documentation is clear for the next person.
lastmod: new Date(), | ||
}), | ||
starlight({ | ||
credits: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They're our partner, so seemed like a good idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed
credits: true, | ||
title: 'Netlify CLI command reference', | ||
description: 'Full command reference for the Netlify CLI', | ||
social: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO we could add more socials here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added youtube, github, twitter, bluesky (also found instagram and linkedin but feels weird here)
tag: 'script', | ||
attrs: { | ||
async: true, | ||
src: 'https://www.googletagmanager.com/gtag/js?id=G-X2FMMZSSS9', | ||
}, | ||
}, | ||
{ | ||
tag: 'script', | ||
content: `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': | ||
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], | ||
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= | ||
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); | ||
})(window,document,'script','dataLayer','GTM-NMKKF2M');`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copied these as-is from the existing site layout
label: 'Commands', | ||
autogenerate: { directory: 'commands' }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤩 I was so happy to find this. So easy.
"@compositor/x0": "6.0.7", | ||
"@rebass/markdown": "1.0.0", | ||
"@rebass/mdx": "1.0.0", | ||
"algoliasearch": "4.24.0", | ||
"lodash.sortby": "4.7.0", | ||
"prop-types": "15.8.1", | ||
"react": "16.14.0", | ||
"react-dom": "16.14.0", | ||
"react-helmet": "6.1.0", | ||
"react-instantsearch-dom": "6.40.4", | ||
"react-router-dom": "4.3.1", | ||
"react-emotion": "9.2.12", | ||
"rebass": "2.3.4", | ||
"styled-components": "3.4.10", | ||
"styled-system": "5.1.5" | ||
}, | ||
"devDependencies": { | ||
"@astrojs/starlight": "^0.31.1", | ||
"astro": "^5.1.5", | ||
"markdown-magic": "2.6.1", | ||
"npm-run-all2": "5.0.2", | ||
"sane": "5.0.1", | ||
"sharp": "^0.32.5", | ||
"strip-ansi": "7.1.0" | ||
}, | ||
"overrides": { | ||
"react": "$react", | ||
"react-dom": "$react-dom" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔪🔪🔪
2b9ddfd
to
9f6b622
Compare
|
||
export const copyDirRecursiveAsync = async (src, dest) => { | ||
try { | ||
fs.mkdir(dest, { recursive: true }) | ||
await mkdir(dest, { recursive: true }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol I was trying not to fix other things but I saw a couple bugs here
const Sosumi = () => ( | ||
<SosumiList> | ||
<li> | ||
<a href="https://www.netlify.com/trust-center/">Trust Center</a> | ||
</li> | ||
<li> | ||
<a href="https://www.netlify.com/privacy/">Privacy</a> | ||
</li> | ||
<li> | ||
<a href="https://www.netlify.com/security/">Security</a> | ||
</li> | ||
<li> | ||
<a href="https://www.netlify.com/gdpr-ccpa/">GDPR/CCPA</a> | ||
</li> | ||
<li> | ||
<a | ||
href="mailto:[email protected]?subject=Abuse%20report&body=Please%20include%20the%20site%20URL%20and%20reason%20for%20your%20report%2C%20and%20we%20will%20reply%20promptly." | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
Abuse | ||
</a> | ||
</li> | ||
</SosumiList> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we care about this? There's no such footer on the SDK docs site
9f6b622
to
a8f601e
Compare
I tried to resist the temptation to fix other tech debt here (untyped JS, etc.).
a8f601e
to
40db384
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good :)
Summary
While working on #7008 I discovered that the docs site uses old libraries that have been unmaintained for 7 years, and thus cannot be upgraded past node 16. Because the build step for these docs uses code from the core CLI, this in turn means the core CLI can't be upgraded to any dependencies that don't support node 16. (See also a bit more nuanced context here.)
So I deleted everything, created a new Astro + Starlight site, and pasted the content generation script and bare minimum over, and cribbed a bit of the Astro/Starlight setup from the Netlify SDK docs. 🤷🏼 Looks pretty good, it's fast, it's functional, it has built-in search without needing Algolia anymore, it has dark mode, it's branded, it has copy-to-clipboard, and it has syntax highlighting, pretty much all for free.
I tried to resist the temptation to fix other tech debt here (untyped JS, etc.).