@bgscore/react-router
Version:
Automatic React Router generator for Vite with TypeScript support
95 lines (94 loc) • 2.37 kB
TypeScript
/**
* Metadata types inspired by Next.js but adapted for Vite + React CSR
*/
import { LoaderFunction } from "react-router-dom";
type Author = {
name: string;
url?: string;
};
type Robots = {
index?: boolean;
follow?: boolean;
nocache?: boolean;
noimageindex?: boolean;
nosnippet?: boolean;
};
type AlternateURLs = {
canonical?: string;
languages?: Record<string, string>;
media?: Record<string, string>;
types?: Record<string, string>;
};
type OpenGraphImage = {
url: string;
width?: number;
height?: number;
alt?: string;
};
type OpenGraph = {
type?: 'website' | 'article' | 'book' | 'profile' | 'music.song' | 'music.album' | 'music.playlist' | 'music.radio_station' | 'video.movie' | 'video.episode' | 'video.tv_show' | 'video.other';
title?: string;
description?: string;
url?: string;
siteName?: string;
images?: OpenGraphImage[];
publishedTime?: string;
authors?: string[];
};
type Twitter = {
card?: 'summary' | 'summary_large_image' | 'app' | 'player';
site?: string;
creator?: string;
title?: string;
description?: string;
images?: OpenGraphImage[];
};
type Verification = {
google?: string;
yandex?: string;
me?: string;
};
type ThemeColor = {
color: string;
media?: string;
};
type Icon = {
rel: 'icon' | 'apple-touch-icon' | 'shortcut icon';
url: string;
sizes?: string;
type?: string;
};
export type Metadata<T = unknown> = {
title?: string;
templateTitle?: string;
description?: string;
applicationName?: string;
sparatorTitle?: string;
actionCode?: string | null | undefined;
menuCode?: string | null | undefined;
independent?: boolean;
layout?: boolean;
handle?: any;
loader?: LoaderFunction<T>;
errorElement?: React.ReactNode | null;
authors?: Author[];
generator?: string;
publisher?: string;
keywords?: string[];
robots?: Robots | string;
alternates?: AlternateURLs;
openGraph?: OpenGraph;
twitter?: Twitter;
facebook?: {
appId?: string;
admins?: string[];
};
verification?: Verification;
manifest?: string;
icons?: Icon[];
themeColor?: ThemeColor | ThemeColor[];
canonical?: string;
other?: Record<string, string | string[]>;
protected?: boolean;
} & T;
export {};