Initial boiler plate project

This commit is contained in:
2024-09-24 03:52:46 +00:00
parent 6120b2d6c3
commit 154b93e267
10034 changed files with 2079352 additions and 2 deletions

View File

@ -0,0 +1,40 @@
import { jsx as _jsx } from "react/jsx-runtime";
import React from "react";
import { MetaFilter } from "./meta";
function AlternateLink({ descriptor, ...props }) {
if (!descriptor.url) return null;
return /*#__PURE__*/ _jsx("link", {
...props,
...descriptor.title && {
title: descriptor.title
},
href: descriptor.url.toString()
});
}
export function AlternatesMetadata({ alternates }) {
if (!alternates) return null;
const { canonical, languages, media, types } = alternates;
return MetaFilter([
canonical ? AlternateLink({
rel: "canonical",
descriptor: canonical
}) : null,
languages ? Object.entries(languages).flatMap(([locale, descriptors])=>descriptors == null ? void 0 : descriptors.map((descriptor)=>AlternateLink({
rel: "alternate",
hrefLang: locale,
descriptor
}))) : null,
media ? Object.entries(media).flatMap(([mediaName, descriptors])=>descriptors == null ? void 0 : descriptors.map((descriptor)=>AlternateLink({
rel: "alternate",
media: mediaName,
descriptor
}))) : null,
types ? Object.entries(types).flatMap(([type, descriptors])=>descriptors == null ? void 0 : descriptors.map((descriptor)=>AlternateLink({
rel: "alternate",
type,
descriptor
}))) : null
]);
}
//# sourceMappingURL=alternate.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/lib/metadata/generate/alternate.tsx"],"names":["React","MetaFilter","AlternateLink","descriptor","props","url","link","title","href","toString","AlternatesMetadata","alternates","canonical","languages","media","types","rel","Object","entries","flatMap","locale","descriptors","map","hrefLang","mediaName","type"],"mappings":";AAGA,OAAOA,WAAW,QAAO;AACzB,SAASC,UAAU,QAAQ,SAAQ;AAEnC,SAASC,cAAc,EACrBC,UAAU,EACV,GAAGC,OAGwC;IAC3C,IAAI,CAACD,WAAWE,GAAG,EAAE,OAAO;IAC5B,qBACE,KAACC;QACE,GAAGF,KAAK;QACR,GAAID,WAAWI,KAAK,IAAI;YAAEA,OAAOJ,WAAWI,KAAK;QAAC,CAAC;QACpDC,MAAML,WAAWE,GAAG,CAACI,QAAQ;;AAGnC;AAEA,OAAO,SAASC,mBAAmB,EACjCC,UAAU,EAGX;IACC,IAAI,CAACA,YAAY,OAAO;IAExB,MAAM,EAAEC,SAAS,EAAEC,SAAS,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAGJ;IAE/C,OAAOV,WAAW;QAChBW,YACIV,cAAc;YAAEc,KAAK;YAAab,YAAYS;QAAU,KACxD;QACJC,YACII,OAAOC,OAAO,CAACL,WAAWM,OAAO,CAAC,CAAC,CAACC,QAAQC,YAAY,GACtDA,+BAAAA,YAAaC,GAAG,CAAC,CAACnB,aAChBD,cAAc;oBAAEc,KAAK;oBAAaO,UAAUH;oBAAQjB;gBAAW,OAGnE;QACJW,QACIG,OAAOC,OAAO,CAACJ,OAAOK,OAAO,CAAC,CAAC,CAACK,WAAWH,YAAY,GACrDA,+BAAAA,YAAaC,GAAG,CAAC,CAACnB,aAChBD,cAAc;oBAAEc,KAAK;oBAAaF,OAAOU;oBAAWrB;gBAAW,OAGnE;QACJY,QACIE,OAAOC,OAAO,CAACH,OAAOI,OAAO,CAAC,CAAC,CAACM,MAAMJ,YAAY,GAChDA,+BAAAA,YAAaC,GAAG,CAAC,CAACnB,aAChBD,cAAc;oBAAEc,KAAK;oBAAaS;oBAAMtB;gBAAW,OAGvD;KACL;AACH"}

