Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Commit edb978c

Browse files
committed
feat: add example with nuxtjs
1 parent 80a3e0c commit edb978c

File tree

13 files changed

+603
-0
lines changed

13 files changed

+603
-0
lines changed

examples/browser-nuxtjs/.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false

examples/browser-nuxtjs/.gitignore

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Created by .ignore support plugin (hsz.mobi)
2+
### Node template
3+
# Logs
4+
/logs
5+
*.log
6+
npm-debug.log*
7+
yarn-debug.log*
8+
yarn-error.log*
9+
10+
# Runtime data
11+
pids
12+
*.pid
13+
*.seed
14+
*.pid.lock
15+
16+
# Directory for instrumented libs generated by jscoverage/JSCover
17+
lib-cov
18+
19+
# Coverage directory used by tools like istanbul
20+
coverage
21+
22+
# nyc test coverage
23+
.nyc_output
24+
25+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
26+
.grunt
27+
28+
# Bower dependency directory (https://bower.io/)
29+
bower_components
30+
31+
# node-waf configuration
32+
.lock-wscript
33+
34+
# Compiled binary addons (https://nodejs.org/api/addons.html)
35+
build/Release
36+
37+
# Dependency directories
38+
node_modules/
39+
jspm_packages/
40+
41+
# TypeScript v1 declaration files
42+
typings/
43+
44+
# Optional npm cache directory
45+
.npm
46+
47+
# Optional eslint cache
48+
.eslintcache
49+
50+
# Optional REPL history
51+
.node_repl_history
52+
53+
# Output of 'npm pack'
54+
*.tgz
55+
56+
# Yarn Integrity file
57+
.yarn-integrity
58+
59+
# dotenv environment variables file
60+
.env
61+
62+
# parcel-bundler cache (https://parceljs.org/)
63+
.cache
64+
65+
# next.js build output
66+
.next
67+
68+
# nuxt.js build output
69+
.nuxt
70+
71+
# Nuxt generate
72+
dist
73+
74+
# vuepress build output
75+
.vuepress/dist
76+
77+
# Serverless directories
78+
.serverless
79+
80+
# IDE / Editor
81+
.idea
82+
83+
# Service worker
84+
sw.*
85+
86+
# macOS
87+
.DS_Store
88+
89+
# Vim swap files
90+
*.swp

