Skip to content

Commit

Permalink
Merge pull request #920 from storyblok/feature/auto-import-storyblok-…
Browse files Browse the repository at this point in the history
…vue-types

feat: hoist storyblok/vue types
  • Loading branch information
alvarosabu authored Nov 4, 2024
2 parents 5077ad4 + 7ad0cd7 commit 946e846
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"scripts": {
"prepack": "nuxt-module-build build",
"build": "nuxt-module-build build",
"build": "nuxt-module-build prepare && nuxt-module-build build",
"dev": "nuxi dev playground",
"dev:build": "nuxi build playground",
"dev:preview": "nuxi preview playground",
Expand Down
12 changes: 12 additions & 0 deletions playground/pages/index.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<script setup lang="ts">
import type { SbBlokData } from "@storyblok/vue";
// const storyblokApi = useStoryblokApi();
// // Checking custom Flush method
// storyblokApi.flushCache();
Expand All @@ -9,6 +11,16 @@ const story = await useAsyncStoryblok("vue", {
resolve_relations: "popular-articles.articles"
});
const penguin = await useStoryblok("vue", {
version: "draft",
language: "en",
resolve_relations: "popular-articles.articles"
});
const awiwi = ref<SbBlokData>({});
renderRichText(story.value.content.richText);
/* const richText = computed(() => renderRichText(story.value.content.richText)); */
</script>

Expand Down
2 changes: 1 addition & 1 deletion playground/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
// https://nuxt.com/docs/guide/concepts/typescript
"extends": "./.nuxt/tsconfig.json"
"extends": "./.nuxt/tsconfig.json",
}
5 changes: 4 additions & 1 deletion src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
createResolver
} from "@nuxt/kit";
import type { NuxtHookName } from "@nuxt/schema";
import type { Nuxt } from "nuxt/schema";

export interface ModuleOptions {
accessToken: string,
Expand All @@ -32,7 +33,7 @@ export default defineNuxtModule<ModuleOptions>({
componentsDir: '~/storyblok',
apiOptions: {},
},
setup(options, nuxt) {
setup(options: ModuleOptions, nuxt: Nuxt) {
const resolver = createResolver(import.meta.url);

if(nuxt.options.vite.optimizeDeps) {
Expand Down Expand Up @@ -72,6 +73,8 @@ export default defineNuxtModule<ModuleOptions>({
for (const name of names) {
addImports({ name, as: name, from: "@storyblok/vue" });
}

nuxt.options.typescript.hoist.push("@storyblok/vue")
addImportsDir(resolver.resolve("./runtime/composables"));

if (options.devtools) {
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "./playground/.nuxt/tsconfig.json"
"extends": "./.nuxt/tsconfig.json"
}

0 comments on commit 946e846

Please sign in to comment.