Skip to content

feat: Adding homepage to Starlight docs #4250

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

Merged
merged 25 commits into from
May 13, 2025
Merged

feat: Adding homepage to Starlight docs #4250

merged 25 commits into from
May 13, 2025

Conversation

yhakbar
Copy link
Collaborator

@yhakbar yhakbar commented May 5, 2025

Description

Adds homepage to the Starlight docs.

TODOs

Read the Gruntwork contribution guidelines.

  • Update the docs.
  • Run the relevant tests successfully, including pre-commit checks.
  • Ensure any 3rd party code adheres with our license policy or delete this line if its not applicable.
  • Include release notes. If this PR is backward incompatible, include a migration guide.

Release Notes (draft)

Added homepage to the Starlight docs.

Summary by CodeRabbit

  • New Features

    • Introduced a custom site header with interactive elements, including a GitHub stars button, social icons, and theme/language selectors.
    • Added a new site title component with theme-aware logo support.
    • Implemented a new global layout and main index page with a splash hero section, updated branding, and responsive design.
    • Integrated Tailwind CSS for enhanced styling and theming across the site.
  • Bug Fixes

    • Updated logo assets for improved appearance in both dark and light modes.
  • Chores

    • Updated dependencies to include Tailwind CSS and related tooling.
    • Removed the outdated documentation splash page and replaced it with a new index page.
    • Simplified social links by removing the GitHub link from the site configuration.

Copy link

vercel bot commented May 5, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
terragrunt-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 12, 2025 3:48pm

Copy link
Contributor

coderabbitai bot commented May 5, 2025

📝 Walkthrough

Walkthrough

This update integrates Tailwind CSS into the documentation site, customizes the site's header and branding, and restructures the splash page. It introduces new Astro components for the header and site title, updates configuration and dependencies for Tailwind support, applies global theming, and replaces the main index page with a new design.

Changes

File(s) Change Summary
docs-starlight/astro.config.mjs
docs-starlight/package.json
Added Tailwind CSS and related plugins to the build configuration and dependencies. Updated Starlight integration to use custom CSS, set new logo paths for dark/light modes, registered custom header and site title components, and removed the GitHub social link.
docs-starlight/src/components/Header.astro
docs-starlight/src/components/SiteTitle.astro
Added new Astro components for a custom header (with GitHub stars, social links, search, and theme/language selectors) and a site title with theme-aware logos.
docs-starlight/src/layouts/BaseLayout.astro Introduced a new base layout Astro component for consistent HTML structure and metadata across pages.
docs-starlight/src/pages/index.astro Replaced or added the main index page with a new splash page using StarlightPage, theme-aware logos, hero content, action buttons, and a branded footer.
docs-starlight/src/styles/global.css Added a global CSS file layering Starlight and Tailwind styles, customizing fonts and color palettes using CSS variables and Tailwind color tokens.
docs-starlight/src/content/docs/index.mdx Removed the previous Terragrunt splash documentation page and its content.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Browser
    participant AstroApp
    participant HeaderComponent
    participant GitHubAPI

    User->>Browser: Navigate to site
    Browser->>AstroApp: Request index page
    AstroApp->>HeaderComponent: Render header
    HeaderComponent->>GitHubAPI: Fetch star count
    GitHubAPI-->>HeaderComponent: Return star count
    HeaderComponent-->>AstroApp: Rendered header with stars, logos, links
    AstroApp-->>Browser: Serve complete page with Tailwind styles
Loading

Possibly related PRs

  • fix: Cleaning up docs bugs #3856: Updates the logo property in the starlight integration to use separate dark and light logo paths, directly related to the branding and configuration changes in this PR.

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@yhakbar yhakbar requested a review from ebeneliason May 12, 2025 15:48
@yhakbar yhakbar marked this pull request as ready for review May 12, 2025 15:48
@yhakbar yhakbar requested review from denis256 and lev-ok as code owners May 12, 2025 15:48
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (9)
docs-starlight/src/styles/global.css (1)

7-36: Theme customization looks good.

The font choices and color mappings create a consistent design system. The use of Tailwind's color variables for the accent and gray scales allows for a cohesive theme across the documentation site.

Consider adding a comment about font availability - if these fonts aren't automatically loaded by Starlight, you might need to include them via a font provider or local files.

