Skip to content
This repository was archived by the owner on Nov 23, 2022. It is now read-only.

Commit 90fb36a

Browse files
committed
feat(blog): add peerchat blog post
1 parent 9865e7a commit 90fb36a

File tree

4 files changed

+96
-8
lines changed

4 files changed

+96
-8
lines changed

docs/README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ DStack was created to bring together some of the popular libraries for the decen
1414

1515
## What DStack offers
1616

17-
Currently you can use DStack as a peer-to-peer distributed KV/Graph database
17+
DStack simplifies IPFS JavaScript API for application development usage
1818

19-
_**[See milestones](https://github.com/0x77dev/dstack/milestones)**_
19+
Also provides relay node and Store API
20+
21+
Checkout [Peerchat](https://dstack.0x77.dev/blog/peerchat) demo
2022

2123
[license]: https://github.com/0x77dev/dstack/blob/main/LICENSE
2224
[license-badge]: https://img.shields.io/github/license/0x77dev/dstack

docs/blog/hello-world.md

+11-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,18 @@ DStack was created to bring together some of the popular libraries for the decen
1414

1515
## What DStack offers
1616

17-
Currently you can use DStack as a globally distributed GraphQL cache system built on top of [IPFS DAG API](https://github.com/ipfs/js-ipfs/blob/master/docs/core-api/DAG.md#dag-api-)
17+
DStack simplifies IPFS JavaScript API for application development usage
18+
19+
DStack provides:
20+
21+
- Store API
22+
- PubSub API
23+
- Relay
24+
25+
Checkout [Peerchat](/blog/peerchat) demo
26+
27+
Play with DStack in a [Playground](https://dstack-playground.netlify.app)
1828

1929
## Getting started
2030

2131
See [Tutorial](/docs/intro) to get started using DStack in your app
22-

docs/blog/peerchat.md

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
slug: peerchat
3+
title: Peerchat
4+
authors:
5+
- 0x77dev
6+
tags: [dstack, example, demo, peerchat]
7+
---
8+
9+
## Introduction
10+
11+
Peerchat is a CLI app that allows to chat via DStack PubSub API without any configuration
12+
13+
## Demo
14+
15+
![Demo](https://github.com/dstack-js/chat/raw/main/docs/demo.svg)
16+
17+
_Recording looks ugly, but in terminal it seems to be fine_
18+
19+
## Try it out!
20+
21+
### Install
22+
23+
```console
24+
$ npm i -g peerchar
25+
```
26+
27+
```console
28+
$ yarn global add peerchar
29+
```
30+
31+
```console
32+
$ npx peerchar
33+
```
34+
35+
### Usage
36+
37+
```console
38+
$ # peerchat [channel] [nickname]
39+
$ peerchat dstack steve
40+
```
41+
42+
## How it works?
43+
44+
DStack provides PubSub API
45+
46+
Peerchat uses it to communicate between users
47+
48+
### Code Examples
49+
50+
#### Listening to messages
51+
52+
```javascript
53+
await stack.pubsub.subscribe(room, (event) => {
54+
const username = event.data.nickname
55+
? `${event.data.nickname} (${event.from.slice(-5)})`
56+
: event.from.slice(-5);
57+
58+
messageList.addItem(`${username}: ${event.data.message}`);
59+
messageList.scrollTo(100);
60+
screen.render();
61+
});
62+
```
63+
64+
#### Sending message
65+
66+
```javascript
67+
await pubsub.publish(room, { nickname, message });
68+
```
69+
70+
---
71+
72+
[Peerchat repository](https://github.com/dstack-js/chat)
73+
74+
## Get started with DStack
75+
76+
See [Tutorial](/docs/intro) to get started using DStack in your app

docs/src/css/custom.css

+5-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/* You can override the default Infima variables here. */
88
:root {
99
--docusaurus-btt-color: black;
10-
--ifm-color-primary: #25c2a0;
10+
--ifm-color-primary: #fcf9e8;
1111
--ifm-color-primary-dark: rgb(33, 175, 144);
1212
--ifm-color-primary-darker: rgb(31, 165, 136);
1313
--ifm-color-primary-darkest: rgb(26, 136, 112);
@@ -16,7 +16,8 @@
1616
--ifm-color-primary-lightest: rgb(146, 224, 208);
1717
--ifm-code-font-size: 95%;
1818
--ifm-navbar-link-color: black;
19-
--ifm-color-primary: #FCF9E8;
19+
--ifm-link-color: #d8d2b5;
20+
--ifm-color-primary: #fcf9e8;
2021
--ifm-navbar-shadow: none;
2122
--ifm-color-secondary: white;
2223
--ifm-footer-background-color: black;
@@ -25,7 +26,7 @@
2526
--ifm-font-color-base-inverse: black;
2627
--ifm-background-color: black;
2728
--ifm-background-surface-color: black;
28-
--ifm-navbar-link-hover-color: rgba(0, 0, 0, .90);
29+
--ifm-navbar-link-hover-color: rgba(0, 0, 0, 0.9);
2930
}
3031

3132
.docusaurus-highlight-code-line {
@@ -48,6 +49,6 @@ html[data-theme='dark'] .docusaurus-highlight-code-line {
4849
}
4950

5051
nav.navbar {
51-
background-color: #FCF9E8;
52+
background-color: #fcf9e8;
5253
color: black;
5354
}

0 commit comments

Comments
 (0)