View File

@ -0,0 +1,234 @@
import { jsx as _jsx } from "react/jsx-runtime";
import React from "react";
import { Meta, MetaFilter, MultiMeta } from "./meta";
import { ViewportMetaKeys } from "../constants";
// convert viewport object to string for viewport meta tag
function resolveViewportLayout(viewport) {
let resolved = null;
if (viewport && typeof viewport === "object") {
resolved = "";
for(const viewportKey_ in ViewportMetaKeys){
const viewportKey = viewportKey_;
if (viewportKey in viewport) {
let value = viewport[viewportKey];
if (typeof value === "boolean") value = value ? "yes" : "no";
if (resolved) resolved += ", ";
resolved += `${ViewportMetaKeys[viewportKey]}=${value}`;
}
}
}
return resolved;
}
export function ViewportMeta({ viewport }) {
return MetaFilter([
Meta({
name: "viewport",
content: resolveViewportLayout(viewport)
}),
...viewport.themeColor ? viewport.themeColor.map((themeColor)=>Meta({
name: "theme-color",
content: themeColor.color,
media: themeColor.media
})) : [],
Meta({
name: "color-scheme",
content: viewport.colorScheme
})
]);
}
export function BasicMeta({ metadata }) {
var _metadata_keywords, _metadata_robots, _metadata_robots1;
return MetaFilter([
/*#__PURE__*/ _jsx("meta", {
charSet: "utf-8"
}),
metadata.title !== null && metadata.title.absolute ? /*#__PURE__*/ _jsx("title", {
children: metadata.title.absolute
}) : null,
Meta({
name: "description",
content: metadata.description
}),
Meta({
name: "application-name",
content: metadata.applicationName
}),
...metadata.authors ? metadata.authors.map((author)=>[
author.url ? /*#__PURE__*/ _jsx("link", {
rel: "author",
href: author.url.toString()
}) : null,
Meta({
name: "author",
content: author.name
})
]) : [],
metadata.manifest ? /*#__PURE__*/ _jsx("link", {
rel: "manifest",
href: metadata.manifest.toString(),
crossOrigin: "use-credentials"
}) : null,
Meta({
name: "generator",
content: metadata.generator
}),
Meta({
name: "keywords",
content: (_metadata_keywords = metadata.keywords) == null ? void 0 : _metadata_keywords.join(",")
}),
Meta({
name: "referrer",
content: metadata.referrer
}),
Meta({
name: "creator",
content: metadata.creator
}),
Meta({
name: "publisher",
content: metadata.publisher
}),
Meta({
name: "robots",
content: (_metadata_robots = metadata.robots) == null ? void 0 : _metadata_robots.basic
}),
Meta({
name: "googlebot",
content: (_metadata_robots1 = metadata.robots) == null ? void 0 : _metadata_robots1.googleBot
}),
Meta({
name: "abstract",
content: metadata.abstract
}),
...metadata.archives ? metadata.archives.map((archive)=>/*#__PURE__*/ _jsx("link", {
rel: "archives",
href: archive
})) : [],
...metadata.assets ? metadata.assets.map((asset)=>/*#__PURE__*/ _jsx("link", {
rel: "assets",
href: asset
})) : [],
...metadata.bookmarks ? metadata.bookmarks.map((bookmark)=>/*#__PURE__*/ _jsx("link", {
rel: "bookmarks",
href: bookmark
})) : [],
Meta({
name: "category",
content: metadata.category
}),
Meta({
name: "classification",
content: metadata.classification
}),
...metadata.other ? Object.entries(metadata.other).map(([name, content])=>{
if (Array.isArray(content)) {
return content.map((contentItem)=>Meta({
name,
content: contentItem
}));
} else {
return Meta({
name,
content
});
}
}) : []
]);
}
export function ItunesMeta({ itunes }) {
if (!itunes) return null;
const { appId, appArgument } = itunes;
let content = `app-id=${appId}`;
if (appArgument) {
content += `, app-argument=${appArgument}`;
}
return /*#__PURE__*/ _jsx("meta", {
name: "apple-itunes-app",
content: content
});
}
export function FacebookMeta({ facebook }) {
if (!facebook) return null;
const { appId, admins } = facebook;
return MetaFilter([
appId ? /*#__PURE__*/ _jsx("meta", {
property: "fb:app_id",
content: appId
}) : null,
...admins ? admins.map((admin)=>/*#__PURE__*/ _jsx("meta", {
property: "fb:admins",
content: admin
})) : []
]);
}
const formatDetectionKeys = [
"telephone",
"date",
"address",
"email",
"url"
];
export function FormatDetectionMeta({ formatDetection }) {
if (!formatDetection) return null;
let content = "";
for (const key of formatDetectionKeys){
if (key in formatDetection) {
if (content) content += ", ";
content += `${key}=no`;
}
}
return /*#__PURE__*/ _jsx("meta", {
name: "format-detection",
content: content
});
}
export function AppleWebAppMeta({ appleWebApp }) {
if (!appleWebApp) return null;
const { capable, title, startupImage, statusBarStyle } = appleWebApp;
return MetaFilter([
capable ? Meta({
name: "apple-mobile-web-app-capable",
content: "yes"
}) : null,
Meta({
name: "apple-mobile-web-app-title",
content: title
}),
startupImage ? startupImage.map((image)=>/*#__PURE__*/ _jsx("link", {
href: image.url,
media: image.media,
rel: "apple-touch-startup-image"
})) : null,
statusBarStyle ? Meta({
name: "apple-mobile-web-app-status-bar-style",
content: statusBarStyle
}) : null
]);
}
export function VerificationMeta({ verification }) {
if (!verification) return null;
return MetaFilter([
MultiMeta({
namePrefix: "google-site-verification",
contents: verification.google
}),
MultiMeta({
namePrefix: "y_key",
contents: verification.yahoo
}),
MultiMeta({
namePrefix: "yandex-verification",
contents: verification.yandex
}),
MultiMeta({
namePrefix: "me",
contents: verification.me
}),
...verification.other ? Object.entries(verification.other).map(([key, value])=>MultiMeta({
namePrefix: key,
contents: value
})) : []
]);
}
//# sourceMappingURL=basic.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,51 @@
import { jsx as _jsx } from "react/jsx-runtime";
import React from "react";
import { MetaFilter } from "./meta";
function IconDescriptorLink({ icon }) {
const { url, rel = "icon", ...props } = icon;
return /*#__PURE__*/ _jsx("link", {
rel: rel,
href: url.toString(),
...props
});
}
function IconLink({ rel, icon }) {
if (typeof icon === "object" && !(icon instanceof URL)) {
if (!icon.rel && rel) icon.rel = rel;
return IconDescriptorLink({
icon
});
} else {
const href = icon.toString();
return /*#__PURE__*/ _jsx("link", {
rel: rel,
href: href
});
}
}
export function IconsMetadata({ icons }) {
if (!icons) return null;
const shortcutList = icons.shortcut;
const iconList = icons.icon;
const appleList = icons.apple;
const otherList = icons.other;
return MetaFilter([
shortcutList ? shortcutList.map((icon)=>IconLink({
rel: "shortcut icon",
icon
})) : null,
iconList ? iconList.map((icon)=>IconLink({
rel: "icon",
icon
})) : null,
appleList ? appleList.map((icon)=>IconLink({
rel: "apple-touch-icon",
icon
})) : null,
otherList ? otherList.map((icon)=>IconDescriptorLink({
icon
})) : null
]);
}
//# sourceMappingURL=icons.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/lib/metadata/generate/icons.tsx"],"names":["React","MetaFilter","IconDescriptorLink","icon","url","rel","props","link","href","toString","IconLink","URL","IconsMetadata","icons","shortcutList","shortcut","iconList","appleList","apple","otherList","other","map"],"mappings":";AAGA,OAAOA,WAAW,QAAO;AACzB,SAASC,UAAU,QAAQ,SAAQ;AAEnC,SAASC,mBAAmB,EAAEC,IAAI,EAA4B;IAC5D,MAAM,EAAEC,GAAG,EAAEC,MAAM,MAAM,EAAE,GAAGC,OAAO,GAAGH;IAExC,qBAAO,KAACI;QAAKF,KAAKA;QAAKG,MAAMJ,IAAIK,QAAQ;QAAK,GAAGH,KAAK;;AACxD;AAEA,SAASI,SAAS,EAAEL,GAAG,EAAEF,IAAI,EAAgC;IAC3D,IAAI,OAAOA,SAAS,YAAY,CAAEA,CAAAA,gBAAgBQ,GAAE,GAAI;QACtD,IAAI,CAACR,KAAKE,GAAG,IAAIA,KAAKF,KAAKE,GAAG,GAAGA;QACjC,OAAOH,mBAAmB;YAAEC;QAAK;IACnC,OAAO;QACL,MAAMK,OAAOL,KAAKM,QAAQ;QAC1B,qBAAO,KAACF;YAAKF,KAAKA;YAAKG,MAAMA;;IAC/B;AACF;AAEA,OAAO,SAASI,cAAc,EAAEC,KAAK,EAAwC;IAC3E,IAAI,CAACA,OAAO,OAAO;IAEnB,MAAMC,eAAeD,MAAME,QAAQ;IACnC,MAAMC,WAAWH,MAAMV,IAAI;IAC3B,MAAMc,YAAYJ,MAAMK,KAAK;IAC7B,MAAMC,YAAYN,MAAMO,KAAK;IAE7B,OAAOnB,WAAW;QAChBa,eACIA,aAAaO,GAAG,CAAC,CAAClB,OAASO,SAAS;gBAAEL,KAAK;gBAAiBF;YAAK,MACjE;QACJa,WAAWA,SAASK,GAAG,CAAC,CAAClB,OAASO,SAAS;gBAAEL,KAAK;gBAAQF;YAAK,MAAM;QACrEc,YACIA,UAAUI,GAAG,CAAC,CAAClB,OAASO,SAAS;gBAAEL,KAAK;gBAAoBF;YAAK,MACjE;QACJgB,YAAYA,UAAUE,GAAG,CAAC,CAAClB,OAASD,mBAAmB;gBAAEC;YAAK,MAAM;KACrE;AACH"}

