diff --git a/package.json b/package.json index 4e1873a..d891eff 100644 --- a/package.json +++ b/package.json @@ -57,6 +57,14 @@ { "language": "html", "path": "./snippets/nuxt-template.code-snippets" + }, + { + "language": "javascript", + "path": "./snippets/nuxt-script.code-snippets" + }, + { + "language": "typescript", + "path": "./snippets/nuxt-script.code-snippets" } ] } diff --git a/snippets/nuxt-script.code-snippets b/snippets/nuxt-script.code-snippets new file mode 100644 index 0000000..38388ff --- /dev/null +++ b/snippets/nuxt-script.code-snippets @@ -0,0 +1,83 @@ +{ + "Nuxt useFetch": { + "prefix": "nfetch", + "body": [ + "const { data: ${1:name} } = await useFetch('${2:path}')" + ], + "description": "Nuxt useFetch composable" + }, + "Nuxt useLazyFetch": { + "prefix": "nfetch-lazy", + "body": [ + "const { pending, data: ${1:name} } = await useLazyFetch('${2:path}')" + ], + "description": "Nuxt useLazyFetch composable" + }, + "Nuxt useAsyncData": { + "prefix": "nasyncdata", + "body": [ + "const { data: ${1:name} } = await useAsyncData('${2:requestKey}', () => \\$fetch('${3:path}'))" + ], + "description": "Nuxt useAsyncData composable" + }, + "Nuxt useLazyAsyncData": { + "prefix": "nasyncdata-lazy", + "body": [ + "const { pending, data: ${1:name} } = await useLazyAsyncData('${2:requestKey}', () => \\$fetch('${3:path}'))" + ], + "description": "Nuxt useLazyAsyncData composable" + }, + "Nuxt useHead": { + "prefix": "nhead", + "body": [ + "useHead({", + "\ttitle: ${1:pageTitle},", + "})" + ], + "description": "Nuxt useHead composable" + }, + "Nuxt useHead with description": { + "prefix": "nhead-description", + "body": [ + "useHead({", + "\ttitle: ${1:pageTitle},", + "\tmeta: [", + "\t\t{ name: 'description', content: ${2:pageDescription} },", + "\t],", + "})" + ], + "description": "Nuxt useHead composable with description" + }, + "Nuxt useHead - Title template": { + "prefix": "nhead-template", + "body": [ + "useHead({", + "\ttitleTemplate: (titleChunk) => {", + "\t\treturn titleChunk ? `\\${titleChunk} - ${1:siteTitle}` : '${1:siteTitle}'", + "\t}", + "})" + ], + "description": "Nuxt useHead composable with title template" + }, + "Nuxt definePageMeta": { + "prefix": "npagemeta", + "body": [ + "definePageMeta({", + "\ttitle: '${1:pageTitle}',", + "})" + ], + "description": "Nuxt definePageMeta composable" + }, + "Nuxt definePageMeta with description": { + "prefix": "npagemeta-description", + "body": [ + "definePageMeta({", + "\ttitle: '${1:pageTitle}',", + "\tmeta: [", + "\t\t{ name: 'description', content: '${2:pageDescription}' },", + "\t],", + "})" + ], + "description": "Nuxt definePageMeta composable with description" + }, +}