This guide explains how to work with the frontend resources repository, including how to generate the README.md file and how resources.json is used in the website.
- Generating README.md
- How resources.json is Used in the Website
- Adding New Resources
- Resource Data Structure
The README.md file is automatically generated from src/data/resources.json using a generator script. This ensures the README stays in sync with the actual resource data.
To generate the README.md file, run:
npm run generate:readmeThis command will:
- Read all resources from
src/data/resources.json - Read the template from
README.template.md - Group resources by category and map them to appropriate sections
- Generate a Table of Contents with proper anchor links
- Format resources as markdown bullet points
- Insert the generated content into the template
- Write the final
README.mdfile
The generator (src/lib/generator.ts) performs the following steps:
-
Reads Resources: Loads all resources from
src/data/resources.json -
Categorizes Resources: Uses the
getResourceSection()function to map each resource to a README section based on:- Resource category (Framework, Tool, Learning, etc.)
- Resource tags (for more specific categorization)
- Special rules for frameworks (React, Vue, Angular, etc.)
-
Generates Table of Contents: Creates a structured TOC with links to all sections, organized by main groups:
- Start Broad (HTML5, CSS, JavaScript/TypeScript)
- Core Concepts (Accessibility, Performance, Security, PWA)
- Frameworks & Libraries (React, Vue, Angular, etc.)
- Tooling (Build Tools, Testing, Linting, etc.)
- Beyond the Code (Design Systems, Animation, Data Visualization, etc.)
-
Generates Content Sections:
- Groups resources by section
- Sorts resources alphabetically within each section
- Formats each resource as:
- [Title](URL) - Description
-
Combines with Template:
- Reads
README.template.md(contains header, badges, contribution guidelines, etc.) - Inserts generated TOC and content after the "Table of Contents" marker
- Preserves the footer (Contributing, License sections)
- Reads
The generator uses intelligent mapping to place resources in the correct sections:
-
Framework resources are split by tags:
- React/Next.js β React Ecosystem
- Angular β Angular
- Vue/Nuxt β Vue.js
- Svelte/SvelteKit β Svelte
- etc.
-
Tool resources are categorized by type:
- Bundlers (Vite, Webpack, Rollup) β Build Tools & Bundlers
- Transpilers (Babel, SWC) β Transpiling & Compiling
- Linters (ESLint, Prettier) β Linting & Formatting
- Node.js tools β Development Tools
-
Learning resources are mapped to specific sections:
- HTML5 tags β HTML5 section
- CSS tags β CSS3 & SCSS section
- JavaScript/TypeScript tags β JavaScript / TypeScript section
- Others β Learning Resources section
You should regenerate the README.md file:
- After adding new resources to
resources.json - After modifying existing resources (title, description, category, tags)
- After removing resources
- Before committing changes to the repository
The src/data/resources.json file is the single source of truth for all resources displayed on the website. The website uses this JSON file through a data access layer.
resources.json β src/lib/resources.ts β Website Components
The resources.ts file provides several functions to work with resources:
Returns all resources from the JSON file. This is the main function used by the website.
import { getResources } from "@/lib/resources";
const allResources = getResources();Filters resources by a specific category.
const reactResources = getResourcesByCategory("Framework");Searches resources by title, description, or tags (case-insensitive).
const results = searchResources("react");Checks for duplicate IDs and URLs in the resources file. Useful for data integrity.
const validation = validateResources();
if (!validation.isValid) {
console.error(
"Duplicates found:",
validation.duplicateIds,
validation.duplicateUrls
);
}The website components use these functions to display resources:
import { getResources } from "../../lib/resources";
// Load all resources
const resources = useMemo(() => getResources(), []);
// Filter resources based on search and category
const filteredResources = useMemo(() => {
return resources.filter((resource) => {
const matchesSearch = /* search logic */;
const matchesCategory = /* category filter */;
return matchesSearch && matchesCategory;
});
}, [resources, search, selectedCategory]);Displays individual resource cards with:
- Resource title (linked to URL)
- Description
- Category icon (based on category)
- Tags
- Date added
- Like button (client-side only)
Provides a REST API endpoint that returns all resources:
import { getResources } from "@/lib/resources";
export async function GET() {
const resources = getResources();
return NextResponse.json(resources);
}Each resource in resources.json follows this structure:
{
"id": "unique-slug-for-your-resource",
"title": "Resource Title",
"url": "https://resource-url.com",
"description": "A short, one-sentence description.",
"category": "Framework",
"tags": ["tag1", "tag2", "tag3"],
"addedOn": "2024-01-01"
}The website supports these categories (defined in src/app/types/resource.ts):
- Framework
- UI Library
- Tool
- Learning
- Performance
- Testing
- State Management
- CSS
- TypeScript
- Accessibility
- Security
- PWA
- Animation
- Data Visualization
- 3D & WebGL
- Platforms & Hosting
- Public APIs
- Git
- Design Resources
- Utilities
- Web VR
- Search Functionality: Users can search resources by title, description, or tags
- Category Filtering: Users can filter resources by category
- Responsive Design: The website is fully responsive and works on all devices
- Client-Side Filtering: All filtering happens in the browser for fast performance
- Static Site: The website is a static Next.js site, so resources are loaded at build time
To add a new resource to the website:
-
Edit
src/data/resources.json:- Add a new object to the array
- Follow the resource structure (see above)
- Use a unique
id(kebab-case slug) - Choose an appropriate
category - Add relevant
tags
-
Regenerate README.md:
npm run generate:readme
-
Test the website:
npm run dev
- Verify the resource appears in the website
- Check that search and filtering work correctly
-
Validate resources (optional):
npm run testThis runs unit tests that check for duplicates and validate the data structure.
id(string): Unique identifier, typically a kebab-case slugtitle(string): Display name of the resourceurl(string): Full URL to the resourcedescription(string): One-sentence descriptioncategory(string): One of the supported categoriestags(string[]): Array of relevant tagsaddedOn(string): Date in YYYY-MM-DD format
-
IDs: Use kebab-case, lowercase, no special characters
- β
react-documentation - β
React Documentation
- β
-
Descriptions: Keep them concise (one sentence), informative, and start with a capital letter
-
Tags: Use lowercase, relevant tags that help with search
- Include the main technology (e.g., "react", "vue", "css")
- Include the type (e.g., "documentation", "tutorial", "tool")
- Include relevant concepts (e.g., "hooks", "routing", "animation")
-
Categories: Choose the most specific category that fits
- Framework resources β "Framework"
- UI component libraries β "UI Library"
- Development tools β "Tool"
- Learning materials β "Learning"
-
URLs: Always use HTTPS when available, and ensure URLs are valid
- Make sure you ran
npm run generate:readme - Check that
resources.jsonis valid JSON (no syntax errors) - Verify the generator script completed without errors
- Check that the resource is in
resources.json - Verify the JSON syntax is correct
- Make sure the category matches one of the supported categories
- Restart the dev server:
npm run dev
- Run the validation function:
validateResources() - Check for duplicate IDs or URLs
- Remove or merge duplicate entries
- README.md: Generated automatically from
resources.jsonusingnpm run generate:readme - Website: Uses
resources.jsonthroughsrc/lib/resources.tsfunctions - Single Source of Truth:
src/data/resources.jsoncontains all resource data - Always regenerate README.md after modifying
resources.json