Skip to content

Commit

Permalink
Fix syntax error in guidelines
Browse files Browse the repository at this point in the history
  • Loading branch information
dostonnabotov committed Jan 1, 2025
1 parent 49692f9 commit e9ee067
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 20 deletions.
36 changes: 20 additions & 16 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,49 +43,51 @@ 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
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
Expand All @@ -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
Expand All @@ -105,8 +107,10 @@ author: original-author
contributors: your-github-username
---

```
Updated code here
```
````

2. **Credit all contributors:**

Expand Down Expand Up @@ -141,10 +145,10 @@ Example structure:

```md
/snippets
|_ python
|_ file-handling
|_ list-manipulation
|_ ....
|- python
|- file-handling
|- list-manipulation
|- ....
```

### Adding a New Language
Expand Down
35 changes: 31 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. 🚀

<a href="https://youtu.be/BhRi7fJzPgk?si=z1sVXU7uRS0bkSEt" target="_blank" style="text-decoration: none;">
<img src="https://img.shields.io/static/v1?label=&message=Watch%20on%20YouTube&labelColor=FFFFFF&color=FF0000&style=for-the-badge&logo=youtube&logoColor=FF0000" alt="Watch on YouTube" style="margin-right: 20px">
<div>
<a href="https://youtu.be/BhRi7fJzPgk?si=z1sVXU7uRS0bkSEt" target="_blank">
<img src="https://img.shields.io/static/v1?label=&message=Watch%20on%20YouTube&labelColor=FFFFFF&color=FF0000&style=for-the-badge&logo=youtube&logoColor=FF0000" alt="Watch on YouTube">
</a>
<div>

<br>

Expand Down Expand Up @@ -36,20 +38,45 @@ 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
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.

Expand Down

0 comments on commit e9ee067

Please sign in to comment.