Skip to content

Commit

Permalink
Rename install methode and fix install types
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelreichor committed Oct 30, 2024
1 parent 1685120 commit 492c81d
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 18 deletions.
5 changes: 5 additions & 0 deletions .changeset/great-dolphins-invent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'vue-craftcms': patch
---

Change naming of install methode from CraftSdk to CraftCms and make all package options required
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ npm install -D vue-craftcms
Register the plugin on your application (usually in main.ts) and add the baseUrl to your craft cms backend

```typescript
import { CraftSdk } from 'craft-vue-sdk';
import { CraftCms } from '@vue-craftcms';
import { createApp } from 'vue';
import App from './App.vue';

const app = createApp(App);

app.use(CraftSdk, {
app.use(CraftCms, {
baseUrl: 'https://backend-craftcms.ddev.site',
debug: false,
debug: true,
registerComponents: true,
});

Expand Down
6 changes: 3 additions & 3 deletions lib/composables/useApi.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { inject } from 'vue';
import type { CraftSdkOptions } from '../types';
import type { CraftCmsOptions } from '../types';

export function useCraft(): CraftSdkOptions {
return inject<CraftSdkOptions>('CraftSdkOptions')!;
export function useCraft(): CraftCmsOptions {
return inject<CraftCmsOptions>('CraftCmsOptions')!;
}
14 changes: 7 additions & 7 deletions lib/main.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import CraftPage from './components/CraftPage.vue';
import CraftArea from './components/CraftArea.vue';
import type { App } from 'vue';
import type { CraftSdkOptions } from './types';
import type { CraftCmsOptions } from './types';

export * from './composables/useCraftUrlBuilder';
export * from './composables/useApi';
export * from './types';

export const defaultOptions: CraftSdkOptions = {
baseUrl: 'default.com',
export const defaultOptions: CraftCmsOptions = {
baseUrl: '',
registerComponents: true,
debug: false,
};

export const CraftSdk = {
install(app: App, options: CraftSdkOptions = defaultOptions) {
export const CraftCms = {
install(app: App, options: CraftCmsOptions = defaultOptions) {
if (options.registerComponents) {
app.component('CraftPage', CraftPage);
app.component('CraftArea', CraftArea);
}

app.provide('CraftSdkOptions', options);
app.provide('CraftCmsOptions', options);

if (options.debug) {
console.log('Craft SDK Options:', options);
console.log('Craft CMS Options', options);
}
},
};
6 changes: 3 additions & 3 deletions lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export type Config = {
};
};

export type CraftSdkOptions = {
export type CraftCmsOptions = {
baseUrl: string;
registerComponents?: boolean;
debug?: boolean;
registerComponents: boolean;
debug: boolean;
};
4 changes: 2 additions & 2 deletions playground/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { CraftSdk } from '@vue-craftcms';
import { CraftCms } from '@vue-craftcms';

import { createApp } from 'vue';
import App from './App.vue';

const app = createApp(App);

app.use(CraftSdk, {
app.use(CraftCms, {
baseUrl: 'https://backend-craftcms.ddev.site',
debug: true,
registerComponents: true,
Expand Down

0 comments on commit 492c81d

Please sign in to comment.