Skip to content

Commit

Permalink
add overview
Browse files Browse the repository at this point in the history
  • Loading branch information
CordlessWool committed Mar 28, 2024
1 parent 5ccba92 commit f78475f
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 7 deletions.
23 changes: 17 additions & 6 deletions documentation/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,39 @@ import { defineConfig } from 'vitepress'
export default defineConfig({
title: "loom-io",
description: "loom your file handling",
lastUpdated: true,
themeConfig: {
logo: "/loom-io.png",
// https://vitepress.dev/reference/default-theme-config
nav: [
{ text: 'Home', link: '/' },
{ text: 'Documentation', link: '/introduction' }
{ text: 'Documentation', link: '/core/intro' }
],

sidebar: [
{
text: 'Getting Started',
items: [
{ text: 'Introduction', link: '/intro' },
{ text: 'Install', link: '/install' },
{ text: 'First steps', link: '/getting-started' }
{ text: 'Introduction', link: '/core/intro' },
{ text: 'Install', link: '/core/install' },
{ text: 'Overview', link: '/core/overview' },
{ text: 'Directory', link: '/core/directory' },
{ text: 'File', link: '/core/file' },
{ text: 'Editor', link: '/core/editor' }
]
},
{
text: 'Source Adapter',
items: [
{ text: 'In-Memory', link: '/adapter/in-memory-adapter' },
{ text: 'Filesystem (node)', link: '/adapter/node-fs-adapter' },
{ text: 'S3', link: '/adapter/minio-s3-adapter' }
{ text: 'S3-Minio', link: '/adapter/minio-s3-adapter' }
]
},
{
text: 'Converter',
items: [
{ text: 'JSON', link: '/converter/markdown-converter' },
{ text: 'YAML', link: '/converter/yaml-converter' }
]
}
],
Expand Down
2 changes: 1 addition & 1 deletion documentation/install.md → documentation/core/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ bun add @loom-io/core

:::

This package will not work out of the box, because it is missing an adapter to connect files. For example to get a similar functionality as in the filesystem bundle you need to install the filesystem adapter and some converter to convert different filetypes to json.
This package will not work out of the box, because it is missing an adapter to connect a storage system e.g. S3, Filesystem . For example to get a similar functionality as in the filesystem bundle you need to install the filesystem adapter and some converter to convert different filetypes to json.

::: code-group

Expand Down
File renamed without changes.
59 changes: 59 additions & 0 deletions documentation/core/overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Overview

loom-io simplify the access to different storing systems and brings you additional functionality like reading directories recursive, search files, read them line by line or auto convert files to json.

Take at the specific chapter to get all details of functionality, at least how to build an own plugin. This chapter should just give you an overview for orientation.

## Basic Setup

The default export of loom-io is a global Object you can import at server side without register a plugin or adapter again and again. We will import it as `Loom`, but you can give it any name.

If you are not using a base bundle you need to register an adapter and probably some converters to read files as json. To keep the examples more generic we will import `Loom` from the core library. If you are using a bundle replace the import `@loom-io/core` with the bundle name e.g. `@loom-io/base-fs`.

```ts
import Loom from "@loom-io/core";
import s3MinioAdapter from "@loom-io/minio-s3-adapter";
import JSONConverter from "@loom-io/json-converter";

Loom.register(
s3MinioAdapter("s3://", {
bucketName: "test",
endPoint: "play.min.io",
port: 9000,
useSSL: true,
accessKey: "key",
secretKey: "secure",
})
);

Loom.register(JSONConverter);
```

Now we can dive deeper into loom-io and the storing system to access or create files and directories.

## Basic examples

Here are some basic examples to get a impression of the library usage

### List all files in a directory

This is one of the first functions implemented in the library and one of the main reason. We already registered an adapter above so it will be not necessary to have a second one, but to have a full example we will do it anyways. To get all details about the adapter or dir take a look to the doc sections

```ts
import Loom, { isFile, isDirectory } from "@loom-io/core";
import fsAdapter from "@loom-io/node-filesystem-adapter";

// We add the adapter for filesystem now.
// By default the root of our filesystem is your project directory
Loom.register(fsAdapter("file://"));

// the directory do not have to exist
//select the root dir, in this case the project dir
const dir = await Loom.dir("file://");
//read dir recursive and search for files
const files = await dir.files(true);

for (let file of files) {
console.log(file.path);
}
```
Binary file added documentation/loom-io.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f78475f

Please sign in to comment.