docs-starlight/src/layouts/BaseLayout.astro (1)

8-21: HTML structure follows best practices.

The HTML structure is well-formed with appropriate meta tags. Consider the following improvements:

  1. Add a <meta name="theme-color"> for mobile browser theming
  2. Consider adding Open Graph and Twitter card meta tags for better social sharing
<head>
  <meta charset="UTF-8" />
  <meta name="description" content="Terragrunt Homepage" />
  <meta name="viewport" content="width=device-width" />
  <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
  <meta name="generator" content={Astro.generator} />
+ <meta name="theme-color" content="#4f46e5" media="(prefers-color-scheme: light)">
+ <meta name="theme-color" content="#4f46e5" media="(prefers-color-scheme: dark)">
+ <meta property="og:title" content={title} />
+ <meta property="og:description" content="Terragrunt Homepage" />
+ <meta property="og:type" content="website" />
+ <meta property="twitter:card" content="summary_large_image" />
  <title>{title}</title>
</head>
docs-starlight/src/components/SiteTitle.astro (1)

19-20: Small typo in comment.

The comment says "if a user configure both" but should say "if a user configures both".

-				{/* Show light alternate if a user configure both light and dark logos. */}
+				{/* Show light alternate if a user configures both light and dark logos. */}
docs-starlight/src/components/Header.astro (6)

39-41: Remove commented-out code.

There's commented-out code that should be removed for cleaner maintenance.

<div class="header sl-flex">
-	<!-- <div class="title-wrapper sl-flex"> -->
		<SiteTitle {...Astro.props} />
-	<!-- </div> -->

48-52: Extract SVG icons to separate components.

Multiple inline SVGs make the template harder to read and maintain. Consider extracting them to separate components or using an icon library.

For example, create a new component like IconGitHub.astro:

---
const { width = 20, height = 20 } = Astro.props;
---
<svg xmlns="http://www.w3.org/2000/svg" width={width} height={height} viewBox="0 0 24 24" fill="currentColor">
  <path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/>
</svg>

Then update the template:

- <span class="github-icon">
-   <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/></svg>
- </span>
+ <span class="github-icon">
+   <IconGitHub />
+ </span>

Apply similar changes to other SVG icons in the file.

Also applies to: 65-67, 76-78


72-74: Move inline style to CSS.

The inline style on the SVG should be moved to the CSS section.

- <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="currentColor" style="margin-right: 0.5rem;">
+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="currentColor" class="support-icon">

Then add to the CSS:

.support-icon {
  margin-right: 0.5rem;
}

139-139: Remove commented-out CSS.

There's a commented-out background property in the CSS that should be removed.

