Skip to content

Commit

Permalink
🏷️ (types) move docus runtime instance into src/types
Browse files Browse the repository at this point in the history
  • Loading branch information
Tahul committed May 10, 2021
1 parent 1553720 commit 9b09d57
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/core/runtime/docus.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { reactive, Ref, toRefs } from '@nuxtjs/composition-api'
import type { DefaultThemeSettings } from '../../defaultTheme'
import { DocusSettings, PermissiveContext, DocusState, DocusAddonContext, DocusNavigation } from '../../types'
import { reactive, toRefs } from '@nuxtjs/composition-api'
import { DocusSettings, PermissiveContext, DocusState, DocusAddonContext, DocusRuntimeInstance } from '../../types'
import { useDocusApi } from './composables/api'
import { useDocusNavigation } from './composables/navigation'
import { clientAsyncData, docusInit } from './composables/helpers'
Expand All @@ -9,13 +8,6 @@ import { useDocusReleases } from './composables/releases'
import { useDocusStyle } from './composables/style'
import { useDocusAddons } from './composables/addons'

export type DocusRuntimeInstance<T = DefaultThemeSettings> = {
settings: Ref<Omit<DocusSettings, 'theme'>>
navigation: Ref<DocusNavigation>
theme: Ref<T>
[key: string]: any
} & ReturnType<typeof useDocusApi>

let docusInstance: DocusRuntimeInstance

/**
Expand All @@ -29,6 +21,8 @@ export const createDocus = async (
// Nuxt instance proxy
let $nuxt: any

const { ssrContext } = context

// State
const state = reactive({
settings: null,
Expand All @@ -45,6 +39,7 @@ export const createDocus = async (

// Create Docus Addons context
const docusAddonContext: DocusAddonContext = {
ssrContext,
$nuxt,
context,
state,
Expand Down
8 changes: 8 additions & 0 deletions src/types/core.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Context } from '@nuxt/types'
import { Ref } from '@nuxtjs/composition-api'
import { MetaInfo } from 'vue-meta'
import { useDocusApi } from '../core/runtime/composables/api'
import { DefaultThemeSettings } from '../defaultTheme/index.d'
Expand Down Expand Up @@ -106,13 +107,20 @@ export interface DocusSettings<T = DefaultThemeSettings> {
}

export interface DocusAddonContext<T = DefaultThemeSettings> {
ssrContext: Context['ssrContext']
context: PermissiveContext
state: DocusState
settings: DocusSettings<T>
createQuery: any
api: ReturnType<typeof useDocusApi>
$nuxt?: any
}
export type DocusRuntimeInstance<T = DefaultThemeSettings> = {
settings: Ref<Omit<DocusSettings, 'theme'>>
navigation: Ref<DocusNavigation>
theme: Ref<T>
[key: string]: any
} & ReturnType<typeof useDocusApi>

export interface Colors {
[key: string]: string | Colors
Expand Down

1 comment on commit 9b09d57

@vercel
Copy link

@vercel vercel bot commented on 9b09d57 May 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.