View File

@ -0,0 +1,92 @@
import { jsx as _jsx } from "react/jsx-runtime";
import React from "react";
import { nonNullable } from "../../non-nullable";
export function Meta({ name, property, content, media }) {
if (typeof content !== "undefined" && content !== null && content !== "") {
return /*#__PURE__*/ _jsx("meta", {
...name ? {
name
} : {
property
},
...media ? {
media
} : undefined,
content: typeof content === "string" ? content : content.toString()
});
}
return null;
}
export function MetaFilter(items) {
const acc = [];
for (const item of items){
if (Array.isArray(item)) {
acc.push(...item.filter(nonNullable));
} else if (nonNullable(item)) {
acc.push(item);
}
}
return acc;
}
function camelToSnake(camelCaseStr) {
return camelCaseStr.replace(/([A-Z])/g, function(match) {
return "_" + match.toLowerCase();
});
}
const aliasPropPrefixes = new Set([
"og:image",
"twitter:image",
"og:video",
"og:audio"
]);
function getMetaKey(prefix, key) {
// Use `twitter:image` and `og:image` instead of `twitter:image:url` and `og:image:url`
// to be more compatible as it's a more common format.
// `og:video` & `og:audio` do not have a `:url` suffix alias
if (aliasPropPrefixes.has(prefix) && key === "url") {
return prefix;
}
if (prefix.startsWith("og:") || prefix.startsWith("twitter:")) {
key = camelToSnake(key);
}
return prefix + ":" + key;
}
function ExtendMeta({ content, namePrefix, propertyPrefix }) {
if (!content) return null;
return MetaFilter(Object.entries(content).map(([k, v])=>{
return typeof v === "undefined" ? null : Meta({
...propertyPrefix && {
property: getMetaKey(propertyPrefix, k)
},
...namePrefix && {
name: getMetaKey(namePrefix, k)
},
content: typeof v === "string" ? v : v == null ? void 0 : v.toString()
});
}));
}
export function MultiMeta({ propertyPrefix, namePrefix, contents }) {
if (typeof contents === "undefined" || contents === null) {
return null;
}
return MetaFilter(contents.map((content)=>{
if (typeof content === "string" || typeof content === "number" || content instanceof URL) {
return Meta({
...propertyPrefix ? {
property: propertyPrefix
} : {
name: namePrefix
},
content
});
} else {
return ExtendMeta({
namePrefix,
propertyPrefix,
content
});
}
}));
}
//# sourceMappingURL=meta.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/lib/metadata/generate/meta.tsx"],"names":["React","nonNullable","Meta","name","property","content","media","meta","undefined","toString","MetaFilter","items","acc","item","Array","isArray","push","filter","camelToSnake","camelCaseStr","replace","match","toLowerCase","aliasPropPrefixes","Set","getMetaKey","prefix","key","has","startsWith","ExtendMeta","namePrefix","propertyPrefix","Object","entries","map","k","v","MultiMeta","contents","URL"],"mappings":";AAAA,OAAOA,WAAW,QAAO;AACzB,SAASC,WAAW,QAAQ,qBAAoB;AAEhD,OAAO,SAASC,KAAK,EACnBC,IAAI,EACJC,QAAQ,EACRC,OAAO,EACPC,KAAK,EAMN;IACC,IAAI,OAAOD,YAAY,eAAeA,YAAY,QAAQA,YAAY,IAAI;QACxE,qBACE,KAACE;YACE,GAAIJ,OAAO;gBAAEA;YAAK,IAAI;gBAAEC;YAAS,CAAC;YAClC,GAAIE,QAAQ;gBAAEA;YAAM,IAAIE,SAAS;YAClCH,SAAS,OAAOA,YAAY,WAAWA,UAAUA,QAAQI,QAAQ;;IAGvE;IACA,OAAO;AACT;AAEA,OAAO,SAASC,WACdC,KAAmB;IAEnB,MAAMC,MAAwB,EAAE;IAChC,KAAK,MAAMC,QAAQF,MAAO;QACxB,IAAIG,MAAMC,OAAO,CAACF,OAAO;YACvBD,IAAII,IAAI,IAAIH,KAAKI,MAAM,CAAChB;QAC1B,OAAO,IAAIA,YAAYY,OAAO;YAC5BD,IAAII,IAAI,CAACH;QACX;IACF;IACA,OAAOD;AACT;AAWA,SAASM,aAAaC,YAAoB;IACxC,OAAOA,aAAaC,OAAO,CAAC,YAAY,SAAUC,KAAK;QACrD,OAAO,MAAMA,MAAMC,WAAW;IAChC;AACF;AAEA,MAAMC,oBAAoB,IAAIC,IAAI;IAChC;IACA;IACA;IACA;CACD;AACD,SAASC,WAAWC,MAAc,EAAEC,GAAW;IAC7C,uFAAuF;IACvF,sDAAsD;IACtD,4DAA4D;IAC5D,IAAIJ,kBAAkBK,GAAG,CAACF,WAAWC,QAAQ,OAAO;QAClD,OAAOD;IACT;IACA,IAAIA,OAAOG,UAAU,CAAC,UAAUH,OAAOG,UAAU,CAAC,aAAa;QAC7DF,MAAMT,aAAaS;IACrB;IACA,OAAOD,SAAS,MAAMC;AACxB;AAEA,SAASG,WAAW,EAClBzB,OAAO,EACP0B,UAAU,EACVC,cAAc,EAKf;IACC,IAAI,CAAC3B,SAAS,OAAO;IACrB,OAAOK,WACLuB,OAAOC,OAAO,CAAC7B,SAAS8B,GAAG,CAAC,CAAC,CAACC,GAAGC,EAAE;QACjC,OAAO,OAAOA,MAAM,cAChB,OACAnC,KAAK;YACH,GAAI8B,kBAAkB;gBAAE5B,UAAUqB,WAAWO,gBAAgBI;YAAG,CAAC;YACjE,GAAIL,cAAc;gBAAE5B,MAAMsB,WAAWM,YAAYK;YAAG,CAAC;YACrD/B,SAAS,OAAOgC,MAAM,WAAWA,IAAIA,qBAAAA,EAAG5B,QAAQ;QAClD;IACN;AAEJ;AAEA,OAAO,SAAS6B,UAAU,EACxBN,cAAc,EACdD,UAAU,EACVQ,QAAQ,EAKT;IACC,IAAI,OAAOA,aAAa,eAAeA,aAAa,MAAM;QACxD,OAAO;IACT;IAEA,OAAO7B,WACL6B,SAASJ,GAAG,CAAC,CAAC9B;QACZ,IACE,OAAOA,YAAY,YACnB,OAAOA,YAAY,YACnBA,mBAAmBmC,KACnB;YACA,OAAOtC,KAAK;gBACV,GAAI8B,iBACA;oBAAE5B,UAAU4B;gBAAe,IAC3B;oBAAE7B,MAAM4B;gBAAW,CAAC;gBACxB1B;YACF;QACF,OAAO;YACL,OAAOyB,WAAW;gBAChBC;gBACAC;gBACA3B;YACF;QACF;IACF;AAEJ"}

