From 04d99b9c65d33bbe4686d84c456b5ea84648b5b1 Mon Sep 17 00:00:00 2001 From: Kevin Heiner Date: Fri, 10 Apr 2026 14:17:32 -0700 Subject: [PATCH 1/6] docs: add eslint to docs folder --- docs/.vitepress/config.ts | 21 ++++++----- docs/api/components/edit-button.md | 2 +- docs/api/components/index.md | 8 ++--- docs/api/components/visual-editor.md | 25 ++++++------- docs/api/composables/auth.md | 5 +-- docs/api/composables/client.md | 5 ++- docs/api/composables/file.md | 16 ++++----- docs/api/composables/index.md | 54 +++++++--------------------- docs/api/composables/storage.md | 2 +- docs/api/configuration/env.md | 20 ++++++----- docs/api/configuration/index.md | 1 - docs/api/configuration/module.md | 19 +++++----- docs/api/configuration/server.md | 2 +- docs/guide/authentication.md | 45 +++++++++++------------ docs/guide/files.md | 51 +++++++++++++------------- docs/guide/getting-started.md | 14 ++++---- docs/guide/introduction.md | 7 ++-- docs/guide/realtime.md | 16 +++++---- docs/guide/rules-sync.md | 4 +-- docs/guide/rules-testing.md | 18 +++++----- docs/guide/rules.md | 6 ++-- docs/guide/server-side.md | 14 +++++--- docs/guide/visual-editor.md | 27 +++++++------- docs/snippets/quick-example.vue | 48 ++++++++++++------------- eslint.config.js | 3 +- 25 files changed, 207 insertions(+), 226 deletions(-) diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 56b26f3..3572b07 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -42,17 +42,19 @@ export default defineConfig({ text: 'API Reference', items: [ { - text: 'Configuration', link: 'index', + text: 'Configuration', + link: 'index', collapsed: true, base: '/api/configuration/', items: [ { text: 'Module Options', link: 'module' }, { text: 'Environment Variables', link: 'env' }, { text: 'Directus Server Configuration', link: 'server' }, - ] + ], }, { - text: 'Composables', link: 'index', + text: 'Composables', + link: 'index', collapsed: true, base: '/api/composables/', items: [ @@ -60,17 +62,18 @@ export default defineConfig({ { text: 'Client', link: 'client' }, { text: 'File', link: 'file' }, { text: 'Storage', link: 'storage' }, - ] + ], }, { - text: 'Components', link: 'index', + text: 'Components', + link: 'index', collapsed: true, base: '/api/components/', items: [ { text: 'Visual Editor', link: 'visual-editor' }, { text: 'Edit Button', link: 'edit-button' }, { text: 'Add Button', link: 'add-button' }, - ] + ], }, ], }, @@ -80,13 +83,13 @@ export default defineConfig({ ], editLink: { pattern: 'https://github.com/rolleyio/nuxt-directus-sdk/edit/next/docs/:path', - text: 'Edit this page on GitHub' + text: 'Edit this page on GitHub', }, lastUpdated: { formatOptions: { dateStyle: 'medium', - } + }, }, - externalLinkIcon: true + externalLinkIcon: true, }, }) diff --git a/docs/api/components/edit-button.md b/docs/api/components/edit-button.md index 4e350d9..7a7f749 100644 --- a/docs/api/components/edit-button.md +++ b/docs/api/components/edit-button.md @@ -84,4 +84,4 @@ The button has scoped default styles. Override using the default slot for custom border-radius: 8px; z-index: 2147483647; } -``` \ No newline at end of file +``` diff --git a/docs/api/components/index.md b/docs/api/components/index.md index bb2e079..44292d0 100644 --- a/docs/api/components/index.md +++ b/docs/api/components/index.md @@ -25,8 +25,7 @@ const route = useRoute() const directus = useDirectus() const { data: article } = await useAsyncData('article', () => - directus.request(readItem('articles', route.params.id)) -) + directus.request(readItem('articles', route.params.id))) ``` @@ -528,15 +531,15 @@ Generate a URL for a Directus file with optional transformations. **Options:** ```typescript interface DirectusFileOptions { - filename?: string // Custom filename for downloads - download?: boolean // Force download - width?: number // Resize width - height?: number // Resize height - quality?: number // Image quality (1-100) + filename?: string // Custom filename for downloads + download?: boolean // Force download + width?: number // Resize width + height?: number // Resize height + quality?: number // Image quality (1-100) fit?: 'cover' | 'contain' | 'inside' | 'outside' format?: 'jpg' | 'png' | 'webp' | 'tiff' | 'avif' - withoutEnlargement?: boolean // Prevent upscaling - key?: string // Access key for private files + withoutEnlargement?: boolean // Prevent upscaling + key?: string // Access key for private files } ``` diff --git a/docs/guide/getting-started.md b/docs/guide/getting-started.md index d47372d..18f0170 100644 --- a/docs/guide/getting-started.md +++ b/docs/guide/getting-started.md @@ -33,7 +33,7 @@ export default defineNuxtConfig({ }) ``` ::: info -View all module options in the [API Reference > Configuration](../api/configuration.md#complete-configuration-example) page. +View all module options in the [API Reference > Configuration](../api/configuration.md#complete-configuration-example) page. ::: 3. Add the following variables to the `.env` file in your nuxt project root: @@ -46,7 +46,6 @@ DIRECTUS_ADMIN_TOKEN=admin_token_required_for_typegen - **`DIRECTUS_URL`** (required): Your Directus instance URL - **`DIRECTUS_ADMIN_TOKEN`** (optional): Admin token for type generation and `useAdminDirectus()` module. - ## Directus Configuration For the module to work properly, you need to configure your Directus instance with the following environment variables depending on your environment: @@ -82,7 +81,6 @@ These configuration examples assume that you do not modify the default environme WEBSOCKETS_ENABLED=true ``` - ## Verify Installation Create a simple page to test the integration: @@ -102,7 +100,7 @@ npx directus-template-cli@latest apply The template cli will attempt to merge with your existing content, but is not guaranteed to preserve anything. It is recommended that you use the cli on a fresh instance for testing as needed or modify the examples to work with your existing data structures. ::: - @@ -117,8 +115,8 @@ export default defineNuxtConfig({ directus: { // Proxy configuration (optional) devProxy: { - enabled: true, // default: true in dev mode - path: '/directus', // default: '/directus' + enabled: true, // default: true in dev mode + path: '/directus', // default: '/directus' }, }, }) @@ -134,8 +132,8 @@ If your Nuxt server can reach Directus via an internal URL (e.g. Docker service export default defineNuxtConfig({ directus: { url: { - client: 'https://cms.example.com', // Used by the browser - server: 'http://directus:8055', // Used during SSR + client: 'https://cms.example.com', // Used by the browser + server: 'http://directus:8055', // Used during SSR }, }, }) diff --git a/docs/guide/introduction.md b/docs/guide/introduction.md index e5a6742..8d64ed8 100644 --- a/docs/guide/introduction.md +++ b/docs/guide/introduction.md @@ -66,8 +66,7 @@ const { data: posts } = await useAsyncData('posts', () => directus.request(readItems('posts', { fields: ['*'], limit: 10 - })) -) + }))) // Subscribe to realtime updates await directus.connect() @@ -78,7 +77,9 @@ const { subscription } = await directus.subscribe('posts')

Welcome, {{ user.email }}

- +
diff --git a/docs/guide/realtime.md b/docs/guide/realtime.md index 569734e..969af6a 100644 --- a/docs/guide/realtime.md +++ b/docs/guide/realtime.md @@ -107,7 +107,7 @@ Configure realtime auth mode in your Nuxt app: export default defineNuxtConfig({ directus: { auth: { - realtimeAuthMode: 'public', // 'public', 'handshake', or 'strict' + realtimeAuthMode: 'public', // 'public', 'handshake', or 'strict' }, }, }) @@ -124,7 +124,7 @@ With session-based authentication and `WEBSOCKETS_REST_AUTH=strict` in Directus: export default defineNuxtConfig({ directus: { auth: { - realtimeAuthMode: 'public', // Default + realtimeAuthMode: 'public', // Default }, }, }) @@ -140,7 +140,7 @@ Authenticates during the initial WebSocket handshake: export default defineNuxtConfig({ directus: { auth: { - realtimeAuthMode: 'public', // Default - recommended + realtimeAuthMode: 'public', // Default - recommended }, }, }) @@ -182,7 +182,7 @@ const { subscription } = await directus.subscribe('collection_name', { filter: { /* filter options */ }, limit: 100, }, - uid: 'optional-uid' // Unique identifier for this subscription + uid: 'optional-uid' // Unique identifier for this subscription }) ``` @@ -205,7 +205,7 @@ for await (const message of subscription) { break case 'delete': // Item deleted - console.log('Deleted:', message.data) // Array of IDs + console.log('Deleted:', message.data) // Array of IDs break } } @@ -293,7 +293,7 @@ export function useRealtimePosts() { posts.value.push(...message.data) } if (message.event === 'update') { - message.data.forEach(updated => { + message.data.forEach((updated) => { const index = posts.value.findIndex(p => p.id === updated.id) if (index !== -1) { posts.value[index] = updated @@ -334,7 +334,9 @@ onBeforeUnmount(() => disconnect())