diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 77105539..62adf023 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -43,7 +43,7 @@ To add a new code snippet: - Use the following format to structure your snippet: -```md +````md --- title: Name of the snippet description: A short explanation of what the snippet does @@ -51,41 +51,43 @@ tags: tag1, tag2, tag3 author: your-github-username --- +```lang // Your code here ``` +```` Here’s an example for JavaScript: -``` +````md --- title: Format Date description: Formats a date in 'YYYY-MM-DD' format. author: dostonnabotov -tags: javascript,date,format,utility +tags: javascript,date,format --- +```js const formatDate = (date) => date.toISOString().split('T')[0]; // Usage: console.log(formatDate(new Date())); // Output: '2024-12-10' ``` +```` 5. **Use syntax highlighting:** - Enclose your code with triple backticks (```). - Specify the language after the first set of backticks for syntax highlighting. -![snippet code example in markdown file](https://github.com/user-attachments/assets/be650cfe-fd17-49e7-ae82-e1c88e30d4c9) - 6. **Test your snippet:** - Ensure your code runs as expected. -Expected structure: +Expected file structure: -```txt -snippets - |- language - |- category - |- your-snippet-here.md +```md +/snippets + |- language + |- category-name + |- your-snippet-here.md ``` ### Editing a Existing Snippet @@ -96,7 +98,7 @@ If you’d like to refine or improve an existing snippet: - Include your GitHub username under the `contributors` field in the metadata section. -```md +````md --- title: Name of the snippet description: A short explanation of what the snippet does @@ -105,8 +107,10 @@ author: original-author contributors: your-github-username --- +``` Updated code here ``` +```` 2. **Credit all contributors:** @@ -141,10 +145,10 @@ Example structure: ```md /snippets - |_ python - |_ file-handling - |_ list-manipulation - |_ .... + |- python + |- file-handling + |- list-manipulation + |- .... ``` ### Adding a New Language diff --git a/README.md b/README.md index e34b94e3..4826cfb3 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,11 @@ An open-source project that categorizes handy code snippets across various programming languages. Built with love and powered by an awesome community. 🚀 - - Watch on YouTube +
+ + Watch on YouTube +

@@ -36,7 +38,7 @@ The snippets database is located in the `/snippets` folder. 3. Create a markdown file and add your snippet using the following format: -```md +````md --- title: Name of the snippet description: A short explanation of what the snippet does @@ -44,12 +46,37 @@ tags: tag1, tag2, tag3 author: your-github-username --- +```lang // Your code here ``` +```` Here's an example for JavaScript: -![code example in markdown file](https://github.com/user-attachments/assets/dba9fda3-76fe-4d92-b12a-8bc065286b90) +````md +--- +title: Format Date +description: Formats a date in 'YYYY-MM-DD' format. +author: dostonnabotov +tags: javascript,date,format +--- + +```js +const formatDate = (date) => date.toISOString().split('T')[0]; + +// Usage: +console.log(formatDate(new Date())); // Output: '2024-12-10' +``` +```` + +Expected file structure: + +```md +/snippets + |- language + |- category-name + |- your-snippet-here.md +``` For more details about adding new categories or programming languages, check out the [CONTRIBUTING.md](/CONTRIBUTING.md) file.