-
-
Notifications
You must be signed in to change notification settings - Fork 130
Migrating the snippet format to a markdown approach #88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrating the snippet format to a markdown approach #88
Conversation
✅ Deploy Preview for quicksnip ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Yeah, at the start i had a config file in each language folder, but it gets messy... And i don't quite like the idea... What is the issue with the current naming ? The fact that things like Css aren't all upper case ? |
One way would be to inverse the process, making the folder have the non-slugified name, and slufifying it later with the consolidate, i'm going to try that |
…the slug name of the language
@dostonnabotov The commit i just pushed should fixed it... |
I like the naming convention in language folders, all lowercase. It's more consistent. How about we uppercase all when showing in the website to avoid headaches? |
Yeah i guess that's another way to do it xD |
…tead of the slug name of the language" This reverts commit 63eaf19.
… and contributor array
I think markdown code block should specify the language |
Yes, they can, but the migrate script doesn't add them automaticly, i will add that |
If you are using bash, you can use this sed -i "s/\`\`\`/\`\`\`$1" "$2" $1 is directory as in language |
@saminjay I fixed that 👍 |
import { copyFileSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from 'fs'; | ||
import { join } from 'path'; | ||
|
||
function slugify(string, separator = "-") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is non-reversible, reverseSlugify
will work correctly on more complex strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's only used to migrate snippets, the script will get removed once the migration is done, so it's ugly, and not really "smart", don't worry about it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it's also used to create category names from folder name, but it's the only choice we have, avoiding having config files again everywhere, and category files should only contain basic words, so it's reversable
Description
As we discussed in the discord, contributing and reviewing pull request is becoming harder, largly due to the way snippets are stored.
This PR changes that by introducing a
snippets
folder at the root of the project, this folder contains folders for each languages and categories, snippets are defined with markdown files with a simple structure.The most important commit of this PR is the first one, the second one migrates already existing snippets to the
snippets
folder, the third one re generates the json language files with the new format, and the fourth fixes issue with the code of snippets switching from an array to a continuous string.So this PR adds three scrips and one util:
migrateSnippets.js
- Which generates thesnippets
folder from language files (It can be removed when we this gets merged)snippetParser.js
- This is the util, it exposes function that allow for parsing the snippet folder.checkSnippetFormatting.js
- Just checks the formating of the snippets usingsnippetParser.js
it does not modify anything (Should be runned on commit/PR)consolidateSnippets.js
- Takes all the snippets and generates the language json files under/public/data
, also copies the icon in the right places and generates the/public/data/_index.json
file.Checklist