Skip to content

Commit

Permalink
Merge pull request #985 from basics/feature/composable-fix
Browse files Browse the repository at this point in the history
fix(composable): fix missing composable
  • Loading branch information
ThornWalli authored Apr 22, 2024
2 parents 4ee3c76 + 0ac46c8 commit 9aa05ec
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 16 deletions.
3 changes: 0 additions & 3 deletions docs/src/composables/useBoosterComponentObserver.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,9 @@ title: useBoosterComponentObserver
</template>

<script setup>
import useBoosterComponentObserver from '#booster/composables/componentObserver';
const { el: target, inView } = useBoosterComponentObserver({
trackVisibility: true,
delay: 350
});
</script>
```
1 change: 0 additions & 1 deletion docs/src/composables/useBoosterConfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ Returns `nuxt-booster` public runtime options.
## Example

```js
import { useBoosterConfig } from '#imports';
const $boosterOptions = useBoosterConfig();
```
1 change: 0 additions & 1 deletion docs/src/composables/useBoosterCritical.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const { isCritical } = useBoosterCritical({critical: true});
</template>

<script setup>
import { useBoosterCritical } from '#imports';
const { isCritical } = useBoosterCritical();
</script>
```
1 change: 0 additions & 1 deletion docs/src/composables/useBoosterFont.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const { $getFont } = useBoosterFonts({critical: true});
</template>

<script setup>
import { useBoosterFonts } from '#imports';
const { $getFont } = useBoosterFonts();
</script>
```
15 changes: 9 additions & 6 deletions src/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,15 @@ export default defineNuxtModule({
await addBuildTemplates(nuxt, moduleOptions);

addImports(
['useBoosterCritical', 'useBoosterConfig', 'useBoosterFonts'].map(
name => ({
name,
from: resolve(runtimeDir, 'composables/index')
})
)
[
'useBoosterComponentObserver',
'useBoosterCritical',
'useBoosterConfig',
'useBoosterFonts'
].map(name => ({
name,
from: resolve(runtimeDir, 'composables/index')
}))
);
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/composables/componentObserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { onMounted, ref } from 'vue';
import { getElementObserver } from '#booster/classes/intersection';
import { useBoosterCritical } from '#imports';

export default function useComponentObserver(options) {
export default function (options) {
const el = ref(null);
const inView = ref(false);

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/composables/config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useRuntimeConfig } from '#app';

export default function useConfig() {
export default function () {
const { booster: runtimeConfig } = useRuntimeConfig().public;
return runtimeConfig;
}
2 changes: 1 addition & 1 deletion src/runtime/composables/critical.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { computed, ref, inject, provide, useAttrs } from 'vue';

const criticalContextKey = Symbol('criticalContext');

export default function useFonts({ critical } = {}) {
export default function ({ critical } = {}) {
const attrs = useAttrs();

const currentCritical = ref(
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/composables/fonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useHead, useBoosterCritical, useBoosterConfig } from '#imports';
import { useNuxtApp } from '#app';
import FontCollection from '#booster/classes/FontCollection';

export default function useFonts(context) {
export default function (context) {
const { isCritical, critical } = useBoosterCritical(context);

const runtimeConfig = useBoosterConfig();
Expand Down
1 change: 1 addition & 0 deletions src/runtime/composables/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { default as useBoosterComponentObserver } from './componentObserver';
export { default as useBoosterCritical } from './critical';
export { default as useBoosterConfig } from './config';
export { default as useBoosterFonts } from './fonts';

0 comments on commit 9aa05ec

Please sign in to comment.