Skip to content

Commit

Permalink
Merge pull request #18 from dreyfus92/feat-docs
Browse files Browse the repository at this point in the history
add: documentation website for `sloth-pipe`
  • Loading branch information
trvswgnr committed Feb 3, 2024
2 parents dbb2a2b + 7a2d23f commit af2625c
Show file tree
Hide file tree
Showing 31 changed files with 569 additions and 50 deletions.
96 changes: 72 additions & 24 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,62 +1,110 @@
# macOS-specific files
.DS_Store

# Windows-specific files
Thumbs.db

# Jetbrains specific files
.idea

# Environment variables
.env
.env.local
.env.development.local
.env.test.local
.env.production.local
.env.local
_scratch*
logs
_.log

# Node modules and logs
node_modules/
npm-debug.log_
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
.cache
*.tgz
.yarn-integrity
.parcel-cache
.next
.out
.nuxt
.dist
.vuepress/dist
.temp
.docusaurus
.serverless/
.fusebox/
.dynamodb/
.tern-port
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# Debug logs
_scratch*
logs
_.log

# Report files
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json

# Process IDs
pids
_.pid
_.seed
*.pid.lock

# Coverage reports
lib-cov
coverage
*.lcov
.nyc_output

# Grunt intermediate storage
.grunt

# Bower components
bower_components

# Node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
node_modules/

# JSPM packages
jspm_packages/

# Web modules
web_modules/

# TypeScript build info
*.tsbuildinfo

# NPM debug logs
.npm

# Linter caches
.eslintcache
.stylelintcache

# Rollup plugin caches
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Node.js REPL history
.node_repl_history
*.tgz
.yarn-integrity
.parcel-cache
.next
out
.nuxt
dist
.vuepress/dist
.temp
.docusaurus
.serverless/
.fusebox/
.dynamodb/
.tern-port
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# Visual Studio Code
.vscode
.vscode-test

# generated types from Astro
.astro/

# Astro's build output
dist/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![sloth-pipe](readme-banner.png)
![sloth-pipe](/docs/src/assets/readme-banner.png)

# Sloth Pipe

Expand Down
Binary file modified bun.lockb
Binary file not shown.
54 changes: 54 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Starlight Starter Kit: Basics

