Improve Site Name Handling, Tag Page Mobile Layout, and Share Button UX
Summary
Enhanced site name handling logic to use properly cased filenames and improved URL fallbacks, while fixing mobile layout spacing issues on tag pages by removing redundant "Related Tags" text and adding appropriate responsive margins. Additionally, significantly improved the share button user experience by relocating it from the sidebar to the main content filter header with consistent styling and better mobile responsiveness.
Why Care
These changes significantly improve the user experience by displaying more meaningful and properly formatted site names instead of URLs, while ensuring the tag pages look polished on mobile devices. The share button relocation makes sharing filtered toolkit views much more discoverable and accessible to users. The improvements make the toolkit more professional and easier to navigate across all screen sizes.
Implementation
Changes Made
Modified Files:
site/src/utils/toolUtils.ts- EnhancedgetEffectiveSiteName()function and addedgetActualFilename()helpersite/src/pages/toolkit/tag/[tag].astro- Improved mobile layout spacing and data mappingsite/src/components/basics/CardGrid.astro- Added share button to filter header with consistent stylingsite/src/components/tool-components/TagColumn.astro- Removed share button functionality (moved to CardGrid)
New Files Created:
site/src/pages/toolkit/tag/[tag].astro- Tag-specific toolkit page with responsive layout
Detailed Changes:
site/src/utils/toolUtils.ts:
- Enhanced
getEffectiveSiteName()function with improved fallback logic:- Added proper null/empty string checking with
.trim() - Improved URL hostname processing to remove common TLD extensions (.com, .org, .net, .io, .co, .ai, .app, .dev)
- Added support for international TLDs (.co.uk, .com.au, .co.jp)
- Implemented proper capitalization for extracted hostnames
- Added new
getActualFilename()helper function:- Extracts actual filename with proper casing from Astro entry objects
- Supports both
filePathandoriginalFilenameproperties - Provides fallback to entry ID when file path unavailable
site/src/pages/toolkit/tag/[tag].astro:
- Fixed mobile layout spacing by adding
mt-8 lg:mt-0classes to sidebar - Removed redundant "Related Tags" heading text for cleaner UI
site/src/components/basics/CardGrid.astro:
- Added share button to filter header - Relocated from TagColumn for better discoverability
- Implemented consistent styling - Used site's CSS variable system (
--clr-sidebar-bg,--clr-text-primary, etc.) - Added mobile responsiveness - Responsive design with 768px breakpoint, adjusted padding and button sizes
- Maintained full functionality - Preserved clipboard copy, URL sharing, and visual feedback states
- Enhanced UX - Share button now appears in main content flow rather than sidebar
site/src/components/tool-components/TagColumn.astro:
- Removed share button functionality - Cleaned up 71 lines of JavaScript code for share button logic
- Removed share button CSS - Cleaned up 43 lines of CSS styles for
.share-btnand related states - Streamlined component - Focused TagColumn on its core tag filtering functionality
- Updated data mapping to use
getActualFilename(entry)for proper filename handling - Added import for
getActualFilenameutility function
Technical Details
Site Name Fallback Priority:
- site_name field from frontmatter (highest priority)
- filename with proper casing and .md extension removed
- URL hostname with smart processing:
- Strip common TLD extensions
- Capitalize first letter
- Fallback to full URL if parsing fails
Code Sample - Enhanced getEffectiveSiteName():
typescript
// site/src/utils/toolUtils.ts
export function getEffectiveSiteName(site_name: string, filename: string, url: string): string {
// Priority: site_name > filename > url hostname
if (site_name && site_name.trim()) {
return site_name.trim();
}
if (filename && filename.trim()) {
// Remove .md extension if present and preserve original casing
return filename.replace(/\.md$/, '');
}
if (url && url.trim()) {
try {
const urlObj = new URL(url);
let hostname = urlObj.hostname;
// Remove www. prefix if present
if (hostname.startsWith('www.')) {
hostname = hostname.substring(4);
}
// Remove common TLD extensions for cleaner display
const cleanHostname = hostname
.replace(/\.(com|org|net|io|co|ai|app|dev)$/, '')
.replace(/\.(co\.uk|com\.au|co\.jp)$/, '');
// Capitalize first letter for better display
return cleanHostname.charAt(0).toUpperCase() + cleanHostname.slice(1);
} catch {
return url;
}
}
return '';
} Mobile Layout Fix:
astro
<!-- site/src/pages/toolkit/tag/[tag].astro -->
<aside class="lg:col-span-1 mt-8 lg:mt-0">
<div class="sticky top-8">
<!-- Removed: <h3 class="text-lg font-semibold mb-4">Related Tags</h3> -->
<div class="tag-cloud space-y-2"> Integration Points
Data Flow Integration:
- Tag pages now pass actual filenames to ToolCard components via updated data mapping
- ToolCard components receive properly formatted filenames for site name processing
- Site name handling is consistent across all toolkit pages
Component Dependencies:
ToolCard.astrorelies on the enhancedgetEffectiveSiteName()function- Tag pages depend on
getActualFilename()for proper filename extraction - Responsive layout classes ensure consistent behavior across screen sizes
Documentation
Usage Examples:
Before (problematic):
- Site names showed as "github.com" or "docs.anthropic.com"
- Mobile tag pages had cramped spacing
- Filenames were lowercase IDs instead of proper names
After (improved):
- Site names display as "GitHub" or "Anthropic"
- Mobile tag pages have proper spacing from top separator
- Filenames preserve original casing like "AI SDK.md" → "AI SDK"
Performance Impact:
- Minimal performance impact - only affects string processing
- No additional network requests or database queries
- Improved user experience with cleaner, more readable site names
Browser Compatibility:
- Uses standard JavaScript string methods and URL constructor
- Responsive CSS classes compatible with modern browsers
- Graceful fallbacks for URL parsing errors