From 2878d0b64d53b1d0db87e9208a8c73aadfb80e17 Mon Sep 17 00:00:00 2001 From: Vasily Kuzin Date: Sun, 7 Aug 2022 17:25:58 +0300 Subject: [PATCH 1/2] Add data-fetching snippets #6 - nfetch - nfetch-lazy - nasyncdata - nasyncdata-lazy --- package.json | 8 ++++++++ snippets/nuxt-script.code-snippets | 30 ++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 snippets/nuxt-script.code-snippets 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..fd0f10e --- /dev/null +++ b/snippets/nuxt-script.code-snippets @@ -0,0 +1,30 @@ +{ + "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" + }, +} From 7c4783e56c21d8350253e508750c85f424ed3703 Mon Sep 17 00:00:00 2001 From: Vasily Kuzin Date: Sun, 7 Aug 2022 17:57:19 +0300 Subject: [PATCH 2/2] Add head-management snippets #6 - nhead - nhead-description - nhead-template - npagemeta - npagemeta-description --- snippets/nuxt-script.code-snippets | 57 ++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/snippets/nuxt-script.code-snippets b/snippets/nuxt-script.code-snippets index fd0f10e..38388ff 100644 --- a/snippets/nuxt-script.code-snippets +++ b/snippets/nuxt-script.code-snippets @@ -16,15 +16,68 @@ "Nuxt useAsyncData": { "prefix": "nasyncdata", "body": [ - "const { data: ${1:name} } = await useAsyncData('${2:requestKey}', () => $fetch('${3:path}'))" + "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}'))" + "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" + }, }