2
0
mirror of https://github.com/tenrok/vue-meta.git synced 2026-06-07 05:42:25 +03:00

types: update types for v2.3

This commit is contained in:
pimlie
2019-10-09 12:02:29 +02:00
parent 2231ec1aa1
commit dae968bc8b
4 changed files with 54 additions and 15 deletions
+3 -3
View File
@@ -727,7 +727,7 @@ Calling [`inject`](#meta-inject) will return an object on which you can call the
### head <Badge text="v2.3+"/>
- arguments
- ln (type `boolean`, default: `true`)
- ln (type `boolean`, default: `false`)
This is a convenience method which will retrieve the template string which should be added to the `head`.
@@ -737,7 +737,7 @@ By passing `ln = true` a line break will be added after each element. This could
### bodyPrepend <Badge text="v2.3+"/>
- arguments
- ln (type `boolean`, default: `true`)
- ln (type `boolean`, default: `false`)
This is a convenience method which will retrieve the template string which should be prepended to the body, i.e. listed just after `<body>`.
@@ -745,7 +745,7 @@ Elements will be printed in the same order as the menu below.
### bodyAppend <Badge text="v2.3+"/>
- arguments
- ln (type `boolean`, default: `true`)
- ln (type `boolean`, default: `false`)
This is a convenience method which will retrieve the template string which should be appended to the body, i.e. listed just before `</body>`.
+1
View File
@@ -6,6 +6,7 @@ export default VueMeta
export {
VueMetaOptions,
VueMetaPlugin,
VueMetaApp,
MetaInfo,
MetaInfoSSR,
AttributeProperty,
+18 -1
View File
@@ -1,5 +1,12 @@
import Vue, { ComponentOptions } from 'vue'
import VueMeta, { VueMetaPlugin, VueMetaOptions, MetaInfo, MetaInfoSSR } from '../index'
import VueMeta, {
VueMetaPlugin,
VueMetaOptions,
VueMetaApp,
MetaInfo,
MetaInfoSSR,
MetaPropertyCharset
} from '../index'
Vue.use(VueMeta, {
keyName: 'head'
@@ -67,6 +74,16 @@ if (metaDataSSR.script) {
metaDataSSR.script.text({ body: true })
}
// add app
const customApp: VueMetaApp = $meta.addApp('custom-app')
const metaCharset: MetaPropertyCharset = { charset: 'utf-8' }
const customAppInfo: MetaInfo = {
meta: [metaCharset]
}
customApp.set(customAppInfo)
// pausing & resuming
let resume
resume = $meta.pause()
+32 -11
View File
@@ -5,13 +5,18 @@ type Component = ComponentOptions<Vue> | typeof Vue
type CallbackFn = () => void
type elements = HTMLElement[]
export interface VueMetaOptions {
export interface VueMetaOptionsRuntime {
refreshOnceOnNavigation?: boolean
debounceWait?: number
waitOnDestroyed?: boolean
}
export interface VueMetaOptions extends VueMetaOptionsRuntime {
keyName: string, // the component option name that vue-meta looks for meta info on.
attribute: string, // the attribute name vue-meta adds to the tags it observes
ssrAppId: string, // the app id used for ssr app
ssrAttribute: string, // the attribute name that lets vue-meta know that meta info has already been server-rendered
tagIDKeyName: string // the property name that vue-meta uses to determine whether to overwrite or append a tag
refreshOnceOnNavigation: boolean
}
export declare class VueMeta {
@@ -21,17 +26,26 @@ export declare class VueMeta {
static generate(metaInfo: MetaInfo, options?: Object): MetaInfoSSR
}
interface RefreshedTags {
addedTags: elements
removedTags: elements
}
interface Refreshed {
vm: Component,
metaInfo: MetaInfo,
tags: {
addedTags: elements
removedTags: elements
}
tags: RefreshedTags
}
interface VueMetaApp {
set(metaInfo: MetaInfo): void | RefreshedTags
remove(): void
}
export interface VueMetaPlugin {
getOptions(): VueMetaOptions
setOptions(runtimeOptions: VueMetaOptionsRuntime): VueMetaOptions
addApp(appName: string): VueMetaApp
refresh(): Refreshed
inject(): MetaInfoSSR
pause(refresh: true): () => Refreshed
@@ -188,6 +202,10 @@ interface ToTextBooleanArg {
text(addSrrAttribute?: boolean): string
}
interface AddLineBreakOption {
ln: boolean
}
interface ToBodyTextOption {
body: boolean
}
@@ -197,18 +215,21 @@ interface ToPbodyTextOption {
}
interface ToBodyText {
text(options?: (ToBodyTextOption | ToPbodyTextOption)): string
text(options?: (ToBodyTextOption | ToPbodyTextOption | AddLineBreakOption)): string
}
export interface MetaInfoSSR {
head(ln?: boolean): string
bodyPrepend(ln?: boolean): string
bodyAppend(ln?: boolean): string
title?: ToText
htmlAttrs?: ToTextBooleanArg
headAttrs?: ToText
bodyAttrs?: ToText
base?: ToText
meta?: ToText
link?: ToText
style?: ToText
base?: ToBodyText
meta?: ToBodyText
link?: ToBodyText
style?: ToBodyText
script?: ToBodyText
noscript?: ToBodyText
}