963 markdown files reformatted with the repository's pinned prettier so pnpm format:check covers the folded tree like every other repo file. The formatter's embedded-language pass also normalized code fences (TS semicolons, closed HTML tags in examples, lowercased CSS hex colors, one renumbered list that skipped an index). Alphanumeric token deltas vs the fold commit were audited file-by-file; all are formatter-equivalent markup normalizations plus the four sanitized skills.
1.4 KiB
1.4 KiB
category
| category |
|---|
| Browser |
useFavicon
Reactive favicon
Usage
import { useFavicon } from '@vueuse/core';
const icon = useFavicon();
icon.value = 'dark.png'; // change current icon
Passing a source ref
You can pass a ref to it, changes from of the source ref will be reflected to your favicon automatically.
import { useFavicon, usePreferredDark } from '@vueuse/core';
import { computed } from 'vue';
const isDark = usePreferredDark();
const favicon = computed(() => (isDark.value ? 'dark.png' : 'light.png'));
useFavicon(favicon);
When a source ref is passed, the return ref will be identical to the source ref
import { useFavicon } from '@vueuse/core';
// ---cut---
const source = shallowRef('icon.png');
const icon = useFavicon(source);
console.log(icon === source); // true
Type Declarations
export interface UseFaviconOptions extends ConfigurableDocument {
baseUrl?: string;
rel?: string;
}
/**
* Reactive favicon.
*
* @see https://vueuse.org/useFavicon
* @param newIcon
* @param options
*/
export declare function useFavicon(
newIcon: ReadonlyRefOrGetter<string | null | undefined>,
options?: UseFaviconOptions,
): ComputedRef<string | null | undefined>;
export declare function useFavicon(
newIcon?: MaybeRef<string | null | undefined>,
options?: UseFaviconOptions,
): Ref<string | null | undefined>;
export type UseFaviconReturn = ReturnType<typeof useFavicon>;