View File

@ -0,0 +1,448 @@
import { Meta, MetaFilter, MultiMeta } from "./meta";
export function OpenGraphMetadata({ openGraph }) {
var _openGraph_title, _openGraph_url, _openGraph_ttl;
if (!openGraph) {
return null;
}
let typedOpenGraph;
if ("type" in openGraph) {
const openGraphType = openGraph.type;
switch(openGraphType){
case "website":
typedOpenGraph = [
Meta({
property: "og:type",
content: "website"
})
];
break;
case "article":
var _openGraph_publishedTime, _openGraph_modifiedTime, _openGraph_expirationTime;
typedOpenGraph = [
Meta({
property: "og:type",
content: "article"
}),
Meta({
property: "article:published_time",
content: (_openGraph_publishedTime = openGraph.publishedTime) == null ? void 0 : _openGraph_publishedTime.toString()
}),
Meta({
property: "article:modified_time",
content: (_openGraph_modifiedTime = openGraph.modifiedTime) == null ? void 0 : _openGraph_modifiedTime.toString()
}),
Meta({
property: "article:expiration_time",
content: (_openGraph_expirationTime = openGraph.expirationTime) == null ? void 0 : _openGraph_expirationTime.toString()
}),
MultiMeta({
propertyPrefix: "article:author",
contents: openGraph.authors
}),
Meta({
property: "article:section",
content: openGraph.section
}),
MultiMeta({
propertyPrefix: "article:tag",
contents: openGraph.tags
})
];
break;
case "book":
typedOpenGraph = [
Meta({
property: "og:type",
content: "book"
}),
Meta({
property: "book:isbn",
content: openGraph.isbn
}),
Meta({
property: "book:release_date",
content: openGraph.releaseDate
}),
MultiMeta({
propertyPrefix: "book:author",
contents: openGraph.authors
}),
MultiMeta({
propertyPrefix: "book:tag",
contents: openGraph.tags
})
];
break;
case "profile":
typedOpenGraph = [
Meta({
property: "og:type",
content: "profile"
}),
Meta({
property: "profile:first_name",
content: openGraph.firstName
}),
Meta({
property: "profile:last_name",
content: openGraph.lastName
}),
Meta({
property: "profile:username",
content: openGraph.username
}),
Meta({
property: "profile:gender",
content: openGraph.gender
})
];
break;
case "music.song":
var _openGraph_duration;
typedOpenGraph = [
Meta({
property: "og:type",
content: "music.song"
}),
Meta({
property: "music:duration",
content: (_openGraph_duration = openGraph.duration) == null ? void 0 : _openGraph_duration.toString()
}),
MultiMeta({
propertyPrefix: "music:album",
contents: openGraph.albums
}),
MultiMeta({
propertyPrefix: "music:musician",
contents: openGraph.musicians
})
];
break;
case "music.album":
typedOpenGraph = [
Meta({
property: "og:type",
content: "music.album"
}),
MultiMeta({
propertyPrefix: "music:song",
contents: openGraph.songs
}),
MultiMeta({
propertyPrefix: "music:musician",
contents: openGraph.musicians
}),
Meta({
property: "music:release_date",
content: openGraph.releaseDate
})
];
break;
case "music.playlist":
typedOpenGraph = [
Meta({
property: "og:type",
content: "music.playlist"
}),
MultiMeta({
propertyPrefix: "music:song",
contents: openGraph.songs
}),
MultiMeta({
propertyPrefix: "music:creator",
contents: openGraph.creators
})
];
break;
case "music.radio_station":
typedOpenGraph = [
Meta({
property: "og:type",
content: "music.radio_station"
}),
MultiMeta({
propertyPrefix: "music:creator",
contents: openGraph.creators
})
];
break;
case "video.movie":
typedOpenGraph = [
Meta({
property: "og:type",
content: "video.movie"
}),
MultiMeta({
propertyPrefix: "video:actor",
contents: openGraph.actors
}),
MultiMeta({
propertyPrefix: "video:director",
contents: openGraph.directors
}),
MultiMeta({
propertyPrefix: "video:writer",
contents: openGraph.writers
}),
Meta({
property: "video:duration",
content: openGraph.duration
}),
Meta({
property: "video:release_date",
content: openGraph.releaseDate
}),
MultiMeta({
propertyPrefix: "video:tag",
contents: openGraph.tags
})
];
break;
case "video.episode":
typedOpenGraph = [
Meta({
property: "og:type",
content: "video.episode"
}),
MultiMeta({
propertyPrefix: "video:actor",
contents: openGraph.actors
}),
MultiMeta({
propertyPrefix: "video:director",
contents: openGraph.directors
}),
MultiMeta({
propertyPrefix: "video:writer",
contents: openGraph.writers
}),
Meta({
property: "video:duration",
content: openGraph.duration
}),
Meta({
property: "video:release_date",
content: openGraph.releaseDate
}),
MultiMeta({
propertyPrefix: "video:tag",
contents: openGraph.tags
}),
Meta({
property: "video:series",
content: openGraph.series
})
];
break;
case "video.tv_show":
typedOpenGraph = [
Meta({
property: "og:type",
content: "video.tv_show"
})
];
break;
case "video.other":
typedOpenGraph = [
Meta({
property: "og:type",
content: "video.other"
})
];
break;
default:
const _exhaustiveCheck = openGraphType;
throw new Error(`Invalid OpenGraph type: ${_exhaustiveCheck}`);
}
}
return MetaFilter([
Meta({
property: "og:determiner",
content: openGraph.determiner
}),
Meta({
property: "og:title",
content: (_openGraph_title = openGraph.title) == null ? void 0 : _openGraph_title.absolute
}),
Meta({
property: "og:description",
content: openGraph.description
}),
Meta({
property: "og:url",
content: (_openGraph_url = openGraph.url) == null ? void 0 : _openGraph_url.toString()
}),
Meta({
property: "og:site_name",
content: openGraph.siteName
}),
Meta({
property: "og:locale",
content: openGraph.locale
}),
Meta({
property: "og:country_name",
content: openGraph.countryName
}),
Meta({
property: "og:ttl",
content: (_openGraph_ttl = openGraph.ttl) == null ? void 0 : _openGraph_ttl.toString()
}),
MultiMeta({
propertyPrefix: "og:image",
contents: openGraph.images
}),
MultiMeta({
propertyPrefix: "og:video",
contents: openGraph.videos
}),
MultiMeta({
propertyPrefix: "og:audio",
contents: openGraph.audio
}),
MultiMeta({
propertyPrefix: "og:email",
contents: openGraph.emails
}),
MultiMeta({
propertyPrefix: "og:phone_number",
contents: openGraph.phoneNumbers
}),
MultiMeta({
propertyPrefix: "og:fax_number",
contents: openGraph.faxNumbers
}),
MultiMeta({
propertyPrefix: "og:locale:alternate",
contents: openGraph.alternateLocale
}),
...typedOpenGraph ? typedOpenGraph : []
]);
}
function TwitterAppItem({ app, type }) {
var _app_url_type, _app_url;
return [
Meta({
name: `twitter:app:name:${type}`,
content: app.name
}),
Meta({
name: `twitter:app:id:${type}`,
content: app.id[type]
}),
Meta({
name: `twitter:app:url:${type}`,
content: (_app_url = app.url) == null ? void 0 : (_app_url_type = _app_url[type]) == null ? void 0 : _app_url_type.toString()
})
];
}
export function TwitterMetadata({ twitter }) {
var _twitter_title;
if (!twitter) return null;
const { card } = twitter;
return MetaFilter([
Meta({
name: "twitter:card",
content: card
}),
Meta({
name: "twitter:site",
content: twitter.site
}),
Meta({
name: "twitter:site:id",
content: twitter.siteId
}),
Meta({
name: "twitter:creator",
content: twitter.creator
}),
Meta({
name: "twitter:creator:id",
content: twitter.creatorId
}),
Meta({
name: "twitter:title",
content: (_twitter_title = twitter.title) == null ? void 0 : _twitter_title.absolute
}),
Meta({
name: "twitter:description",
content: twitter.description
}),
MultiMeta({
namePrefix: "twitter:image",
contents: twitter.images
}),
...card === "player" ? twitter.players.flatMap((player)=>[
Meta({
name: "twitter:player",
content: player.playerUrl.toString()
}),
Meta({
name: "twitter:player:stream",
content: player.streamUrl.toString()
}),
Meta({
name: "twitter:player:width",
content: player.width
}),
Meta({
name: "twitter:player:height",
content: player.height
})
]) : [],
...card === "app" ? [
TwitterAppItem({
app: twitter.app,
type: "iphone"
}),
TwitterAppItem({
app: twitter.app,
type: "ipad"
}),
TwitterAppItem({
app: twitter.app,
type: "googleplay"
})
] : []
]);
}
export function AppLinksMeta({ appLinks }) {
if (!appLinks) return null;
return MetaFilter([
MultiMeta({
propertyPrefix: "al:ios",
contents: appLinks.ios
}),
MultiMeta({
propertyPrefix: "al:iphone",
contents: appLinks.iphone
}),
MultiMeta({
propertyPrefix: "al:ipad",
contents: appLinks.ipad
}),
MultiMeta({
propertyPrefix: "al:android",
contents: appLinks.android
}),
MultiMeta({
propertyPrefix: "al:windows_phone",
contents: appLinks.windows_phone
}),
MultiMeta({
propertyPrefix: "al:windows",
contents: appLinks.windows
}),
MultiMeta({
propertyPrefix: "al:windows_universal",
contents: appLinks.windows_universal
}),
MultiMeta({
propertyPrefix: "al:web",
contents: appLinks.web
})
]);
}
//# sourceMappingURL=opengraph.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,17 @@
function resolveArray(value) {
if (Array.isArray(value)) {
return value;
}
return [
value
];
}
function resolveAsArrayOrUndefined(value) {
if (typeof value === "undefined" || value === null) {
return undefined;
}
return resolveArray(value);
}
export { resolveAsArrayOrUndefined, resolveArray };
//# sourceMappingURL=utils.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/lib/metadata/generate/utils.ts"],"names":["resolveArray","value","Array","isArray","resolveAsArrayOrUndefined","undefined"],"mappings":"AAAA,SAASA,aAAgBC,KAAc;IACrC,IAAIC,MAAMC,OAAO,CAACF,QAAQ;QACxB,OAAOA;IACT;IACA,OAAO;QAACA;KAAM;AAChB;AAEA,SAASG,0BACPH,KAAiC;IAEjC,IAAI,OAAOA,UAAU,eAAeA,UAAU,MAAM;QAClD,OAAOI;IACT;IACA,OAAOL,aAAaC;AACtB;AAEA,SAASG,yBAAyB,EAAEJ,YAAY,GAAE"}