repos / neovimcraft

website that makes it easy to find neovim plugins
git clone https://github.com/neurosnap/neovimcraft.git

commit
7cca1c4
parent
a56776f
author
Eric Bower
date
2021-07-20 04:16:22 +0000 UTC
update readme
3 files changed,  +22, -4
M README.md
+17, -0
 1@@ -13,16 +13,33 @@ export GITHUB_USERNAME='my-user'
 2 
 3 To run the scraper
 4 
 5+```bash
 6+yarn scrape
 7+```
 8+
 9+This will fetch data from remote sources and then save them to our
10+`resources.json` file. This file is our source-of-truth for the plugins we
11+eventually save.
12+
13+To fetch and process the results in our `results.json` file
14+
15 ```bash
16 yarn process
17 ```
18 
19+This will use the github api to fetch information about the resources and also
20+fetch the associated readme for each resource and save them to `db.json` and
21+`markdown.json`
22+
23 To convert markdown files to html
24 
25 ```bash
26 yarn transform
27 ```
28 
29+This will create an `html.json` file which contains the readme html which we
30+use for each plugin page.
31+
32 Once you've created a project and installed dependencies with `yarn`, start a development server:
33 
34 ```bash
M src/routes/index.svelte
+2, -2
 1@@ -68,10 +68,10 @@
 2 
 3     const onFilter = (plugin: Plugin) => {
 4       if (search.includes('tag:')) {
 5-        const nextSearch = search.replace('tag:', '');
 6+        const nextSearch = search.toLocaleLowerCase().replace('tag:', '');
 7         return plugin.tags.some((tag) => tag === nextSearch);
 8       }
 9-      return plugin.id.toLocaleLowerCase().includes(search);
10+      return plugin.id.toLocaleLowerCase().includes(search.toLocaleLowerCase());
11     };
12 
13     return plugins.filter(onFilter);
M src/scrape.ts
+3, -2
 1@@ -76,10 +76,11 @@ async function processMarkdown(text: string) {
 2 async function updateResources(resources: Resource[]) {
 3   const db: ResourceMap = {};
 4   const getId = (r: Resource) => `${r.username}/${r.repo}`;
 5-  resourceFile.resources.forEach((r: Resource) => {
 6+  resources.forEach((r) => {
 7     db[getId(r)] = r;
 8   });
 9-  resources.forEach((r) => {
10+  // resource file trumps what we scrape so we can make changes to things like the tags
11+  resourceFile.resources.forEach((r: Resource) => {
12     db[getId(r)] = r;
13   });
14