@1amageek/open-graph-protocol
Version:
An interface for Open Graph Protocol.
158 lines (157 loc) • 5.08 kB
TypeScript
declare type DateTime = Date;
declare type Url = string;
export declare namespace OpenGraph {
type WebsiteType = "website";
type ArticleType = "article";
type ProductType = "product";
type BookType = "book";
type ProfileType = "profile";
type MusicType = "music.song" | "music.album" | "music.playlist" | "music.radio_station";
type VideoType = "video" | "video.movie" | "video.episode";
type ObjectType = WebsiteType | ArticleType | ProductType | BookType | ProfileType | VideoType;
interface Alternate {
alternate: string;
}
interface Basic {
title: string;
image: Url | Image;
url: Url;
audio?: Url | Audio;
description?: string;
determiner?: string;
locale?: string | Array<string | Alternate>;
site_name?: string;
}
interface Image {
url: string;
secure_url?: Url;
type?: string;
width?: string;
height?: string;
alt?: string;
}
interface Audio {
url: string;
secure_url?: string;
type?: string;
}
interface Website<T extends WebsiteType> extends Basic {
type: T;
}
interface Article<T extends ArticleType> extends Basic {
type: T;
article: {
published_time: DateTime;
modified_time: DateTime;
expiration_time: DateTime;
author: Url | Url[];
section: string;
tag: string | string[];
};
}
interface Amount {
amount: number;
}
interface Currency {
currency: string;
}
interface Product<T extends ProductType> extends Basic {
type: T;
product: {
plural_title?: string;
price: Array<Amount | Currency>;
};
}
interface Book<T extends BookType> extends Basic {
type: T;
book: {
author: Url | Url[];
isbn: string;
release_date: DateTime;
tag: string | string[];
};
}
interface Profile<T extends ProfileType> extends Basic {
type: T;
book: {
first_name: string;
last_name: string;
username: string;
gender: "male" | "female";
};
}
interface Music<T extends MusicType> extends Basic {
type: T;
music: Url | Music.Props<T>;
}
interface Video<T extends VideoType> extends Basic {
type: T;
video: Url | Video.Props<T>;
}
namespace Music {
interface Disc {
disc: number;
}
interface Track {
track: number;
}
export interface Song {
duration: number;
album: Url | Array<Url | Disc | Track>;
musician: Url;
}
export interface Album {
song: Url | Url[] | Array<Url | Disc | Track>;
musician: Url;
release_date: DateTime;
}
export interface Playlist {
song: Url | Url[] | Array<Url | Disc | Track>;
creator: Url;
}
export interface RadioStation {
creator: Url;
}
export type Props<T extends MusicType> = T extends "music.song" ? Music.Song : T extends "music.album" ? Music.Album : T extends "music.playlist" ? Music.Playlist : T extends "music.radio_station" ? Music.RadioStation : never;
export {};
}
namespace Video {
interface Role {
role: string;
}
export interface Base {
url: string;
secure_url?: string;
type?: string;
width?: string;
height?: string;
}
export interface Movie extends Base {
actor: string | string[] | Array<string | Role>;
director: Url | Url[];
writer: Url | Url[];
duration: number;
release_date: DateTime;
tag: string | string[];
}
export interface Episode extends Base {
actor: string | string[] | Array<string | Role>;
director: string | string[];
writer: string | string[];
duration: number;
release_date: DateTime;
tag: string | string[];
series: string;
}
export type Props<T extends VideoType> = T extends "video" ? Video.Base : T extends "video.movie" ? Video.Movie : T extends "video.episode" ? Video.Episode : never;
export {};
}
export type Metadata<T extends ObjectType> = T extends WebsiteType ? Website<T> : T extends ArticleType ? Article<T> : T extends ProductType ? Product<T> : T extends BookType ? Book<T> : T extends ProfileType ? Profile<T> : T extends MusicType ? Music<T> : T extends VideoType ? Video<T> : never;
interface Meta {
property: string;
content: string;
}
export const build: (object: any, iterator: (key: string, value: string) => any, parent?: string | undefined) => Meta[];
export {};
}
export {};