[![Built with Starlight](https://astro.badg.es/v2/built-with-starlight/tiny.svg)](https://starlight.astro.build)

```
npm create astro@latest -- --template starlight
```

[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/starlight/tree/main/examples/basics)
[![Open with CodeSandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/p/sandbox/github/withastro/starlight/tree/main/examples/basics)
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fwithastro%2Fstarlight%2Ftree%2Fmain%2Fexamples%2Fbasics&project-name=my-starlight-docs&repository-name=my-starlight-docs)

> 🧑‍🚀 **Seasoned astronaut?** Delete this file. Have fun!
## 🚀 Project Structure

Inside of your Astro + Starlight project, you'll see the following folders and files:

```
.
├── public/
├── src/
│ ├── assets/
│ ├── content/
│ │ ├── docs/
│ │ └── config.ts
│ └── env.d.ts
├── astro.config.mjs
├── package.json
└── tsconfig.json
```

Starlight looks for `.md` or `.mdx` files in the `src/content/docs/` directory. Each file is exposed as a route based on its file name.

Images can be added to `src/assets/` and embedded in Markdown with a relative link.

Static assets, like favicons, can be placed in the `public/` directory.

## 🧞 Commands

All commands are run from the root of the project, from a terminal:

| Command | Action |
| :------------------------ | :----------------------------------------------- |
| `npm install` | Installs dependencies |
| `npm run dev` | Starts local dev server at `localhost:4321` |
| `npm run build` | Build your production site to `./dist/` |
| `npm run preview` | Preview your build locally, before deploying |
| `npm run astro ...` | Run CLI commands like `astro add`, `astro check` |
| `npm run astro -- --help` | Get help using the Astro CLI |

## 👀 Want to learn more?

Check out [Starlight’s docs](https://starlight.astro.build/), read [the Astro documentation](https://docs.astro.build), or jump into the [Astro Discord server](https://astro.build/chat).
64 changes: 64 additions & 0 deletions docs/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { defineConfig } from 'astro/config';
import starlight from '@astrojs/starlight';

/* https://vercel.com/docs/projects/environment-variables/system-environment-variables#system-environment-variables */
const VERCEL_PREVIEW_SITE =
process.env.VERCEL_ENV !== 'production' &&
process.env.VERCEL_URL &&
`https://${process.env.VERCEL_URL}`;

//TODO: Fix this
const site = VERCEL_PREVIEW_SITE || 'https://slothpipe.techsavvytravvy.com/';


// https://astro.build/config
export default defineConfig({
integrations: [
starlight({
title: 'Sloth Pipe',
social: {
github: 'https://github.com/trvswgnr/sloth-pipe',
"x.com": "https://twitter.com/techsavvytravvy",
},
favicon: '/public/favicon.ico',
head: [
{
tag: 'meta',
attrs: { property: 'og:image', content: site + 'og.jpg?v=1' },
},
{
tag: 'meta',
attrs: { property: 'twitter:image', content: site + 'og.jpg?v=1' },
},
],
customCss: [
// Relative path to your custom CSS file
'./src/styles/custom.css',
],
editLink: {
baseUrl:
"https://github.com/trvswgnr/sloth-pipe/edit/main/docs/",
},
lastUpdated: true,
sidebar: [
{
label: 'Getting started',
items: [
{ label: 'Why Sloth Pipe?', link: '/getting-started/why/' },
{ label: 'Installation', link: '/getting-started/installation/' },
{ label: 'Usage', link: '/getting-started/usage/' },
],
},
{
label: 'Reference',
items: [
{ label: 'Pipe Function', link: '/reference/pipe-function/' },
{ label: 'Methods', link: '/reference/methods/' },
{ label: 'Error Handling', link: '/reference/error-handling/' },
{ label: 'Async Await Support', link: '/reference/async-await-support/' },
],
},
],
}),
],
});
19 changes: 19 additions & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "docs",
"type": "module",
"version": "0.0.1",
"scripts": {
"dev": "astro dev",
"start": "astro dev",
"build": "astro check && astro build",
"preview": "astro preview",
"astro": "astro"
},
"dependencies": {
"@astrojs/starlight": "^0.17.2",
"astro": "^4.2.1",
"sharp": "^0.32.5",
"@astrojs/check": "^0.4.1",
"typescript": "^5.3.3"
}
}
Binary file added docs/public/favicon.ico
Binary file not shown.
Binary file added docs/public/og.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
7 changes: 7 additions & 0 deletions docs/src/content/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineCollection } from 'astro:content';
import { docsSchema, i18nSchema } from '@astrojs/starlight/schema';

export const collections = {
docs: defineCollection({ schema: docsSchema() }),
i18n: defineCollection({ type: 'data', schema: i18nSchema() }),
};
32 changes: 32 additions & 0 deletions docs/src/content/docs/getting-started/installation.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
title: Installation
description: Learn how to install sloth-pipe in your project.
---

import { Tabs, TabItem } from '@astrojs/starlight/components';

Add `sloth-pipe` to your project using your favorite package manager:

<Tabs>
<TabItem label="npm">
```bash
npm install sloth-pipe
```
</TabItem>
<TabItem label="yarn">
```bash
yarn add sloth-pipe
```
</TabItem>
<TabItem label="pnpm">
```bash
pnpm add sloth-pipe
```
</TabItem>
<TabItem label="pnpm">
```bash
bun install sloth-pipe
```
</TabItem>
</Tabs>

59 changes: 59 additions & 0 deletions docs/src/content/docs/getting-started/usage.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
title: Usage
description: Learn how to use sloth-pipe in your projects.
---

Sloth Pipe is a functional library designed to streamline the process of applying a sequence of
transformations to a value in TypeScript. It enables chaining multiple operations in a clear and
readable manner.

## Importing the Library

Begin by importing the Pipe function from the sloth-pipe library:

```ts
import { Pipe } from "sloth-pipe";
```

## Initializing the Pipe

Create a new pipe instance by calling Pipe() with the initial value. This value is the starting
point for subsequent transformations:

```ts
const pipeInstance = Pipe(5);
```

## Applying Transformations

Use the .to() method to define transformations. Each .to() takes a function as an argument. This
function describes how the current value should be transformed:

The first transformation multiplies the input by 2:

```ts
.to((x) => x * 2)
```

The second transformation adds 3 to the result of the first transformation:

```ts
.to((x) => x + 3)
```

## Executing the Pipe

Complete the chain of transformations with the .exec() method. This method executes the
transformations in sequence and returns the final result:

```ts
const result = pipeInstance.exec();
```

## Output:

The final result can be used as needed. In this example, it's logged to the console:

```ts
console.log(result); // Outputs: 13
```
Loading

0 comments on commit af2625c

Please sign in to comment.