Skip to content

⬅️ Back to Table of Contents

πŸ“„ useFavicon

πŸ“Š Analysis Summary

Metric Count
πŸ”§ Functions 2
πŸ“¦ Imports 9
🟒 Vue Composition API 1
πŸ“ Interfaces 1
πŸ“‘ Type Aliases 1

πŸ“š Table of Contents

πŸ› οΈ File Location:

πŸ“‚ packages/core/useFavicon/index.ts

πŸ“¦ Imports

Name Source
ReadonlyRefOrGetter @vueuse/shared
ComputedRef vue
MaybeRef vue
MaybeRefOrGetter vue
Ref vue
ConfigurableDocument ../_configurable
toRef @vueuse/shared
watch vue
defaultDocument ../_configurable

Vue Composition API

Name Type Reactive Variables Composables
watch watch none none

Functions

useFavicon(newIcon: ReadonlyRefOrGetter<string | null | und…, options: UseFaviconOptions): ComputedRef<string | null | undefined>

Reactive favicon.

Parameters:

  • newIcon any: No description
  • options any: No description

See: https://vueuse.org/useFavicon

Raw JSDoc
/**
 * Reactive favicon.
 *
 * @see https://vueuse.org/useFavicon
 * @param newIcon
 * @param options
 */
Code
export function useFavicon(
  newIcon: ReadonlyRefOrGetter<string | null | undefined>,
  options?: UseFaviconOptions,
): ComputedRef<string | null | undefined>

Internal helpers

Declared inside another function in this file.

applyIcon(icon: string): void

Parameters:

  • icon string

Returns: void

Calls:

  • document?.head .querySelectorAll
  • document?.createElement
  • icon.split('.').pop
  • document?.head.append
  • elements?.forEach
Code
(icon: string) => {
    const elements = document?.head
      .querySelectorAll<HTMLLinkElement>(`link[rel*="${rel}"]`)
    if (!elements || elements.length === 0) {
      const link = document?.createElement('link')
      if (link) {
        link.rel = rel
        link.href = `${baseUrl}${icon}`
        link.type = `image/${icon.split('.').pop()}`
        document?.head.append(link)
      }
      return
    }
    elements?.forEach(el => el.href = `${baseUrl}${icon}`)
  }

Interfaces

UseFaviconOptions

Interface Code
export interface UseFaviconOptions extends ConfigurableDocument {
  baseUrl?: string
  rel?: string
}

Properties

Name Type Optional Description
baseUrl string βœ“ not shown
rel string βœ“ not shown

Type Aliases

UseFaviconReturn

type UseFaviconReturn = ComputedRef<string | null | undefined> | Ref<string | null | undefined>;

Generated by Syntax Scribe