feat(docs): add theme, components, and astro config changes#24
feat(docs): add theme, components, and astro config changes#24janelletam wants to merge 14 commits into
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Greptile SummaryThis PR adds theme variables, a suite of new components (
Confidence Score: 4/5Safe to merge with one fix: step-anchors.ts needs an idempotency guard to avoid duplicate click handlers on initial load. All four initialization scripts listen to both DOMContentLoaded and astro:page-load, which both fire on initial load. Three have idempotency guards; step-anchors.ts does not, causing duplicate click handlers on every step anchor during the initial page visit. The rest of the PR is well-structured. src/scripts/step-anchors.ts Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Page Load] --> B[DOMContentLoaded]
A --> C[astro:page-load]
B --> D[initCopyButtons guarded]
B --> E[initStepAnchors no guard]
B --> F[initLazyIframes guarded]
B --> G[initCodeGroups guarded]
C --> D
C --> E
C --> F
C --> G
E -- double listeners on initial load --> H[Step Anchor Click]
H --> I[scrollIntoView x2 and pushState x2]
Reviews (3): Last reviewed commit: "fix(docs): fix incorrect import" | Re-trigger Greptile |
0865088 to
68902b5
Compare
| <div class="hidden items-start justify-between gap-4 lg:flex"> | ||
| {breadcrumbs.length > 0 ? ( | ||
| <Breadcrumb className="min-w-0 flex-1"> | ||
| {breadcrumbs.length > 1 && ( |
There was a problem hiding this comment.
suggestion: Let's keep the previous behaviour where we render only the top-level breadcrumb as well.
| import { toLucideKebab } from "@/lib/icon-utils"; | ||
|
|
||
| interface Props { | ||
| icon: keyof typeof icons; |
There was a problem hiding this comment.
suggestion: let's keep using lucide icons, this way we get intellisense/type errors if we try to use an icon that's misspelled or that doesn't exist.
| ></iframe> | ||
| </div> | ||
|
|
||
| <script> |
There was a problem hiding this comment.
issue: LLMs have a tendency to create astro components with inline scripts. The problem is these scripts are present on the page as many times as the component is rendered. Instead, if we need JS to run on the client, we should make a React component and use an astro client:load or client:idle directive to create an island/hydrate it on the client.
If this is used in content, I might suggest this pattern:
// content/some-page.mdx
<LazyIframe ... /> (astro component)
// components/LazyIframe.astro
<LazyIframe ... client:load /> (react component)
This way, the content editor can still use the simple form and not have to worry about including the directive.
| siteLogo={siteConfig.logo} | ||
| siteLogoDark={siteConfig.logoDark} | ||
| breadcrumbs={breadcrumbs} | ||
| breadcrumbs={[...(breadcrumbs ?? []), { label: title }]} |
There was a problem hiding this comment.
issue: It seems like not rendering the page itself in the breadcrumbs was an intentional design decision (see the comment in src/bach/breadcrumbs.ts buildBreadcrumbs), so let's keep this as-is.
| </BaseLayout> | ||
|
|
||
| <script> | ||
| import '@/scripts/code-copy' |
There was a problem hiding this comment.
suggestion: Instead, let's make the code blocks an astro component that wraps a hydrated react component.
|
|
||
| <script> | ||
| import '@/scripts/code-copy' | ||
| import '@/scripts/step-anchors' |
There was a problem hiding this comment.
question: Is it possible to include the code for these as a hydrated react component rather than a separately included script?
| import { transformerMetaHighlight } from '@shikijs/transformers' | ||
|
|
||
| /** @returns {import('shiki').ShikiTransformer} */ | ||
| function transformerFilename() { |
There was a problem hiding this comment.
suggestion: move these transformers into src/shiki/transformers/*
Summary
docs-v2, including:global.cssto use CSS variables usingoklchvalues for colours and improve accessibilityastro.config.mjs, sidebar/layout components, and clean up duplicate/unused code from initial scaffoldTest plan