From 627a882c43765e84f834a7af870f880501466177 Mon Sep 17 00:00:00 2001 From: j-mendez Date: Tue, 28 Nov 2023 09:45:58 -0500 Subject: [PATCH] chore(docs): add book start --- .github/workflows/CI.yml | 3 +++ .github/workflows/book.yml | 29 +++++++++++++++++++++++++++++ book/.gitignore | 1 + book/book.toml | 6 ++++++ book/src/README.md | 18 ++++++++++++++++++ book/src/SUMMARY.md | 5 +++++ book/src/nodejs.md | 29 +++++++++++++++++++++++++++++ 7 files changed, 91 insertions(+) create mode 100644 .github/workflows/book.yml create mode 100644 book/.gitignore create mode 100644 book/book.toml create mode 100644 book/src/README.md create mode 100644 book/src/SUMMARY.md create mode 100644 book/src/nodejs.md diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 8f90fa6..d1139ea 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -3,6 +3,9 @@ env: DEBUG: napi:* APP_NAME: spider-rs MACOSX_DEPLOYMENT_TARGET: '10.13' +concurrency: + group: ${{ github.ref }} + cancel-in-progress: true permissions: contents: write id-token: write diff --git a/.github/workflows/book.yml b/.github/workflows/book.yml new file mode 100644 index 0000000..db38bad --- /dev/null +++ b/.github/workflows/book.yml @@ -0,0 +1,29 @@ +name: github pages + +on: + push: + branches: + - main + pull_request: + +jobs: + deploy: + runs-on: ubuntu-20.04 + concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + steps: + - uses: actions/checkout@v2 + + - name: Setup mdBook + uses: peaceiris/actions-mdbook@v1 + with: + mdbook-version: 'latest' + + - run: cd book && mdbook build + + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + if: ${{ github.ref == 'refs/heads/main' }} + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./book/book \ No newline at end of file diff --git a/book/.gitignore b/book/.gitignore new file mode 100644 index 0000000..7585238 --- /dev/null +++ b/book/.gitignore @@ -0,0 +1 @@ +book diff --git a/book/book.toml b/book/book.toml new file mode 100644 index 0000000..c237585 --- /dev/null +++ b/book/book.toml @@ -0,0 +1,6 @@ +[book] +authors = ["j-mendez"] +language = "en" +multilingual = false +src = "src" +title = "spider-rs" diff --git a/book/src/README.md b/book/src/README.md new file mode 100644 index 0000000..27e3ea9 --- /dev/null +++ b/book/src/README.md @@ -0,0 +1,18 @@ +# Introduction + +Spider-RS is the fastest web crawler and indexer written in Rust. + +Spider powers some big tools and helps bring the crawling aspect to almost no downtime with the correct setup, view the [spider](https://github.com/spider-rs/spider) project to learn more. + + +Node.js powerhouse crawling in a few lines! + +```ts +import { Website } from "@spider-rs/spider-rs"; + +const website = new Website("https://rsseau.fr"); + +await website.crawl(); + +console.log(website.getLinks()); +``` \ No newline at end of file diff --git a/book/src/SUMMARY.md b/book/src/SUMMARY.md new file mode 100644 index 0000000..2b97e55 --- /dev/null +++ b/book/src/SUMMARY.md @@ -0,0 +1,5 @@ +# Summary + +[Introduction](./README.md) + +- [Node.js](./nodejs.md) diff --git a/book/src/nodejs.md b/book/src/nodejs.md new file mode 100644 index 0000000..dd55130 --- /dev/null +++ b/book/src/nodejs.md @@ -0,0 +1,29 @@ +# Node.js + +We use the node-addon to port the Rust project over with napi to target node.js. + +There are some performance drawbacks from the addon, even still the crawls are lightning fast and performant. + +## Installation + +1. `npm i @spider-rs/spider-rs --save` + +## Usage + +```ts +import { Website } from "@spider-rs/spider-rs"; + +const website = new Website("https://rsseau.fr") + .withHeaders({ + authorization: "somerandomjwt", + }) + .withBudget({ + // limit up to 200 pages crawled for the entire website + "*": 200, + }) + .withBlacklistUrl([new RegExp("/books").source, "/resume"]) + .build(); + +await website.crawl(); +console.log(website.getLinks()); +``` \ No newline at end of file