.pipeline-pill {
  display: flex;
  align-items: center;
- /* background: rgba(167, 139, 250, 0.08); */
  border-radius: 999px;

176-178: Use CSS variables for colors instead of hardcoded values.

Hardcoded color values like #7c3aed and #fff make theme customization difficult and maintenance harder. Consider using CSS variables for consistent theming.

.support-btn {
  display: flex;
  align-items: center;
- background: #7c3aed;
- color: #fff;
+ background: var(--sl-color-accent);
+ color: var(--sl-color-white);
  border-radius: 999px;

Apply similar changes to other hardcoded colors in the file to ensure consistency with the theming system.


113-133: Add documentation for complex grid calculation.

The complex grid calculation for the header layout would benefit from clearer documentation to aid future maintenance.

.header {
+  /* 
+   * This grid layout dynamically adjusts based on:
+   * 1. The sidebar width
+   * 2. The main content width
+   * 3. The TOC width (when present)
+   * 
+   * The goal is to align the header elements with the content below
+   * while maintaining appropriate spacing.
+   */
  --__sidebar-width: max(0rem, var(--sl-content-inline-start, 0rem) - var(--sl-nav-pad-x));
  --__main-column-fr: calc(
    (
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 64c0752 and abc63d3.

⛔ Files ignored due to path filters (6)
  • docs-starlight/bun.lock is excluded by !**/*.lock
  • docs-starlight/src/assets/gruntwork-logo-mark-black.svg is excluded by !**/*.svg
  • docs-starlight/src/assets/gruntwork-logo-mark-white.svg is excluded by !**/*.svg
  • docs-starlight/src/assets/horizontal-logo-dark.svg is excluded by !**/*.svg
  • docs-starlight/src/assets/horizontal-logo-light.svg is excluded by !**/*.svg
  • docs-starlight/src/assets/pipelines.svg is excluded by !**/*.svg
📒 Files selected for processing (8)
  • docs-starlight/astro.config.mjs (3 hunks)
  • docs-starlight/package.json (1 hunks)
  • docs-starlight/src/components/Header.astro (1 hunks)
  • docs-starlight/src/components/SiteTitle.astro (1 hunks)
  • docs-starlight/src/content/docs/index.mdx (0 hunks)
  • docs-starlight/src/layouts/BaseLayout.astro (1 hunks)
  • docs-starlight/src/pages/index.astro (1 hunks)
  • docs-starlight/src/styles/global.css (1 hunks)
💤 Files with no reviewable changes (1)
  • docs-starlight/src/content/docs/index.mdx
🧰 Additional context used
📓 Path-based instructions (1)
`docs-starlight/**/*.astro`: Review the Astro code in the `docs-starlight` directory for quality and correctness. Make sure that the Astro code follows best practices and is easy t...

docs-starlight/**/*.astro: Review the Astro code in the docs-starlight directory for quality and correctness. Make sure that the Astro code follows best practices and is easy to understand, maintain, and follows best practices. When possible, suggest improvements to the Astro code to make it better.

  • docs-starlight/src/layouts/BaseLayout.astro
  • docs-starlight/src/pages/index.astro
  • docs-starlight/src/components/SiteTitle.astro
  • docs-starlight/src/components/Header.astro
⏰ Context from checks skipped due to timeout of 90000ms (13)
  • GitHub Check: Test (Windows)
  • GitHub Check: Test (macos)
  • GitHub Check: Test (Fixtures)
  • GitHub Check: Test (ubuntu)
  • GitHub Check: Build (linux/arm64)
  • GitHub Check: Build (darwin/arm64)
  • GitHub Check: Build (linux/amd64)
  • GitHub Check: Build (windows/amd64)
  • GitHub Check: Build (windows/386)
  • GitHub Check: Build (darwin/amd64)
  • GitHub Check: Build (linux/386)
  • GitHub Check: build-and-test
  • GitHub Check: Pull Request has non-contributor approval
🔇 Additional comments (11)
docs-starlight/package.json (1)

14-14: Package dependencies look well-structured.

The addition of Tailwind CSS and related packages looks appropriate for adding styling to the Starlight docs. The version constraints with the caret (^) allow for compatible minor and patch updates, which is a good practice for dependencies.

Also applies to: 16-16, 22-23

docs-starlight/src/styles/global.css (1)

1-6: Layer structure follows best practices.

The layer structure properly separates concerns and follows the recommended approach for integrating Tailwind with Starlight. The imports are organized in the correct order to ensure proper CSS cascade.

docs-starlight/src/layouts/BaseLayout.astro (1)

1-7: Clean component interface with proper TypeScript typing.

The Props interface with the title property is well-defined and properly destructured from Astro.props.

docs-starlight/src/pages/index.astro (2)

1-8: Clean import structure with proper asset handling.

The imports are well-organized, with clear naming for different logo variants and proper usage of the Astro Image component.


10-39: Hero configuration is well-structured and comprehensive.

The hero section configuration provides all necessary elements for a compelling landing page. The action buttons provide clear navigation paths for different user needs.

docs-starlight/astro.config.mjs (4)

7-7: Tailwind plugin import looks good.

The import statement for the Tailwind CSS Vite plugin follows the standard pattern.


81-85: Custom component configuration is well-structured.

The configuration properly registers custom Starlight components for the Header and SiteTitle. The file paths are correctly specified relative to the project root.


87-89: Logo paths updated correctly.

The logo paths are properly updated to use the new horizontal logo SVG files.


169-171: Vite configuration for Tailwind is correct.

The Vite configuration correctly includes the Tailwind CSS plugin.

docs-starlight/src/components/SiteTitle.astro (1)

45-51: Well-structured image styling for consistent logo presentation.

The image styling ensures consistent logo display while maintaining proper aspect ratios with object-fit: contain. This is a good practice for responsive logos that may have different dimensions.

docs-starlight/src/components/Header.astro (1)

105-134: Well-implemented responsive header layout.

The header layout uses a sophisticated and flexible grid system that adapts to various screen sizes and content configurations. It properly accounts for the sidebar, main content, and table of contents widths, which helps maintain a consistent layout across different pages.

Comment on lines +40 to +48
<footer class="flex items-center justify-center py-6 px-4 bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-300 mt-auto">
<div class="flex items-center gap-[0.5em]">
<Image src={GruntworkLogoBlack} alt="Gruntwork Logo" class="w-6 h-6 dark:sl-hidden" />
<Image src={GruntworkLogoWhite} alt="Gruntwork Logo" class="w-6 h-6 light:sl-hidden" />
<span>&nbsp;From the DevOps experts at&nbsp;</span>
</div>
<a href="https://gruntwork.io" class="text-blue-600 dark:text-blue-400 no-underline hover:underline">Gruntwork</a>
</footer>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Footer design could be improved for accessibility.

The footer structure is good, but consider these improvements:

  1. The text contrast ratio might be insufficient for accessibility in dark mode
  2. The HTML structure has some inconsistent spacing and could be improved
- <footer class="flex items-center justify-center py-6 px-4 bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-300 mt-auto">
+ <footer class="flex items-center justify-center py-6 px-4 bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-200 mt-auto">
  <div class="flex items-center gap-[0.5em]">
    <Image src={GruntworkLogoBlack} alt="Gruntwork Logo" class="w-6 h-6 dark:sl-hidden" />
    <Image src={GruntworkLogoWhite} alt="Gruntwork Logo" class="w-6 h-6 light:sl-hidden" />
-   <span>&nbsp;From the DevOps experts at&nbsp;</span>
+   <span>From the DevOps experts at</span>
    </div>
-	<a href="https://gruntwork.io" class="text-blue-600 dark:text-blue-400 no-underline hover:underline">Gruntwork</a>
+	<a href="https://gruntwork.io" class="ml-1 text-blue-700 dark:text-blue-300 no-underline hover:underline">Gruntwork</a>
</footer>

🏁 Script executed:

#!/bin/bash
# Check if there are any other components using similar footer styling for consistency
fd -e astro | xargs grep -l "footer" | xargs grep -A 10 -B 10 "footer" 2>/dev/null

Length of output: 750


Improve footer accessibility and spacing

The footer is currently the only instance in the codebase, so let’s focus on making it fully accessible and tidy:

• Update text colors to meet a minimum 4.5:1 contrast ratio in both light and dark modes
• Remove hard-coded non-breaking spaces and use Tailwind’s margin utilities for consistent spacing

File: docs-starlight/src/pages/index.astro (around lines 40–48)

- <footer class="flex items-center justify-center py-6 px-4 bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-300 mt-auto">
+ <footer class="flex items-center justify-center py-6 px-4 bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-200 mt-auto">
   <div class="flex items-center gap-[0.5em]">
     <Image src={GruntworkLogoBlack} alt="Gruntwork Logo" class="w-6 h-6 dark:sl-hidden" />
     <Image src={GruntworkLogoWhite} alt="Gruntwork Logo" class="w-6 h-6 light:sl-hidden" />
-    <span>&nbsp;From the DevOps experts at&nbsp;</span>
+    <span>From the DevOps experts at</span>
   </div>
-  <a href="https://gruntwork.io" class="text-blue-600 dark:text-blue-400 no-underline hover:underline">Gruntwork</a>
+  <a href="https://gruntwork.io" class="ml-1 text-blue-700 dark:text-blue-300 no-underline hover:underline">Gruntwork</a>
 </footer>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<footer class="flex items-center justify-center py-6 px-4 bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-300 mt-auto">
<div class="flex items-center gap-[0.5em]">
<Image src={GruntworkLogoBlack} alt="Gruntwork Logo" class="w-6 h-6 dark:sl-hidden" />
<Image src={GruntworkLogoWhite} alt="Gruntwork Logo" class="w-6 h-6 light:sl-hidden" />
<span>&nbsp;From the DevOps experts at&nbsp;</span>
</div>
<a href="https://gruntwork.io" class="text-blue-600 dark:text-blue-400 no-underline hover:underline">Gruntwork</a>
</footer>
</div>
<footer class="flex items-center justify-center py-6 px-4 bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-200 mt-auto">
<div class="flex items-center gap-[0.5em]">
<Image src={GruntworkLogoBlack} alt="Gruntwork Logo" class="w-6 h-6 dark:sl-hidden" />
<Image src={GruntworkLogoWhite} alt="Gruntwork Logo" class="w-6 h-6 light:sl-hidden" />
<span>From the DevOps experts at</span>
</div>
<a href="https://gruntwork.io" class="ml-1 text-blue-700 dark:text-blue-300 no-underline hover:underline">Gruntwork</a>
</footer>

Comment on lines +53 to +60
@media (max-width: 768px) {
img.dark-logo {
content: url('/src/assets/logo-dark.svg');
}

img.light-logo {
content: url('/src/assets/logo-light.svg');
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Hardcoded asset paths in media query could be problematic.

The media query overrides the image sources with hardcoded paths. This approach is brittle and might break if the asset structure changes or during build processes that transform asset paths.

Consider using a more maintainable approach such as:

  1. Using imported assets through Astro's asset handling system
  2. Using CSS variables that can be defined at the theme level
  3. Creating smaller logo variants and importing them properly
@media (max-width: 768px) {
-	img.dark-logo {
-		content: url('/src/assets/logo-dark.svg');
-	}
-
-	img.light-logo {
-		content: url('/src/assets/logo-light.svg');
-	}
+	/* Use a different approach such as:
+	.site-title {
+		--mobile-logo-width: 120px;
+	}
+	img {
+		max-width: var(--mobile-logo-width);
+	}
+	*/
}

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +20 to +35
let starCountDisplay = '8.6k';

try {
const response = await fetch('https://api.github.com/repos/gruntwork-io/terragrunt');
if (response.ok) {
const data = await response.json();
const stars = data.stargazers_count;
if (typeof stars === 'number') {
starCountDisplay = (stars / 1000).toFixed(1) + 'k';
}
} else {
console.error('Failed to fetch GitHub stars:', response.status, await response.text());
}
} catch (error) {
console.error('Error fetching GitHub stars:', error);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

GitHub star count fetching could lead to rate limiting.

The current implementation fetches GitHub stars at build time without caching. This approach has several issues:

  1. It may hit GitHub API rate limits if the site is rebuilt frequently
  2. The star count becomes stale after build
  3. The hardcoded fallback value (8.6k) will need manual updates

Consider these alternatives:

  1. Use a client-side script to fetch the star count on page load
  2. Add build-time caching with a longer expiry
  3. Use a GitHub webhook to trigger rebuilds when star count changes significantly
- let starCountDisplay = '8.6k';
- 
- try {
- 	const response = await fetch('https://api.github.com/repos/gruntwork-io/terragrunt');
- 	if (response.ok) {
- 		const data = await response.json();
- 		const stars = data.stargazers_count;
- 		if (typeof stars === 'number') {
- 			starCountDisplay = (stars / 1000).toFixed(1) + 'k';
- 		}
- 	} else {
- 		console.error('Failed to fetch GitHub stars:', response.status, await response.text());
- 	}
- } catch (error) {
- 	console.error('Error fetching GitHub stars:', error);
- }
+ // Client-side approach (recommended)
+ const starCountDisplay = '8.6k'; // Default fallback shown during hydration

Then add a client-side script element:

<script>
  // Fetch star count client-side to avoid build-time rate limiting
  async function updateStarCount() {
    try {
      const response = await fetch('https://api.github.com/repos/gruntwork-io/terragrunt');
      if (response.ok) {
        const data = await response.json();
        if (typeof data.stargazers_count === 'number') {
          const formatted = (data.stargazers_count / 1000).toFixed(1) + 'k';
          document.querySelector('.github-count').textContent = formatted;
        }
      }
    } catch (error) {
      console.error('Error fetching GitHub stars:', error);
    }
  }
  updateStarCount();
</script>

@yhakbar yhakbar merged commit 8cee725 into main May 13, 2025
27 of 32 checks passed
@yhakbar yhakbar deleted the feat/adding-homepage branch May 13, 2025 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants