Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 150 additions & 0 deletions TAILWIND_SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
# Hugo Native Tailwind CSS Setup

MiloDocs theme now supports Hugo's native Tailwind CSS v4 processing, eliminating the need for separate build tools.

## Quick Setup

### 1. Install Dependencies

In your Hugo site root, install the required dependencies:

```bash
npm install -D @tailwindcss/postcss autoprefixer postcss postcss-import tailwindcss
```

### 2. Create PostCSS Configuration

Create `postcss.config.js` in your site root:

```javascript
module.exports = {
plugins: [
require('postcss-import')({
path: ['themes/milodocs/assets/css']
}),
require('@tailwindcss/postcss'),
require('autoprefixer')
]
}
```

### 3. Create Tailwind Configuration

Create `tailwind.config.js` in your site root:

```javascript
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"content/**/*.md",
"layouts/**/*.html",
"themes/milodocs/layouts/**/*.html",
"themes/milodocs/content/**/*.md",
"assets/js/**/*.js"
],
theme: {
extend: {
colors: {
brand: "var(--color-brand)",
"brand-1": "var(--color-brand-1)",
"brand-2": "var(--color-brand-2)",
"brand-3": "var(--color-brand-3)",
"brand-4": "var(--color-brand-4)",
"brand-5": "var(--color-brand-5)",
"brand-6": "var(--color-brand-6)",
"brand-7": "var(--color-brand-7)",
surface: "var(--color-surface)",
"surface-hover": "var(--color-surface-hover)",
"surface-active": "var(--color-surface-active)",
text: {
primary: "var(--color-text-primary)",
secondary: "var(--color-text-secondary)",
tertiary: "var(--color-text-tertiary)",
inverse: "var(--color-text-inverse)",
},
bg: {
primary: "var(--color-bg-primary)",
secondary: "var(--color-bg-secondary)",
tertiary: "var(--color-bg-tertiary)",
inverse: "var(--color-bg-inverse)",
},
border: {
primary: "var(--color-border-primary)",
secondary: "var(--color-border-secondary)",
focus: "var(--color-border-focus)",
},
},
fontFamily: {
"brand": ["NVIDIA", "Arial", "Helvetica", "sans-serif"],
"nvidia": ["NVIDIA", "Arial", "Helvetica", "sans-serif"],
"nvidia-mono": ["RobotoMono", "SFMono-Regular", "Menlo", "Monaco", "Consolas", "Liberation Mono", "Courier New", "monospace"],
},
fontSize: {
'xs': ['0.875rem', { lineHeight: '1.4' }],
'sm': ['0.875rem', { lineHeight: '1.5' }],
'base': ['1rem', { lineHeight: '1.6' }],
'lg': ['1.125rem', { lineHeight: '1.75' }],
'xl': ['1.25rem', { lineHeight: '1.75' }],
'2xl': ['1.5rem', { lineHeight: '2' }],
'3xl': ['1.875rem', { lineHeight: '2.25' }],
},
},
},
plugins: [],
};
```

### 4. Create Theme Symlink

For the example site to work, create a symlink to the theme:

```bash
mkdir -p themes
ln -sf ../../ themes/milodocs
```

## How It Works

1. **Hugo Processing**: Hugo automatically detects the PostCSS configuration and processes CSS files through PostCSS
2. **Tailwind v4**: The `@tailwindcss/postcss` plugin handles Tailwind CSS v4 compilation
3. **Component Imports**: PostCSS Import resolves the theme's component CSS files
4. **No Build Step**: Everything happens automatically when you run `hugo server` or `hugo build`

## Benefits

- ✅ **No separate build tools**: Hugo handles everything natively
- ✅ **Live reload**: CSS changes are reflected immediately during development
- ✅ **Optimized output**: Hugo automatically minifies and fingerprints CSS in production
- ✅ **Tailwind v4**: Latest Tailwind CSS features and performance improvements
- ✅ **Theme integration**: Full access to theme components and design tokens

## Troubleshooting

### CSS Import Errors

If you see import path errors, ensure:
1. The theme symlink exists: `themes/milodocs` → `../../`
2. PostCSS import path is configured: `path: ['themes/milodocs/assets/css']`

### Missing Dependencies

Ensure you have Hugo Extended version for PostCSS support:
```bash
hugo version # Should show "extended"
```

### Development vs Production

- **Development**: CSS is processed but not minified for faster builds
- **Production**: CSS is automatically minified and fingerprinted by Hugo

## Migration from PostCSS Build

If you're migrating from the previous PostCSS build setup:

1. Remove build scripts from `package.json`
2. Delete generated `assets/css/main.css`
3. Remove theme-level `postcss.config.js` and `tailwind.config.js`
4. Follow the setup steps above

The theme now handles CSS processing through Hugo's native capabilities, providing a much cleaner and more maintainable setup.
39 changes: 35 additions & 4 deletions assets/css/components/cards.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Cards Component - Resource cards, content metadata, and generic card styles */

/* Base Card Styles */
.card {
html:not(.no-transitions) .card {
Copy link

Copilot AI Sep 27, 2025

Choose a reason for hiding this comment

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

The .card class is duplicated with nearly identical properties. The second definition overrides the first, making the conditional html:not(.no-transitions) selector ineffective. Consider consolidating these definitions or using a different approach.

Copilot uses AI. Check for mistakes.
position: relative;
/* background: linear-gradient(135deg, var(--color-surface) 0%, var(--color-bg-secondary) 100%); */
background: var(--glass-bg);
Expand All @@ -15,7 +15,24 @@
transition:
transform var(--timing-medium) var(--easing-standard),
border-color var(--timing-medium) var(--easing-standard),
box-shadow var(--timing-medium) var(--easing-standard);
box-shadow var(--timing-medium) var(--easing-standard),
background-color var(--timing-medium) var(--easing-standard),
color var(--timing-medium) var(--easing-standard);
overflow: hidden;
/* box-shadow: var(--elevation-2), inset 0 1px 0 rgba(255, 255, 255, 0.1); */
box-shadow: var(--glass-shadow);
}

.card {
Copy link

Copilot AI Sep 27, 2025

Choose a reason for hiding this comment

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

The .card class is duplicated with nearly identical properties. The second definition overrides the first, making the conditional html:not(.no-transitions) selector ineffective. Consider consolidating these definitions or using a different approach.

Copilot uses AI. Check for mistakes.
position: relative;
/* background: linear-gradient(135deg, var(--color-surface) 0%, var(--color-bg-secondary) 100%); */
background: var(--glass-bg);
border-radius: var(--radius-card);
/* border: 1px solid var(--color-border-primary); */
border: 1px solid var(--glass-border-color);
/* backdrop-filter: blur(10px); */
-webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
overflow: hidden;
/* box-shadow: var(--elevation-2), inset 0 1px 0 rgba(255, 255, 255, 0.1); */
box-shadow: var(--glass-shadow);
Expand Down Expand Up @@ -50,7 +67,14 @@

/* Resource Card Styles */
.card--resource {
@apply card;
position: relative;
background: var(--glass-bg);
border-radius: var(--radius-card);
border: 1px solid var(--glass-border-color);
-webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
overflow: hidden;
box-shadow: var(--glass-shadow);
Copy link

Copilot AI Sep 27, 2025

Choose a reason for hiding this comment

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

Both .card--resource and .article-card duplicate the same base card properties instead of extending the .card class. This creates maintenance overhead when card styling changes. Consider using @apply card or extending the base card class.

Suggested change
position: relative;
background: var(--glass-bg);
border-radius: var(--radius-card);
border: 1px solid var(--glass-border-color);
-webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
overflow: hidden;
box-shadow: var(--glass-shadow);
/* Only add unique styles here; base card styles are inherited from .card */

Copilot uses AI. Check for mistakes.
/* padding: 1.5rem; */
padding: 1rem;
margin-bottom: 1rem;
Expand Down Expand Up @@ -173,7 +197,14 @@

/* Article Card Styles */
.article-card {
@apply card;
position: relative;
background: var(--glass-bg);
border-radius: var(--radius-card);
border: 1px solid var(--glass-border-color);
-webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
overflow: hidden;
box-shadow: var(--glass-shadow);
Copy link

Copilot AI Sep 27, 2025

Choose a reason for hiding this comment

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

Both .card--resource and .article-card duplicate the same base card properties instead of extending the .card class. This creates maintenance overhead when card styling changes. Consider using @apply card or extending the base card class.

Copilot uses AI. Check for mistakes.
padding: 1.5rem;
margin-bottom: 1.5rem;
display: flex;
Expand Down
2 changes: 1 addition & 1 deletion assets/css/components/navigation.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Navigation Component - Modular navigation system with NVIDIA styling */

/* Import modular navigation components */
@import 'navigation/index.css';
@import './navigation/index.css';
14 changes: 7 additions & 7 deletions assets/css/components/navigation/index.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* Navigation Module - Main import file for all navigation components */

/* Import all navigation modules in proper order */
@import 'base.css';
@import 'chat-toc-toggle.css';
@import 'sidebar.css';
@import 'topbar.css';
@import 'toc.css';
@import 'dropdown.css';
@import 'language-switcher.css';
@import './base.css';
@import './chat-toc-toggle.css';
@import './sidebar.css';
@import './topbar.css';
@import './toc.css';
@import './dropdown.css';
@import './language-switcher.css';
3 changes: 2 additions & 1 deletion assets/css/components/navigation/sidebar.css
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ li:has(> .sidebar-item > .sidebar-item__toggle[aria-expanded="false"]) > .nested
.sidebar__item--level-1 .sidebar__text {
/* Step down one size from text-lg and slightly reduce weight */
/* @apply text-lg font-brand font-bold; */
@apply text-base font-brand font-semibold;
@apply text-base font-semibold;
font-family: "NVIDIA", "Arial", "Helvetica", sans-serif;
}

.sidebar__item--level-1 {
Expand Down
4 changes: 2 additions & 2 deletions assets/css/components/navigation/toc.css
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@
}

.toc ul ul {
@apply pl-4 mt-2 border-l border-opacity-20;
border-color: var(--color-border-primary);
@apply pl-4 mt-2 border-l;
border-color: color-mix(in srgb, var(--color-border-primary) 20%, transparent);
}

/* TOC Link Styling */
Expand Down
40 changes: 20 additions & 20 deletions assets/css/components/notebook.css
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@

.notebook-cell--markdown .notebook-cell__number {
background: color-mix(in srgb, rgb(134, 239, 172) 10%, transparent);
color: theme('colors.green.600');
color: #059669;
border-color: color-mix(in srgb, rgb(134, 239, 172) 20%, transparent);
}

Expand All @@ -266,19 +266,19 @@

.notebook-cell__status--executed {
background: color-mix(in srgb, rgb(34, 197, 94) 10%, transparent);
color: theme('colors.green.600');
color: #059669;
border: 1px solid color-mix(in srgb, rgb(34, 197, 94) 20%, transparent);
}

.notebook-cell__status--pending {
background: color-mix(in srgb, rgb(251, 191, 36) 10%, transparent);
color: theme('colors.amber.600');
color: #d97706;
border: 1px solid color-mix(in srgb, rgb(251, 191, 36) 20%, transparent);
}

.notebook-cell__status--error {
background: color-mix(in srgb, rgb(239, 68, 68) 10%, transparent);
color: theme('colors.red.600');
color: #dc2626;
border: 1px solid color-mix(in srgb, rgb(239, 68, 68) 20%, transparent);
}

Expand Down Expand Up @@ -339,7 +339,7 @@
======================================== */

.notebook-cell--markdown .notebook-cell__type-icon {
color: theme('colors.green.600');
color: #059669;
}

.notebook-cell__markdown-content {
Expand Down Expand Up @@ -473,7 +473,7 @@
/* Stream Output */
.notebook-cell__output--stream {
background: var(--color-bg-secondary);
color: theme('colors.green.400');
color: #4ade80;
padding: 1rem;
font-family: theme('fontFamily.mono');
font-size: 0.875rem;
Expand Down Expand Up @@ -537,17 +537,17 @@

/* Error Output */
.notebook-cell__output--error {
background: theme('colors.red.900');
color: theme('colors.red.100');
border-color: theme('colors.red.700');
background: #7f1d1d;
color: #fee2e2;
border-color: #b91c1c;
padding: 1rem;
}

.notebook-cell__error-name {
font-weight: 700;
font-size: 1rem;
margin-bottom: 0.5rem;
color: theme('colors.red.300');
color: #fca5a5;
}

.notebook-cell__error-value {
Expand All @@ -565,7 +565,7 @@

.notebook-cell__traceback-line {
padding: 0.125rem 0;
border-inline-start: 2px solid theme('colors.red.500');
border-inline-start: 2px solid #ef4444;
padding-inline-start: 0.75rem;
margin: 0.25rem 0;
}
Expand Down Expand Up @@ -642,7 +642,7 @@
======================================== */

.notebook-cell--raw .notebook-cell__type-icon {
color: theme('colors.purple.600');
color: #9333ea;
}

.notebook-cell__raw-content {
Expand Down Expand Up @@ -1085,17 +1085,17 @@

@media (prefers-contrast: high) {
.notebook__cells {
--notebook-border: theme('colors.gray.900');
--cell-border: theme('colors.gray.800');
--cell-hover-border: theme('colors.blue.700');
--cell-active-border: theme('colors.blue.600');
--notebook-border: #111827;
--cell-border: #1f2937;
--cell-hover-border: #1d4ed8;
--cell-active-border: #2563eb;
}

.dark .notebook__cells {
--notebook-border: theme('colors.gray.100');
--cell-border: theme('colors.gray.300');
--cell-hover-border: theme('colors.blue.300');
--cell-active-border: theme('colors.blue.400');
--notebook-border: #f3f4f6;
--cell-border: #d1d5db;
--cell-hover-border: #93c5fd;
--cell-active-border: #60a5fa;
}
}

Expand Down
Loading