UNPKG

react-seo-meta-tags

Version:

SEO metatags for React apps, especially blogs built with Gatsby or NextJS

111 lines (110 loc) 4.26 kB
/** * JSON-LD is a format for encoding structured data in the Internet. * Its popularity is due to the fact Google uses it and advocates websites to use it. * There is a lot of different formats for publishing data on JSON-LD but since * my own use-case is only for publishing blog posts I'll be using but a small subset * of them. */ import { WebsiteProps, BlogPostProps, OrganizationProps, BreadcrumbList } from './types'; /** * This schema is the bread and butter of websites. It's a simple description which * only benefit is I guess that Google might showcase your site in a search result. * (if all stars are aligned) * @param props */ export declare function generateWebsite({ author, datePublished, description, language, title, url, image, site }: WebsiteProps): { '@context': string; '@type': string; datePublished: string | null | undefined; description: string | null | undefined; image: string | null | undefined; inLanguage: string; name: string; url: string | null | undefined; author: { '@type': string; name: string | null | undefined; email: string | null | undefined; image: string | null | undefined; } | null | undefined; potentialAction: "" | { '@type': string; /** * @example "https://www.google.com/search?q=asdf" */ target: string; 'query-input': string; } | null | undefined; }; /** * Breadcrumb is a nice way to show the structure of your site. People and bots both respect that. * The breadcrumb will be showed in the search result directly, so it's important to get it right. * I think Google bot tries to do by itself, but I guess it's helpful if you add it by yourself too. * * https://developers.google.com/search/docs/guides/enhance-site#enable-breadcrumb */ export declare function generateBreadcrumbList(breadcrumbList: BreadcrumbList): { '@context': string; '@type': string; itemListElement: { '@type': string; position: number; item: { '@id': string; '@type': string; url: string; name: string; image: string | null | undefined; }; }[]; }; export declare function generateOrganization(organization: OrganizationProps): Object; /** * This is a general BlogPosting schema which covers quite a few attributes. * @param props */ export declare function generateBlogPosting({ url, title, description, image, datePublished, dateModified, tags, author, publisher }: WebsiteProps & BlogPostProps): { '@context': string; '@type': string; url: string | null | undefined; name: string; /** * From https://developers.google.com/search/docs/data-types/article#article_types * "The headline of the article. Headlines should not exceed 110 characters." */ headline: string; keywords: string[] | null | undefined; description: string | null | undefined; author: { '@type': string; name: string | null | undefined; email: string | null | undefined; image: string | null | undefined; } | null | undefined; publisher: Object | null | undefined; mainEntityOfPage: { /** * From example markup of JSON-LD https://developers.google.com/search/docs/data-types/article */ '@type': string; /** * Indicates that this BlogPosting is the main thing in this URL. */ '@id': string | null | undefined; }; /** * From https://developers.google.com/search/docs/data-types/article#article_types * "Images should be at least 1200 pixels wide." */ image: string; datePublished: string | null | undefined; /** * Recommended by https://search.google.com/structured-data/testing-tool * * Reasoning https://bts.nomadgate.com/medium-evergreen-content -> * Not only does Google prefer to feature more recent content in its search results, but * users are also more likely to click an article with a recent date listed next to it. * Does it make sense as you can just manipulate the date? Eeeh... Perhaps Google is aware of that. */ dateModified: string | undefined; };