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

Commit d0f8751

Browse files
committedOct 14, 2021
nuxtjs integration
1 parent a55f0e2 commit d0f8751

25 files changed

+33725
-0
lines changed
 

‎nuxtjs/.editorconfig

+13
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

‎nuxtjs/.gitignore

+90
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

‎nuxtjs/README.md

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# nuxtjs
2+
3+
## Build Setup
4+
5+
```bash
6+
# install dependencies
7+
$ npm install
8+
9+
# serve with hot reload at localhost:3000
10+
$ npm run dev
11+
12+
# build for production and launch server
13+
$ npm run build
14+
$ npm run start
15+
16+
# generate static project
17+
$ npm run generate
18+
```
19+
20+
For detailed explanation on how things work, check out the [documentation](https://nuxtjs.org).
21+
22+
## Special Directories
23+
24+
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.
25+
26+
### `assets`
27+
28+
The assets directory contains your uncompiled assets such as Stylus or Sass files, images, or fonts.
29+
30+
More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/assets).
31+
32+
### `components`
33+
34+
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.
35+
36+
More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/components).
37+
38+
### `layouts`
39+
40+
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.
41+
42+
More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/layouts).
43+
44+
45+
### `pages`
46+
47+
This directory contains your application views and routes. Nuxt will read all the `*.vue` files inside this directory and setup Vue Router automatically.
48+
49+
More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/get-started/routing).
50+
51+
### `plugins`
52+
53+
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`.
54+
55+
More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/plugins).
56+
57+
### `static`
58+
59+
This directory contains your static files. Each file inside this directory is mapped to `/`.
60+
61+
Example: `/static/robots.txt` is mapped as `/robots.txt`.
62+
63+
More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/static).
64+
65+
### `store`
66+
67+
This directory contains your Vuex store files. Creating a file in this directory automatically activates Vuex.
68+
69+
More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/store).

‎nuxtjs/article.md

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# Nuxt.js
2+
3+
## Prerequisites
4+
5+
1. A Directus instance (link to Directus setup guide)
6+
2. Node.js
7+
3. Database
8+
9+
## Getting started
10+
11+
1. Create a Directus instance by running:
12+
13+
```
14+
npm init directus-project directus-demo
15+
```
16+
17+
2. Apply the provided schema snapshot, `demo.yaml` by running:
18+
19+
```
20+
npx directus schema apply ./demo.yaml
21+
```
22+
> Learn more about schema snapshot/apply [over here](https://docs.directus.io/reference/command-line-interface/#migrate-schema-to-a-different-environment)
23+
24+
3. Move the provided custom migration file, `20211014-add-demo-data.js` into the `extensions/migrations` directory in our Directus project:
25+
26+
```
27+
.
28+
├── extensions
29+
│ └── migrations
30+
│ └── 20211014-add-demo-data.js <- place the file here
31+
└── package.json
32+
```
33+
34+
We should see the following output in the terminal:
35+
36+
```
37+
✨ Running migrations...
38+
✨ Applying Add Demo Data...
39+
✨ Done
40+
```
41+
42+
4. Apply the custom migration by running:
43+
```
44+
npx directus database migrate:*
45+
```
46+
> Learn more about custom migrations [over here](https://docs.directus.io/guides/migrations/#custom-migrations)
47+
48+
## Adding Directus module to your Nuxt project
49+
50+
> If you don't have a Nuxt project ready yet, check out the official docs on setting up and running a Nuxt project: https://nuxtjs.org/docs/get-started/installation/
51+
52+
The Directus module exposes the Directus SDK in the [Nuxt Context](https://nuxtjs.org/docs/internals-glossary/context/) so that we may access it via `$directus` (`asyncData`, `middleware`,`plugins`) or `this.$directus` in Nuxt `fetch()` methods.
53+
54+
1. Install the `@directus/nuxt` module by running:
55+
56+
```
57+
npm install @directus/nuxt
58+
```
59+
60+
2. Add it into the `modules` section in our `nuxt.config.js` file:
61+
62+
```js
63+
export default {
64+
modules: ['@directus/nuxt']
65+
}
66+
```
67+
68+
3. Configure our Directus module in our `nuxt.config.js` with the following:
69+
70+
- `url`: The URL of your Directus instance
71+
72+
For authentication, you can either use credentials:
73+
74+
- `options.email`: user email
75+
- `options.password`: user password
76+
77+
Or a static token:
78+
79+
- `options.static`: the static token
80+
81+
> How to get a static token? Check out: https://docs.directus.io/reference/api/authentication/#static-token
82+
83+
Here's an example of how it would look like:
84+
85+
```js
86+
export default {
87+
modules: ['@directus/nuxt'],
88+
directus: {
89+
url: 'http://localhost:8055',
90+
options: {
91+
static: 'superadminsecrettoken',
92+
// email: 'superadmin@example.com',
93+
// password: 'password',
94+
}
95+
}
96+
}
97+
```
98+
99+
(may have to modify this to use [privateRuntimeConfig](https://nuxtjs.org/docs/directory-structure/nuxt-config#privateruntimeconfig))
100+
101+
## Creating the main page
102+
103+
Here we will display a list of posts available in our `Posts` collection in Directus.
104+
105+
Since the author detail is a nested relationship of `Posts`, we can retrieve the nested author properties by specifying `author.<nested property here>` under `fields` within our query:
106+
107+
```js
108+
fields: ["*", "author.avatar", "author.first_name", "author.last_name"],
109+
```
110+
111+
and we will show the posts in descending order. We can use the `sort` option in our query:
112+
113+
```js
114+
sort: '-date_created'
115+
```
116+
117+
Note that there is a minus sign prepend to the `date_created` column to indicate the result should be in descending order.

‎nuxtjs/assets/css/fonts.css

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@font-face {
2+
font-family: 'Inter';
3+
font-style: normal;
4+
font-weight: 100 900;
5+
font-display: block;
6+
src: url(~assets/fonts/inter-var-latin.woff2) format('woff2');
7+
unicode-range: U+00??, U+0131, U+0152-0153, U+02bb-02bc, U+02c6, U+02da,
8+
U+02dc, U+2000-206f, U+2074, U+20ac, U+2122, U+2191, U+2193, U+2212, U+2215,
9+
U+feff, U+fffd;
10+
}
35.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)
This repository has been archived.