Skip to content

Commit

Permalink
feat: add web-types.json for WebStorm (#1288)
Browse files Browse the repository at this point in the history
* docs(JSDoc): define component slots

* fix(dx): add web-types.json for better code insight in WebStorm

* chore: generate types in dist directory

Co-authored-by: Ahad Birang <farnabaz@gmail.com>
  • Loading branch information
SugarF0x and farnabaz committed Jun 30, 2022
1 parent 58025e1 commit dad69b8
Show file tree
Hide file tree
Showing 7 changed files with 339 additions and 11 deletions.
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,18 @@
"main": "./dist/module.cjs",
"module": "./dist/module.mjs",
"types": "./dist/types.d.ts",
"web-types": "./dist/web-types.json",
"files": [
"dist"
],
"scripts": {
"build": "nuxt-module-build",
"dev": "./scripts/playground.sh",
"dev:build": "nuxi build playground/basic",
"dev:prepare": "nuxt-module-build --stub && nuxi prepare playground/basic",
"dev:fixtures": "./scripts/fixture.sh",
"build": "nuxt-module-build && yarn build:web-types",
"build:docs": "(cd docs && nuxi build)",
"build:web-types": "vue-docgen-web-types src/runtime/components/ ./dist/web-types.json",
"example": "./scripts/example.sh",
"lint": "eslint --ext .js,.ts,.vue .",
"prepack": "yarn build",
Expand Down Expand Up @@ -101,6 +103,7 @@
"nuxt": "^3.0.0-rc.4",
"rehype-figure": "^1.0.1",
"remark-oembed": "^1.2.2",
"vitest": "^0.16.0"
"vitest": "^0.16.0",
"vue-docgen-web-types": "^0.1.7"
}
}
9 changes: 9 additions & 0 deletions src/runtime/components/ContentDoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ export default defineComponent({
default: true
}
},

/**
* Document empty fallback
* @slot empty
*/
/**
* Document not found fallback
* @slot not-found
*/
render (ctx) {
const slots = useSlots()

Expand Down
9 changes: 9 additions & 0 deletions src/runtime/components/ContentList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ export default defineComponent({
default: undefined
}
},

/**
* Content empty fallback
* @slot empty
*/
/**
* Content not found fallback
* @slot not-found
*/
render (ctx) {
const slots = useSlots()

Expand Down
5 changes: 5 additions & 0 deletions src/runtime/components/ContentNavigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ export default defineComponent({
refresh
}
},

/**
* Navigation empty fallback
* @slot empty
*/
render (ctx) {
const slots = useSlots()

Expand Down
5 changes: 5 additions & 0 deletions src/runtime/components/ContentQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ export default defineComponent({
refresh
}
},

/**
* Content not found fallback
* @slot not-found
*/
render (ctx) {
const slots = useSlots()

Expand Down
4 changes: 4 additions & 0 deletions src/runtime/components/ContentRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ export default defineComponent({
}
)
},
/**
* Content empty fallback
* @slot empty
*/
render (ctx) {
const slots = useSlots()

Expand Down

0 comments on commit dad69b8

Please sign in to comment.