examples/browser-nuxtjs/README.md

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
<p align="center">
2+
<a href="https://js.ipfs.io" title="JS IPFS">
3+
<img src="https://ipfs.io/ipfs/Qme6KJdKcp85TYbLxuLV7oQzMiLremD7HMoXLZEmgo6Rnh/js-ipfs-sticker.png" alt="IPFS in JavaScript logo" width="244" />
4+
</a>
5+
</p>
6+
7+
<h3 align="center"><b>IPFS Nuxt App</b></h3>
8+
9+
<p align="center">
10+
<b><i>Using js-ipfs in a nuxtjs project</i></b>
11+
<br />
12+
<br />
13+
<img src="https://raw.githubusercontent.com/jlord/forkngo/gh-pages/badges/cobalt.png" width="200">
14+
<br>
15+
<a href="https://github.com/ipfs/js-ipfs/tree/master/docs">Explore the docs</a>
16+
·
17+
<a href="https://codesandbox.io/">View Demo</a>
18+
·
19+
<a href="https://github.com/ipfs-examples/js-ipfs-examples/issues">Report Bug</a>
20+
·
21+
<a href="https://github.com/ipfs-examples/js-ipfs-examples/issues">Request Feature/Example</a>
22+
</p>
23+
24+
## Table of Contents
25+
26+
- [Table of Contents](#table-of-contents)
27+
- [About The Project](#about-the-project)
28+
- [Getting Started](#getting-started)
29+
- [Pre requisites](#pre-requisites)
30+
- [Installation and Running example](#installation-and-running-example)
31+
- [Available Scripts](#available-scripts)
32+
- [Compiles and hot-reloads for development](#compiles-and-hot-reloads-for-development)
33+
- [Compiles and minifies for production](#compiles-and-minifies-for-production)
34+
- [Generate static project](#generate-static-project)
35+
- [Customize configuration](#customize-configuration)
36+
- [Usage](#usage)
37+
- [`assets`](#assets)
38+
- [`components`](#components)
39+
- [`layouts`](#layouts)
40+
- [`pages`](#pages)
41+
- [`plugins`](#plugins)
42+
- [`static`](#static)
43+
- [`store`](#store)
44+
- [Documentation](#documentation)
45+
- [Contributing](#contributing)
46+
- [Want to hack on IPFS?](#want-to-hack-on-ipfs)
47+
48+
## About The Project
49+
50+
- Read the [docs](https://github.com/ipfs/js-ipfs/tree/master/docs)
51+
- Look into other [examples](https://github.com/ipfs/js-ipfs/tree/master/examples) to learn how to spawn an IPFS node in Node.js and in the Browser
52+
- Consult the [Core API docs](https://github.com/ipfs/js-ipfs/tree/master/docs/core-api) to see what you can do with an IPFS node
53+
- Visit https://dweb-primer.ipfs.io to learn about IPFS and the concepts that underpin it
54+
- Head over to https://proto.school to take interactive tutorials that cover core IPFS APIs
55+
- Check out https://docs.ipfs.io for tips, how-tos and more
56+
- See https://blog.ipfs.io for news and more
57+
- Need help? Please ask 'How do I?' questions on https://discuss.ipfs.io
58+
59+
## Getting Started
60+
61+
### Pre requisites
62+
63+
Make sure you have installed all of the following prerequisites on your development machine:
64+
65+
- Git - [Download & Install Git](https://git-scm.com/downloads). OSX and Linux machines typically have this already installed.
66+
- Node.js - [Download & Install Node.js](https://nodejs.org/en/download/) and the npm package manager.
67+
68+
### Installation and Running example
69+
70+
```console
71+
> npm install
72+
> npm start
73+
```
74+
75+
Now open your browser at `http://localhost:8081`
76+
77+
### Available Scripts
78+
79+
In the project directory, you can run:
80+
81+
#### Compiles and hot-reloads for development
82+
83+
```console
84+
$ npm run dev
85+
```
86+
87+
#### Compiles and minifies for production
88+
89+
```console
90+
$ npm run build
91+
$ npm run start
92+
```
93+
94+
#### Generate static project
95+
96+
```console
97+
$ npm run generate
98+
```
99+
100+
#### Customize configuration
101+
102+
For detailed explanation on how things work, check out the [documentation](https://nuxtjs.org).
103+
104+
## Usage
105+
106+
A minimal demonstration of how to use `js-ipfs` with `Nuxt`.
107+
108+
You can create the following extra directories, some of which have special behaviors. Only `pages` is required; you can delete them if you don't want to use their functionality.
109+
110+
### `assets`
111+
112+
The assets directory contains your uncompiled assets such as Stylus or Sass files, images, or fonts.
113+
114+
More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/assets).
115+
116+
### `components`
117+
118+
The components directory contains your Vue.js components. Components make up the different parts of your page and can be reused and imported into your pages, layouts and even other components.
119+
120+
More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/components).
121+
122+
### `layouts`
123+
124+
Layouts are a great help when you want to change the look and feel of your Nuxt app, whether you want to include a sidebar or have distinct layouts for mobile and desktop.
125+
126+
More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/layouts).
127+
128+
### `pages`
129+
130+
This directory contains your application views and routes. Nuxt will read all the `*.vue` files inside this directory and setup Vue Router automatically.
131+
132+
More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/get-started/routing).
133+
134+
### `plugins`
135+
136+
The plugins directory contains JavaScript plugins that you want to run before instantiating the root Vue.js Application. This is the place to add Vue plugins and to inject functions or constants. Every time you need to use `Vue.use()`, you should create a file in `plugins/` and add its path to plugins in `nuxt.config.js`.
137+
138+
More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/plugins).
139+
140+
### `static`
141+
142+
This directory contains your static files. Each file inside this directory is mapped to `/`.
143+
144+
Example: `/static/robots.txt` is mapped as `/robots.txt`.
145+
146+
More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/static).
147+
148+
### `store`
149+
150+
This directory contains your Vuex store files. Creating a file in this directory automatically activates Vuex.
151+
152+
More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/store).
153+
154+
This project was bootstrapped with [create-nuxt-app](https://nuxtjs.org/docs/2.x/get-started/installation).
155+
156+
_For more examples, please refer to the [Documentation](#documentation)_
157+
158+
## Documentation
159+
160+
- [Config](https://docs.ipfs.io/)
161+
- [Core API](https://github.com/ipfs/js-ipfs/tree/master/docs/core-api)
162+
- [Examples](https://github.com/ipfs/js-ipfs/tree/master/examples)
163+
- [Development](https://github.com/ipfs/js-ipfs/blob/master/docs/DEVELOPMENT.md)
164+
165+
## Contributing
166+
167+
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**.
168+
169+
1. Fork the IPFS Project
170+
2. Create your Feature Branch (`git checkout -b feature/amazing-feature`)
171+
3. Commit your Changes (`git commit -a -m 'feat: add some amazing feature'`)
172+
4. Push to the Branch (`git push origin feature/amazing-feature`)
173+
5. Open a Pull Request
174+
175+
## Want to hack on IPFS?
176+
177+
[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md)
178+
179+
The IPFS implementation in JavaScript needs your help! There are a few things you can do right now to help out:
180+
181+
Read the [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md) and [JavaScript Contributing Guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md).
182+
183+
- **Check out existing issues** The [issue list](https://github.com/ipfs/js-ipfs/issues) has many that are marked as ['help wanted'](https://github.com/ipfs/js-ipfs/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22help+wanted%22) or ['difficulty:easy'](https://github.com/ipfs/js-ipfs/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3Adifficulty%3Aeasy) which make great starting points for development, many of which can be tackled with no prior IPFS knowledge
184+
- **Look at the [IPFS Roadmap](https://github.com/ipfs/roadmap)** This are the high priority items being worked on right now
185+
- **Perform code reviews** More eyes will help
186+
a. speed the project along
187+
b. ensure quality, and
188+
c. reduce possible future bugs.
189+
- **Add tests**. There can never be enough tests.
190+
- **Join the [Weekly Core Implementations Call](https://github.com/ipfs/team-mgmt/issues/992)** it's where everyone discusses what's going on with IPFS and what's next
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<template>
2+
<main class="mt-8 bg-white overflow-hidden shadow sm:rounded-lg p-6">
3+
<h3 class="text-2xl leading-7 font-semibold">{{ status }}</h3>
4+
<div id="ipfs-info" v-if="online" class="mt-3 text-gray-600">
5+
<p>
6+
ID: <span id="ipfs-info-id">{{ id }}</span>
7+
</p>
8+
<p>
9+
Agent version: <span id="ipfs-info-agent">{{ agentVersion }}</span>
10+
</p>
11+
</div>
12+
</main>
13+
</template>
14+
15+
<script>
16+
export default {
17+
name: "IpfsInfo",
18+
data: function() {
19+
return {
20+
status: "Connecting to IPFS...",
21+
id: "",
22+
agentVersion: "",
23+
online: false
24+
};
25+
},
26+
mounted: function() {
27+
this.getIpfsNodeInfo();
28+
},
29+
methods: {
30+
async getIpfsNodeInfo() {
31+
try {
32+
// Await for ipfs node instance.
33+
const ipfs = await this.$ipfs;
34+
// Call ipfs `id` method.
35+
// Returns the identity of the Peer.
36+
const { agentVersion, id } = await ipfs.id();
37+
this.agentVersion = agentVersion;
38+
this.id = id;
39+
// Set successful status text.
40+
this.status = "Connected to IPFS";
41+
this.online = ipfs.isOnline;
42+
} catch (err) {
43+
// Set error status text.
44+
this.status = `Error: ${err}`;
45+
}
46+
}
47+
}
48+
};
49+
</script>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<template>
2+
<svg class="nuxt-logo" viewBox="0 0 45 30" fill="none" xmlns="http://www.w3.org/2000/svg">
3+
<path d="M24.7203 29.704H41.1008C41.6211 29.7041 42.1322 29.5669 42.5828 29.3061C43.0334 29.0454 43.4075 28.6704 43.6675 28.2188C43.9275 27.7672 44.0643 27.2549 44.0641 26.7335C44.0639 26.2121 43.9266 25.6999 43.6662 25.2485L32.6655 6.15312C32.4055 5.70162 32.0315 5.32667 31.581 5.06598C31.1305 4.8053 30.6195 4.66805 30.0994 4.66805C29.5792 4.66805 29.0682 4.8053 28.6177 5.06598C28.1672 5.32667 27.7932 5.70162 27.5332 6.15312L24.7203 11.039L19.2208 1.48485C18.9606 1.03338 18.5864 0.658493 18.1358 0.397853C17.6852 0.137213 17.1741 0 16.6538 0C16.1336 0 15.6225 0.137213 15.1719 0.397853C14.7213 0.658493 14.3471 1.03338 14.0868 1.48485L0.397874 25.2485C0.137452 25.6999 0.000226653 26.2121 2.8053e-07 26.7335C-0.000226092 27.2549 0.136554 27.7672 0.396584 28.2188C0.656614 28.6704 1.03072 29.0454 1.48129 29.3061C1.93185 29.5669 2.44298 29.7041 2.96326 29.704H13.2456C17.3195 29.704 20.3239 27.9106 22.3912 24.4118L27.4102 15.7008L30.0986 11.039L38.1667 25.0422H27.4102L24.7203 29.704ZM13.0779 25.0374L5.9022 25.0358L16.6586 6.36589L22.0257 15.7008L18.4322 21.9401C17.0593 24.2103 15.4996 25.0374 13.0779 25.0374Z" fill="#00DC82" />
4+
</svg>
5+
</template>
6+
7+
<style>
8+
.nuxt-logo {
9+
height: 180px;
10+
}
11+
</style>

0 commit comments

Comments
 (0)