Commit c734119
authored
feat: implement
This Pull request implement the `word-editor` script; the primary
functionality of this script is to allowing adding new word, retrieve
and update existing word which are individual `.mdx` files residing in
the `src/pages/browse` directory of the project. This script avails us
of all the helper functions required to perform this operations.
### Changes Made
- Implemented the `writeNewWord` function - this function takes 3 params
namely the `userOctokit`, `forkedRepoDetails`, and the `word`; it
leverages the `userOctokit` instance to perform a write operation i.e.
writing a new file (newWord.mdx) to a fork of our project on the user's
account on behalf of the user through the `"PUT
/repos/{owner}/{repo}/contents/{path}"` endpoint
- Impelemented the `getExistingWord` function - this function helps
retrieve data of existing words in the fork of our project on the user's
account by calling the `"GET /repos/{owner}/{repo}/contents/{path}"`
endpoint; it returns an object which carries the following properties
that we are mostly interested in...
- `title` - title of the the existing word - this infact is a custom
appended data to the `response.data` from the call made to the endpoint
- `path` - path to the existing word file
- `sha` - unique SHA of the existing word
- Implemented the `editExistingWord` function - this function takes 3
params namely the `userOctokit`, `forkedRepoDetails`, and the `word`
(holds the properties: `path`, `sha`, `title` and `content`); it
leverages the `userOctokit` instance to perform a edit operation i.e.
updating the existing file on a fork of our project on the user's
account on behalf of the user through thesame `"PUT
/repos/{owner}/{repo}/contents/{path}"` endpoint
- Implemented `writeFileContent` helper function - this function help
write a content for our dictionary word file generating them from
another added constant in the `src/lib/template/word.md.js`
### Screencast/Screenshot
_too lazy to record a screencast for this one_ 😜, _but trust me_ 🤞 _the
shit works_ 😮💨word-editor script (#18)1 parent 07f6f9d commit c734119
3 files changed
Lines changed: 116 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
24 | 33 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
0 commit comments