Skip to content

Commit fa4e7bd

Browse files
Fixes tab switching issue.
1 parent fbb8e45 commit fa4e7bd

File tree

3 files changed

+32
-34
lines changed

3 files changed

+32
-34
lines changed

docs/.vuepress/config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ module.exports = {
2424
md.use(require('markdown-it-footnote'))
2525
md.use(require('markdown-it-task-lists'))
2626
md.use(require('markdown-it-deflist')),
27-
md.use(require('markdown-it-imsize')),
28-
md.use(require('markdown-it-image-lazy-loading'))
27+
md.use(require('markdown-it-imsize')),
28+
md.use(require('markdown-it-image-lazy-loading'))
2929
}
3030
},
3131
themeConfig: {

docs/.vuepress/theme/styles/index.styl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,12 @@ code {
7676
--code-bg-color: $codeBgColor;
7777
--highlight-color: $highlightColor;
7878
}
79+
80+
section.tabs-component-panel::before {
81+
content: '';
82+
display: block;
83+
position: relative;
84+
width: 0;
85+
height: 10em;
86+
margin-top: -10em;
87+
}

docs/basics/js/js-ipfs.md

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,23 @@
11
---
22
title: IPFS in JavaScript
3-
description: "A simple walkthrough of how to perform basic IPFS operations using the JS implementation."
3+
description: "A simple walkthrough of how to perform basic IPFS operations using the JavaScript implementation."
44
---
55

6-
# JS-IPFS Basics
6+
# IPFS in JavaScript
77

8-
This guide aims to walk you through the basics of using IPFS with JavaScript. JS-IPFS is one of multiple [IPFS implementations](../ipfs-implementations.md).
9-
10-
You will learn how install and spawn a node using the available libraries, as well as add, retrieve,
11-
read, and remove files. If you are unsure about the meaning of some terms, check out the [glossary](../concepts/glossary.md).
8+
This guide aims to walk you through the basics of using IPFS with JavaScript. JS-IPFS is one of multiple [IPFS implementations](../ipfs-implementations.md). You will learn how install and spawn a node using the available libraries, as well as add, retrieve, read, and remove files. If you are unsure about the meaning of some terms, check out the [glossary](../concepts/glossary.md).
129

1310
::: tip Environment
1411

1512
All instructions and examples shown here were performed and tested on an M1 Mac. However, the IPFS commands are the same on Linux, macOS, and Windows. You will need to know how to navigate your computer's directories from within the CLI. If you're unsure how to use the CLI, we recommend learning how before continuing with this guide.
1613

1714
:::
1815

19-
There are two main JavaScript libraries for working with IPFS, learn about each library in the [reference section](../reference/js/api).
20-
2116
## Install JS-IPFS
2217

2318
:::: tabs
2419

25-
::: tab ipfs-cli
20+
::: tab ipfs-cli id="install-ipfs-cli"
2621

2722
### JS-IPFS module
2823

@@ -38,7 +33,7 @@ To build from source, clone the [source packages](https://github.com/ipfs/js-ipf
3833

3934
:::
4035

41-
::: tab ipfs-core
36+
::: tab ipfs-core id="install-ipfs-core"
4237

4338
### IPFS core API
4439

@@ -60,7 +55,7 @@ To build from source, clone the [source packages](https://github.com/ipfs/js-ipf
6055

6156
:::: tabs
6257

63-
::: tab ipfs-cli
58+
::: tab ipfs-cli id="spawn-ipfs-cli"
6459

6560
To spawn a node using the CLI, simply start the daemon:
6661

@@ -99,7 +94,7 @@ jsipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "POST
9994

10095
:::
10196

102-
::: tab ipfs-core
97+
::: tab ipfs-core id="spawn-ipfs-core"
10398

10499
Create a simple Node.js application to host the logic that will allow you to use the RPC API. You'll also use this Node.js application later on to add and remove files.
105100

@@ -143,7 +138,7 @@ To create an IPFS node, add:
143138
main();
144139
```
145140

146-
This imports IPFS as a dependency and uses the `create()` function to create a node instance.
141+
This imports IPFS as a dependency and uses the `create()` function to create a node instance.
147142

148143
To spawn the node, run the application:
149144

@@ -169,7 +164,7 @@ The JS-IPFS implementation is split into several Node.js modules. The following
169164

170165
:::: tabs
171166

172-
::: tab ipfs-http-client
167+
::: tab ipfs-http-client id="connect-ipfs-http-client"
173168

174169
If you have not already installed the client library, add the `ipfs-http-client` module to your project:
175170

@@ -185,13 +180,13 @@ Populate your `index.js` file with the following to create an instance of the HT
185180
const client = create() // the default API address http://localhost:5001
186181
```
187182

188-
This imports the client library and uses the `create()` function to connect to an IPFS API server.
183+
This imports the client library and uses the `create()` function to connect to an IPFS API server.
189184

190185
To connect to the API, run the application:
191186

192187
:::
193188

194-
::: tab ipfs-client
189+
::: tab ipfs-client id="connect-ipfs-client"
195190

196191
If you have not already installed the client library, add the `ipfs-http-client` module to your project:
197192

@@ -222,15 +217,13 @@ Now you can start to add files using JS-IPFS to the IPFS network.
222217

223218
::: warning Section changes coming soon
224219

225-
As the JS-IPFS implementation goes through changes, the steps to add a
226-
file are likely to change. Please reference the
227-
[source packages](https://github.com/ipfs/js-ipfs) for the latest updates.
220+
As the JS-IPFS implementation goes through changes, the steps to add a file are likely to change. Please reference the [source packages](https://github.com/ipfs/js-ipfs) for the latest updates.
228221

229222
:::
230223

231224
:::: tabs
232225

233-
::: tab ipfs-cli
226+
::: tab ipfs-cli id="add-ipfs-cli"
234227

235228
In a new session, navigate to the directory you wish to add a file from. You can also specify the file path when using the cli to add a file.
236229

@@ -256,14 +249,11 @@ To view the file contents, navigate to the [webui](http://127.0.0.1:5002/webui)
256249

257250
:::
258251

259-
::: tab ipfs-core
252+
::: tab ipfs-core id="add-ipfs-core"
260253

261-
To add a file using `ipfs-core`, you can create a test `.txt` file in
262-
your project directory or point to a local file on your machine that you would
263-
like to upload to IPFS.
254+
To add a file using `ipfs-core`, you can create a test `.txt` file in your project directory or point to a local file on your machine that you would like to upload to IPFS.
264255

265-
Then, using `node.add`, add an `await` operator that includes a `path`
266-
and `content` field and an output message in the project's `index.js` file:
256+
Then, using `node.add`, add an `await` operator that includes a `path` and `content` field and an output message in the project's `index.js` file:
267257

268258
```js{6-9,11}
269259
import * as IPFS from 'ipfs-core';
@@ -288,11 +278,10 @@ You should obtain an output similar to:
288278
Added file: test.txt CID(QmYt9ypyGsR1BKdaCGPdwdBgAiuXK5AYN2bGSNZov7YXuk)
289279
```
290280

291-
The file has been added to the IPFS network and has given the file a CID.
292-
You can share this CID with anyone, and they can use it on their IPFS node to obtain
293-
the content you uploaded.
281+
The file has been added to the IPFS network and has given the file a CID. You can share this CID with anyone, and they can use it on their IPFS node to obtain the content you uploaded.
294282

295283
If you take the CID and load it on the HTTP gateway, you will see the content:
284+
296285
> e.g. https://ipfs.io/ipfs/QmYt9ypyGsR1BKdaCGPdwdBgAiuXK5AYN2bGSNZov7YXuk
297286
298287
<img src="../../images/jsipfs-add-gateway.png" width="1000">
@@ -305,7 +294,7 @@ If you take the CID and load it on the HTTP gateway, you will see the content:
305294

306295
::::tabs
307296

308-
::: tab ipfs-cli
297+
::: tab ipfs-cli id="retrieve-ipfs-cli"
309298

310299
Navigate to the directory where you wish to save the folder. IPFS will save the folder to whichever directory you are in. Here, we're going to save the file in the ~/Desktop directory:
311300

@@ -329,7 +318,7 @@ You will notice a new file in your project directory that is labelled as the CID
329318

330319
:::
331320

332-
::: tab ipfs-core
321+
::: tab ipfs-core id="retrieve-ipfs-core"
333322

334323
Continuing with the same Node.js application, retrieving a file from IPFS can be done by using
335324
a `cat` call. We will use the CID from the previous section when we added the `test.txt` file by passing `fileAdded.cid` as an argument to `node.cat`:
@@ -397,7 +386,7 @@ Removing the content pin will remove a file from IPFS. In this section, we will
397386

398387
:::: tabs
399388

400-
::: tab ipfs-cli
389+
::: tab ipfs-cli id="remove-ipfs-cli"
401390

402391
If you would like to remove a different piece of content, you can run `jsipfs pin ls` to view a list of pinned content on the local IPFS node:
403392

0 commit comments

Comments
 (0)