Skip to content

Commit dbc25ed

Browse files
authored
Merge pull request #66 from DominusKelvin/nuxt-script
Added nuxt script snippets
2 parents ce182cb + 32133a5 commit dbc25ed

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,14 @@ You can enable tab completion (recommended) by opening `Code > Preferences > Set
135135
| `nfont` | link to include fonts in a nuxt project, in nuxt-config |
136136
| `ncss` | link to css assets such as normalize |
137137

138+
### Nuxt Page
139+
140+
| Snippet | Purpose |
141+
| ------- | ------------------------------------------------------- |
142+
| `nasyncdata` | Nuxt asyncData |
143+
| `nfetch` | Nuxt Fetch |
144+
| `nhead` | Nuxt Head |
145+
138146
### Extra (plaintext)
139147

140148
| Snippet | Purpose |

package.json

+8
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@
6161
"language": "javascript",
6262
"path": "./snippets/nuxt-config.json"
6363
},
64+
{
65+
"language": "javascript",
66+
"path": "./snippets/nuxt-script.json"
67+
},
6468
{
6569
"language": "typescript",
6670
"path": "./snippets/vue-script.json"
@@ -77,6 +81,10 @@
7781
"language": "typescript",
7882
"path": "./snippets/nuxt-config.json"
7983
},
84+
{
85+
"language": "typescript",
86+
"path": "./snippets/nuxt-script.json"
87+
},
8088
{
8189
"language": "plaintext",
8290
"path": "./snippets/plaintext.json"

snippets/nuxt-script.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"Nuxt Async": {
3+
"prefix": "nasyncdata",
4+
"body": ["async asyncData ({ ${1:params} }) {", "\tconst { data } = await fetch(`${2:endpoint}`).then(res => res.json())", "\treturn { ${3:key}:${4:value} }", "},"],
5+
"description": "Nuxt asyncData"
6+
},
7+
"Nuxt Fetch": {
8+
"prefix": "nfetch",
9+
"body": ["async fetch ({ store, ${1:params} }) {", "\tlet { data } = await fetch('${2:endpoint}').then(res => res.json())", "\tstore.commit('${3:MUTATION_TYPE}', data)", "},"],
10+
"description": "Nuxt Fetch"
11+
},
12+
"Nuxt Head": {
13+
"prefix": "nhead",
14+
"body": ["head () {", "\treturn {", "\t\ttitle: ${1:'Page Title'},", "\t\tmeta: [", "\t\t\t// hid is used as unique identifier. Do not use `vmid` for it as it will not work","\t\t\t{ hid: 'description', name: 'description', content: ${2:'My custom description'} }", "\t\t]", "\t}", "},"],
15+
"description": "Nuxt Head"
16+
}
17+
}

0 commit comments

Comments
 (0)