main repo

This commit is contained in:
Basilosaurusrex
2025-11-24 18:09:40 +01:00
parent b636ee5e70
commit f027651f9b
34146 changed files with 4436636 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
const TYPE_URL = "__METADATA_URL";
function replacer(_key, val) {
// clone URL as string but recover it as URL
if (val instanceof URL) {
return {
_type: TYPE_URL,
value: val.href
};
}
return val;
}
function reviver(_key, val) {
if (typeof val === "object" && val !== null && val._type === TYPE_URL) {
return new URL(val.value);
}
return val;
}
export function cloneMetadata(metadata) {
const jsonString = JSON.stringify(metadata, replacer);
return JSON.parse(jsonString, reviver);
}
//# sourceMappingURL=clone-metadata.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/lib/metadata/clone-metadata.ts"],"names":["TYPE_URL","replacer","_key","val","URL","_type","value","href","reviver","cloneMetadata","metadata","jsonString","JSON","stringify","parse"],"mappings":"AAEA,MAAMA,WAAW;AAEjB,SAASC,SAASC,IAAY,EAAEC,GAAQ;IACtC,4CAA4C;IAC5C,IAAIA,eAAeC,KAAK;QACtB,OAAO;YAAEC,OAAOL;YAAUM,OAAOH,IAAII,IAAI;QAAC;IAC5C;IACA,OAAOJ;AACT;AAEA,SAASK,QAAQN,IAAY,EAAEC,GAAQ;IACrC,IAAI,OAAOA,QAAQ,YAAYA,QAAQ,QAAQA,IAAIE,KAAK,KAAKL,UAAU;QACrE,OAAO,IAAII,IAAID,IAAIG,KAAK;IAC1B;IACA,OAAOH;AACT;AAEA,OAAO,SAASM,cAAcC,QAA0B;IACtD,MAAMC,aAAaC,KAAKC,SAAS,CAACH,UAAUT;IAC5C,OAAOW,KAAKE,KAAK,CAACH,YAAYH;AAChC"}

18
node_modules/next/dist/esm/lib/metadata/constants.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
export const ViewPortKeys = {
width: "width",
height: "height",
initialScale: "initial-scale",
minimumScale: "minimum-scale",
maximumScale: "maximum-scale",
viewportFit: "viewport-fit",
userScalable: "user-scalable",
interactiveWidget: "interactive-widget"
};
export const IconKeys = [
"icon",
"shortcut",
"apple",
"other"
];
//# sourceMappingURL=constants.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/lib/metadata/constants.ts"],"names":["ViewPortKeys","width","height","initialScale","minimumScale","maximumScale","viewportFit","userScalable","interactiveWidget","IconKeys"],"mappings":"AAGA,OAAO,MAAMA,eAAkD;IAC7DC,OAAO;IACPC,QAAQ;IACRC,cAAc;IACdC,cAAc;IACdC,cAAc;IACdC,aAAa;IACbC,cAAc;IACdC,mBAAmB;AACrB,EAAU;AAEV,OAAO,MAAMC,WAA4B;IAAC;IAAQ;IAAY;IAAS;CAAQ,CAAA"}

View File

@@ -0,0 +1,43 @@
export function createDefaultMetadata() {
return {
viewport: "width=device-width, initial-scale=1",
metadataBase: null,
// Other values are all null
title: null,
description: null,
applicationName: null,
authors: null,
generator: null,
keywords: null,
referrer: null,
themeColor: null,
colorScheme: null,
creator: null,
publisher: null,
robots: null,
manifest: null,
alternates: {
canonical: null,
languages: null,
media: null,
types: null
},
icons: null,
openGraph: null,
twitter: null,
verification: {},
appleWebApp: null,
formatDetection: null,
itunes: null,
abstract: null,
appLinks: null,
archives: null,
assets: null,
bookmarks: null,
category: null,
classification: null,
other: {}
};
}
//# sourceMappingURL=default-metadata.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/lib/metadata/default-metadata.tsx"],"names":["createDefaultMetadata","viewport","metadataBase","title","description","applicationName","authors","generator","keywords","referrer","themeColor","colorScheme","creator","publisher","robots","manifest","alternates","canonical","languages","media","types","icons","openGraph","twitter","verification","appleWebApp","formatDetection","itunes","abstract","appLinks","archives","assets","bookmarks","category","classification","other"],"mappings":"AAEA,OAAO,SAASA;IACd,OAAO;QACLC,UAAU;QACVC,cAAc;QAEd,4BAA4B;QAC5BC,OAAO;QACPC,aAAa;QACbC,iBAAiB;QACjBC,SAAS;QACTC,WAAW;QACXC,UAAU;QACVC,UAAU;QACVC,YAAY;QACZC,aAAa;QACbC,SAAS;QACTC,WAAW;QACXC,QAAQ;QACRC,UAAU;QACVC,YAAY;YACVC,WAAW;YACXC,WAAW;YACXC,OAAO;YACPC,OAAO;QACT;QACAC,OAAO;QACPC,WAAW;QACXC,SAAS;QACTC,cAAc,CAAC;QACfC,aAAa;QACbC,iBAAiB;QACjBC,QAAQ;QACRC,UAAU;QACVC,UAAU;QACVC,UAAU;QACVC,QAAQ;QACRC,WAAW;QACXC,UAAU;QACVC,gBAAgB;QAChBC,OAAO,CAAC;IACV;AACF"}

View File

@@ -0,0 +1,39 @@
import React from "react";
import { MetaFilter } from "./meta";
function AlternateLink({ descriptor, ...props }) {
if (!descriptor.url) return null;
return /*#__PURE__*/ React.createElement("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":"AAEA,OAAOA,WAAW,QAAO;AAEzB,SAASC,UAAU,QAAQ,SAAQ;AAEnC,SAASC,cAAc,EACrBC,UAAU,EACV,GAAGC,OAGwC;IAC3C,IAAI,CAACD,WAAWE,GAAG,EAAE,OAAO;IAC5B,qBACE,oBAACC;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,185 @@
import React from "react";
import { Meta, MetaFilter, MultiMeta } from "./meta";
export function BasicMetadata({ metadata }) {
var _metadata_keywords, _metadata_robots, _metadata_robots1;
return MetaFilter([
/*#__PURE__*/ React.createElement("meta", {
charSet: "utf-8"
}),
metadata.title !== null && metadata.title.absolute ? /*#__PURE__*/ React.createElement("title", null, 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__*/ React.createElement("link", {
rel: "author",
href: author.url.toString()
}) : null,
Meta({
name: "author",
content: author.name
})
]) : [],
metadata.manifest ? /*#__PURE__*/ React.createElement("link", {
rel: "manifest",
href: metadata.manifest.toString()
}) : 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
}),
...metadata.themeColor ? metadata.themeColor.map((themeColor)=>Meta({
name: "theme-color",
content: themeColor.color,
media: themeColor.media
})) : [],
Meta({
name: "color-scheme",
content: metadata.colorScheme
}),
Meta({
name: "viewport",
content: metadata.viewport
}),
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__*/ React.createElement("link", {
rel: "archives",
href: archive
})) : [],
...metadata.assets ? metadata.assets.map((asset)=>/*#__PURE__*/ React.createElement("link", {
rel: "assets",
href: asset
})) : [],
...metadata.bookmarks ? metadata.bookmarks.map((bookmark)=>/*#__PURE__*/ React.createElement("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])=>Meta({
name,
content: Array.isArray(content) ? content.join(",") : 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__*/ React.createElement("meta", {
name: "apple-itunes-app",
content: content
});
}
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__*/ React.createElement("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__*/ React.createElement("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

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/lib/metadata/generate/basic.tsx"],"names":["React","Meta","MetaFilter","MultiMeta","BasicMetadata","metadata","meta","charSet","title","absolute","name","content","description","applicationName","authors","map","author","url","link","rel","href","toString","manifest","generator","keywords","join","referrer","themeColor","color","media","colorScheme","viewport","creator","publisher","robots","basic","googleBot","abstract","archives","archive","assets","asset","bookmarks","bookmark","category","classification","other","Object","entries","Array","isArray","ItunesMeta","itunes","appId","appArgument","formatDetectionKeys","FormatDetectionMeta","formatDetection","key","AppleWebAppMeta","appleWebApp","capable","startupImage","statusBarStyle","image","VerificationMeta","verification","namePrefix","contents","google","yahoo","yandex","me","value"],"mappings":"AAEA,OAAOA,WAAW,QAAO;AACzB,SAASC,IAAI,EAAEC,UAAU,EAAEC,SAAS,QAAQ,SAAQ;AAEpD,OAAO,SAASC,cAAc,EAAEC,QAAQ,EAAkC;QAoBpCA,oBAeFA,kBACGA;IAnCrC,OAAOH,WAAW;sBAChB,oBAACI;YAAKC,SAAQ;;QACdF,SAASG,KAAK,KAAK,QAAQH,SAASG,KAAK,CAACC,QAAQ,iBAChD,oBAACD,eAAOH,SAASG,KAAK,CAACC,QAAQ,IAC7B;QACJR,KAAK;YAAES,MAAM;YAAeC,SAASN,SAASO,WAAW;QAAC;QAC1DX,KAAK;YAAES,MAAM;YAAoBC,SAASN,SAASQ,eAAe;QAAC;WAC/DR,SAASS,OAAO,GAChBT,SAASS,OAAO,CAACC,GAAG,CAAC,CAACC,SAAW;gBAC/BA,OAAOC,GAAG,iBACR,oBAACC;oBAAKC,KAAI;oBAASC,MAAMJ,OAAOC,GAAG,CAACI,QAAQ;qBAC1C;gBACJpB,KAAK;oBAAES,MAAM;oBAAUC,SAASK,OAAON,IAAI;gBAAC;aAC7C,IACD,EAAE;QACNL,SAASiB,QAAQ,iBACf,oBAACJ;YAAKC,KAAI;YAAWC,MAAMf,SAASiB,QAAQ,CAACD,QAAQ;aACnD;QACJpB,KAAK;YAAES,MAAM;YAAaC,SAASN,SAASkB,SAAS;QAAC;QACtDtB,KAAK;YAAES,MAAM;YAAYC,OAAO,GAAEN,qBAAAA,SAASmB,QAAQ,qBAAjBnB,mBAAmBoB,IAAI,CAAC;QAAK;QAC/DxB,KAAK;YAAES,MAAM;YAAYC,SAASN,SAASqB,QAAQ;QAAC;WAChDrB,SAASsB,UAAU,GACnBtB,SAASsB,UAAU,CAACZ,GAAG,CAAC,CAACY,aACvB1B,KAAK;g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M;YACNC,SAASoD;QACX,KACA;KACL;AACH;AAEA,OAAO,SAASE,iBAAiB,EAC/BC,YAAY,EAGb;IACC,IAAI,CAACA,cAAc,OAAO;IAE1B,OAAOhE,WAAW;QAChBC,UAAU;YACRgE,YAAY;YACZC,UAAUF,aAAaG,MAAM;QAC/B;QACAlE,UAAU;YAAEgE,YAAY;YAASC,UAAUF,aAAaI,KAAK;QAAC;QAC9DnE,UAAU;YACRgE,YAAY;YACZC,UAAUF,aAAaK,MAAM;QAC/B;QACApE,UAAU;YAAEgE,YAAY;YAAMC,UAAUF,aAAaM,EAAE;QAAC;WACpDN,aAAapB,KAAK,GAClBC,OAAOC,OAAO,CAACkB,aAAapB,KAAK,EAAE/B,GAAG,CAAC,CAAC,CAAC2C,KAAKe,MAAM,GAClDtE,UAAU;gBAAEgE,YAAYT;gBAAKU,UAAUK;YAAM,MAE/C,EAAE;KACP;AACH"}

View File

@@ -0,0 +1,50 @@
import React from "react";
import { MetaFilter } from "./meta";
function IconDescriptorLink({ icon }) {
const { url, rel = "icon", ...props } = icon;
return /*#__PURE__*/ React.createElement("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__*/ React.createElement("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,oBAACI;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,oBAACF;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,84 @@
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__*/ React.createElement("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();
});
}
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
if ((prefix === "og:image" || prefix === "twitter:image") && 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","getMetaKey","prefix","key","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,oBAACE;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,SAASC,WAAWC,MAAc,EAAEC,GAAW;IAC7C,uFAAuF;IACvF,qDAAqD;IACrD,IAAI,AAACD,CAAAA,WAAW,cAAcA,WAAW,eAAc,KAAMC,QAAQ,OAAO;QAC1E,OAAOD;IACT;IACA,IAAIA,OAAOE,UAAU,CAAC,UAAUF,OAAOE,UAAU,CAAC,aAAa;QAC7DD,MAAMP,aAAaO;IACrB;IACA,OAAOD,SAAS,MAAMC;AACxB;AAEA,SAASE,WAAW,EAClBtB,OAAO,EACPuB,UAAU,EACVC,cAAc,EAKf;IACC,IAAI,CAACxB,SAAS,OAAO;IACrB,OAAOK,WACLoB,OAAOC,OAAO,CAAC1B,SAAS2B,GAAG,CAAC,CAAC,CAACC,GAAGC,EAAE;QACjC,OAAO,OAAOA,MAAM,cAChB,OACAhC,KAAK;YACH,GAAI2B,kBAAkB;gBAAEzB,UAAUmB,WAAWM,gBAAgBI;YAAG,CAAC;YACjE,GAAIL,cAAc;gBAAEzB,MAAMoB,WAAWK,YAAYK;YAAG,CAAC;YACrD5B,SAAS,OAAO6B,MAAM,WAAWA,IAAIA,qBAAAA,EAAGzB,QAAQ;QAClD;IACN;AAEJ;AAEA,OAAO,SAAS0B,UAAU,EACxBN,cAAc,EACdD,UAAU,EACVQ,QAAQ,EAKT;IACC,IAAI,OAAOA,aAAa,eAAeA,aAAa,MAAM;QACxD,OAAO;IACT;IAEA,OAAO1B,WACL0B,SAASJ,GAAG,CAAC,CAAC3B;QACZ,IACE,OAAOA,YAAY,YACnB,OAAOA,YAAY,YACnBA,mBAAmBgC,KACnB;YACA,OAAOnC,KAAK;gBACV,GAAI2B,iBACA;oBAAEzB,UAAUyB;gBAAe,IAC3B;oBAAE1B,MAAMyB;gBAAW,CAAC;gBACxBvB;YACF;QACF,OAAO;YACL,OAAOsB,WAAW;gBAChBC;gBACAC;gBACAxB;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"}

View File

@@ -0,0 +1,72 @@
import { isMetadataRoute, isStaticMetadataRoute } from "./is-metadata-route";
import path from "../../shared/lib/isomorphic/path";
import { interpolateDynamicPath } from "../../server/server-utils";
import { getNamedRouteRegex } from "../../shared/lib/router/utils/route-regex";
import { djb2Hash } from "../../shared/lib/hash";
import { normalizeAppPath } from "../../shared/lib/router/utils/app-paths";
import { normalizePathSep } from "../../shared/lib/page-path/normalize-path-sep";
/*
* If there's special convention like (...) or @ in the page path,
* Give it a unique hash suffix to avoid conflicts
*
* e.g.
* /app/open-graph.tsx -> /open-graph/route
* /app/(post)/open-graph.tsx -> /open-graph/route-[0-9a-z]{6}
*/ function getMetadataRouteSuffix(page) {
let suffix = "";
if (page.includes("(") && page.includes(")") || page.includes("@")) {
suffix = djb2Hash(page).toString(36).slice(0, 6);
}
return suffix;
}
/**
* Fill the dynamic segment in the metadata route
*
* Example:
* fillMetadataSegment('/a/[slug]', { params: { slug: 'b' } }, 'open-graph') -> '/a/b/open-graph'
*
*/ export function fillMetadataSegment(segment, params, imageSegment) {
const pathname = normalizeAppPath(segment);
const routeRegex = getNamedRouteRegex(pathname, false);
const route = interpolateDynamicPath(pathname, params, routeRegex);
const suffix = getMetadataRouteSuffix(segment);
const routeSuffix = suffix ? `-${suffix}` : "";
const { name, ext } = path.parse(imageSegment);
return normalizePathSep(path.join(route, `${name}${routeSuffix}${ext}`));
}
/**
* Map metadata page key to the corresponding route
*
* static file page key: /app/robots.txt -> /robots.xml -> /robots.txt/route
* dynamic route page key: /app/robots.tsx -> /robots -> /robots.txt/route
*
* @param page
* @returns
*/ export function normalizeMetadataRoute(page) {
if (!isMetadataRoute(page)) {
return page;
}
let route = page;
let suffix = "";
if (page === "/robots") {
route += ".txt";
} else if (page === "/manifest") {
route += ".webmanifest";
} else if (page.endsWith("/sitemap")) {
route += ".xml";
} else {
// Remove the file extension, e.g. /route-path/robots.txt -> /route-path
const pathnamePrefix = page.slice(0, -(path.basename(page).length + 1));
suffix = getMetadataRouteSuffix(pathnamePrefix);
}
// Support both /<metadata-route.ext> and custom routes /<metadata-route>/route.ts.
// If it's a metadata file route, we need to append /[id]/route to the page.
if (!route.endsWith("/route")) {
const { dir, name: baseName, ext } = path.parse(route);
const isStaticRoute = isStaticMetadataRoute(page);
route = path.posix.join(dir, `${baseName}${suffix ? `-${suffix}` : ""}${ext}`, isStaticRoute ? "" : "[[...__metadata_id__]]", "route");
}
return route;
}
//# sourceMappingURL=get-metadata-route.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/lib/metadata/get-metadata-route.ts"],"names":["isMetadataRoute","isStaticMetadataRoute","path","interpolateDynamicPath","getNamedRouteRegex","djb2Hash","normalizeAppPath","normalizePathSep","getMetadataRouteSuffix","page","suffix","includes","toString","slice","fillMetadataSegment","segment","params","imageSegment","pathname","routeRegex","route","routeSuffix","name","ext","parse","join","normalizeMetadataRoute","endsWith","pathnamePrefix","basename","length","dir","baseName","isStaticRoute","posix"],"mappings":"AAAA,SAASA,eAAe,EAAEC,qBAAqB,QAAQ,sBAAqB;AAC5E,OAAOC,UAAU,mCAAkC;AACnD,SAASC,sBAAsB,QAAQ,4BAA2B;AAClE,SAASC,kBAAkB,QAAQ,4CAA2C;AAC9E,SAASC,QAAQ,QAAQ,wBAAuB;AAChD,SAASC,gBAAgB,QAAQ,0CAAyC;AAC1E,SAASC,gBAAgB,QAAQ,gDAA+C;AAEhF;;;;;;;CAOC,GACD,SAASC,uBAAuBC,IAAY;IAC1C,IAAIC,SAAS;IAEb,IAAI,AAACD,KAAKE,QAAQ,CAAC,QAAQF,KAAKE,QAAQ,CAAC,QAASF,KAAKE,QAAQ,CAAC,MAAM;QACpED,SAASL,SAASI,MAAMG,QAAQ,CAAC,IAAIC,KAAK,CAAC,GAAG;IAChD;IACA,OAAOH;AACT;AAEA;;;;;;CAMC,GACD,OAAO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AAI,CAAC,EAChDU,gBAAgB,KAAK,0BACrB;IAEJ;IAEA,OAAOb;AACT"}

View File

@@ -0,0 +1,93 @@
import { normalizePathSep } from "../../shared/lib/page-path/normalize-path-sep";
export const STATIC_METADATA_IMAGES = {
icon: {
filename: "icon",
extensions: [
"ico",
"jpg",
"jpeg",
"png",
"svg"
]
},
apple: {
filename: "apple-icon",
extensions: [
"jpg",
"jpeg",
"png"
]
},
favicon: {
filename: "favicon",
extensions: [
"ico"
]
},
openGraph: {
filename: "opengraph-image",
extensions: [
"jpg",
"jpeg",
"png",
"gif"
]
},
twitter: {
filename: "twitter-image",
extensions: [
"jpg",
"jpeg",
"png",
"gif"
]
}
};
// Match routes that are metadata routes, e.g. /sitemap.xml, /favicon.<ext>, /<icon>.<ext>, etc.
// TODO-METADATA: support more metadata routes with more extensions
const defaultExtensions = [
"js",
"jsx",
"ts",
"tsx"
];
const getExtensionRegexString = (extensions)=>`(?:${extensions.join("|")})`;
// When you only pass the file extension as `[]`, it will only match the static convention files
// e.g. /robots.txt, /sitemap.xml, /favicon.ico, /manifest.json
// When you pass the file extension as `['js', 'jsx', 'ts', 'tsx']`, it will also match the dynamic convention files
// e.g. /robots.js, /sitemap.tsx, /favicon.jsx, /manifest.ts
// When `withExtension` is false, it will match the static convention files without the extension, by default it's true
// e.g. /robots, /sitemap, /favicon, /manifest, use to match dynamic API routes like app/robots.ts
export function isMetadataRouteFile(appDirRelativePath, pageExtensions, withExtension) {
const metadataRouteFilesRegex = [
new RegExp(`^[\\\\/]robots${withExtension ? `\\.${getExtensionRegexString(pageExtensions.concat("txt"))}$` : ""}`),
new RegExp(`^[\\\\/]manifest${withExtension ? `\\.${getExtensionRegexString(pageExtensions.concat("webmanifest", "json"))}$` : ""}`),
new RegExp(`^[\\\\/]favicon\\.ico$`),
new RegExp(`[\\\\/]sitemap${withExtension ? `\\.${getExtensionRegexString(pageExtensions.concat("xml"))}$` : ""}`),
new RegExp(`[\\\\/]${STATIC_METADATA_IMAGES.icon.filename}\\d?${withExtension ? `\\.${getExtensionRegexString(pageExtensions.concat(STATIC_METADATA_IMAGES.icon.extensions))}$` : ""}`),
new RegExp(`[\\\\/]${STATIC_METADATA_IMAGES.apple.filename}\\d?${withExtension ? `\\.${getExtensionRegexString(pageExtensions.concat(STATIC_METADATA_IMAGES.apple.extensions))}$` : ""}`),
new RegExp(`[\\\\/]${STATIC_METADATA_IMAGES.openGraph.filename}\\d?${withExtension ? `\\.${getExtensionRegexString(pageExtensions.concat(STATIC_METADATA_IMAGES.openGraph.extensions))}$` : ""}`),
new RegExp(`[\\\\/]${STATIC_METADATA_IMAGES.twitter.filename}\\d?${withExtension ? `\\.${getExtensionRegexString(pageExtensions.concat(STATIC_METADATA_IMAGES.twitter.extensions))}$` : ""}`)
];
const normalizedAppDirRelativePath = normalizePathSep(appDirRelativePath);
return metadataRouteFilesRegex.some((r)=>r.test(normalizedAppDirRelativePath));
}
export function isStaticMetadataRouteFile(appDirRelativePath) {
return isMetadataRouteFile(appDirRelativePath, [], true);
}
export function isStaticMetadataRoute(page) {
return page === "/robots" || page === "/manifest" || isStaticMetadataRouteFile(page);
}
/*
* Remove the 'app' prefix or '/route' suffix, only check the route name since they're only allowed in root app directory
* e.g.
* /app/robots -> /robots
* app/robots -> /robots
* /robots -> /robots
*/ export function isMetadataRoute(route) {
let page = route.replace(/^\/?app\//, "").replace(/\/route$/, "");
if (page[0] !== "/") page = "/" + page;
return !page.endsWith("/page") && isMetadataRouteFile(page, defaultExtensions, false);
}
//# sourceMappingURL=is-metadata-route.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/lib/metadata/is-metadata-route.ts"],"names":["normalizePathSep","STATIC_METADATA_IMAGES","icon","filename","extensions","apple","favicon","openGraph","twitter","defaultExtensions","getExtensionRegexString","join","isMetadataRouteFile","appDirRelativePath","pageExtensions","withExtension","metadataRouteFilesRegex","RegExp","concat","normalizedAppDirRelativePath","some","r","test","isStaticMetadataRouteFile","isStaticMetadataRoute","page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AC9D,IAAIH,IAAI,CAAC,EAAE,KAAK,KAAKA,OAAO,MAAMA;IAElC,OACE,CAACA,KAAKI,QAAQ,CAAC,YACfjB,oBAAoBa,MAAMhB,mBAAmB;AAEjD"}

123
node_modules/next/dist/esm/lib/metadata/metadata.js generated vendored Normal file
View File

@@ -0,0 +1,123 @@
import React from "react";
import { AppleWebAppMeta, FormatDetectionMeta, ItunesMeta, BasicMetadata, VerificationMeta } from "./generate/basic";
import { AlternatesMetadata } from "./generate/alternate";
import { OpenGraphMetadata, TwitterMetadata, AppLinksMeta } from "./generate/opengraph";
import { IconsMetadata } from "./generate/icons";
import { resolveMetadata } from "./resolve-metadata";
import { MetaFilter } from "./generate/meta";
import { createDefaultMetadata } from "./default-metadata";
import { isNotFoundError } from "../../client/components/not-found";
// Use a promise to share the status of the metadata resolving,
// returning two components `MetadataTree` and `MetadataOutlet`
// `MetadataTree` is the one that will be rendered at first in the content sequence for metadata tags.
// `MetadataOutlet` is the one that will be rendered under error boundaries for metadata resolving errors.
// In this way we can let the metadata tags always render successfully,
// and the error will be caught by the error boundary and trigger fallbacks.
export function createMetadataComponents({ tree, pathname, searchParams, getDynamicParamFromSegment, appUsingSizeAdjust, errorType }) {
const metadataContext = {
pathname
};
let resolve;
// Only use promise.resolve here to avoid unhandled rejections
const metadataErrorResolving = new Promise((res)=>{
resolve = res;
});
async function MetadataTree() {
const defaultMetadata = createDefaultMetadata();
let metadata = defaultMetadata;
let error;
const errorMetadataItem = [
null,
null
];
const errorConvention = errorType === "redirect" ? undefined : errorType;
const [resolvedMetadata, resolvedError] = await resolveMetadata({
tree,
parentParams: {},
metadataItems: [],
errorMetadataItem,
searchParams,
getDynamicParamFromSegment,
errorConvention,
metadataContext
});
if (!resolvedError) {
metadata = resolvedMetadata;
resolve(undefined);
} else {
error = resolvedError;
// If the error triggers in initial metadata resolving, re-resolve with proper error type.
// They'll be saved for flight data, when hydrates, it will replaces the SSR'd metadata with this.
// for not-found error: resolve not-found metadata
if (!errorType && isNotFoundError(resolvedError)) {
const [notFoundMetadata, notFoundMetadataError] = await resolveMetadata({
tree,
parentParams: {},
metadataItems: [],
errorMetadataItem,
searchParams,
getDynamicParamFromSegment,
errorConvention: "not-found",
metadataContext
});
metadata = notFoundMetadata;
error = notFoundMetadataError || error;
}
resolve(error);
}
const elements = MetaFilter([
BasicMetadata({
metadata
}),
AlternatesMetadata({
alternates: metadata.alternates
}),
ItunesMeta({
itunes: metadata.itunes
}),
FormatDetectionMeta({
formatDetection: metadata.formatDetection
}),
VerificationMeta({
verification: metadata.verification
}),
AppleWebAppMeta({
appleWebApp: metadata.appleWebApp
}),
OpenGraphMetadata({
openGraph: metadata.openGraph
}),
TwitterMetadata({
twitter: metadata.twitter
}),
AppLinksMeta({
appLinks: metadata.appLinks
}),
IconsMetadata({
icons: metadata.icons
})
]);
if (appUsingSizeAdjust) elements.push(/*#__PURE__*/ React.createElement("meta", {
name: "next-size-adjust"
}));
return /*#__PURE__*/ React.createElement(React.Fragment, null, elements.map((el, index)=>{
return /*#__PURE__*/ React.cloneElement(el, {
key: index
});
}));
}
async function MetadataOutlet() {
const error = await metadataErrorResolving;
if (error) {
throw error;
}
return null;
}
// @ts-expect-error async server components
return [
MetadataTree,
MetadataOutlet
];
}
//# sourceMappingURL=metadata.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/lib/metadata/metadata.tsx"],"names":["React","AppleWebAppMeta","FormatDetectionMeta","ItunesMeta","BasicMetadata","VerificationMeta","AlternatesMetadata","OpenGraphMetadata","TwitterMetadata","AppLinksMeta","IconsMetadata","resolveMetadata","MetaFilter","createDefaultMetadata","isNotFoundError","createMetadataComponents","tree","pathname","searchParams","getDynamicParamFromSegment","appUsingSizeAdjust","errorType","metadataContext","resolve","metadataErrorResolving","Promise","res","MetadataTree","defaultMetadata","metadata","error","errorMetadataItem","errorConvention","undefined","resolvedMetadata","resolvedError","parentParams","metadataItems","notFoundMetadata","notFoundMetadataError","elements","alternates","itunes","formatDetection","verification","appleWebApp","openGraph","twitter","appLinks","icons","push","meta","name","map","el","index","cloneElement","key","MetadataOutlet"],"mappings":"AAGA,OAAOA,WAAW,QAAO;AACzB,SACEC,eAAe,EACfC,mBAAmB,EACnBC,UAAU,EACVC,aAAa,EACbC,gBAAgB,QACX,mBAAkB;AACzB,SAASC,kBAAkB,QAAQ,uBAAsB;AACzD,SACEC,iBAAiB,EACjBC,eAAe,EACfC,YAAY,QACP,uBAAsB;AAC7B,SAASC,aAAa,QAAQ,mBAAkB;AAChD,SAASC,eAAe,QAAQ,qBAAoB;AACpD,SAASC,UAAU,QAAQ,kBAAiB;AAE5C,SAASC,qBAAqB,QAAQ,qBAAoB;AAC1D,SAASC,eAAe,QAAQ,oCAAmC;AAEnE,+DAA+D;AAC/D,+DAA+D;AAC/D,sGAAsG;AACtG,0GAA0G;AAC1G,uEAAuE;AACvE,4EAA4E;AAC5E,OAAO,SAASC,yBAAyB,EACvCC,IAAI,EACJC,QAAQ,EACRC,YAAY,EACZC,0BAA0B,EAC1BC,kBAAkB,EAClBC,SAAS,EAQV;IACC,MAAMC,kBAAkB;QACtBL;IACF;IAEA,IAAIM;IACJ,8DAA8D;IAC9D,MAAMC,yBAAyB,IAAIC,QAA2B,CAACC;QAC7DH,UAAUG;IACZ;IAEA,eAAeC;QACb,MAAMC,kBAAkBf;QACxB,IAAIgB,WAAyCD;QAC7C,IAAIE;QACJ,MAAMC,oBAAkC;YAAC;YAAM;SAAK;QACpD,MAAMC,kBAAkBX,cAAc,aAAaY,YAAYZ;QAE/D,MAAM,CAACa,kBAAkBC,cAAc,GAAG,MAAMxB,gBAAgB;YAC9DK;YACAoB,cAAc,CAAC;YACfC,eAAe,EAAE;YACjBN;YACAb;YACAC;YACAa;YACAV;QACF;QACA,IAAI,CAACa,eAAe;YAClBN,WAAWK;YACXX,QAAQU;QACV,OAAO;YACLH,QAAQK;YACR,0FAA0F;YAC1F,kGAAkG;YAClG,kDAAkD;YAClD,IAAI,CAACd,aAAaP,gBAAgBqB,gBAAgB;gBAChD,MAAM,CAACG,kBAAkBC,sBAAsB,GAAG,MAAM5B,gBACtD;oBACEK;oBACAoB,cAAc,CAAC;oBACfC,eAAe,EAAE;oBACjBN;oBACAb;oBACAC;oBACAa,iBAAiB;oBACjBV;gBACF;gBAEFO,WAAWS;gBACXR,QAAQS,yBAAyBT;YACnC;YACAP,QAAQO;QACV;QAEA,MAAMU,WAAW5B,WAAW;YAC1BR,cAAc;gBAAEyB;YAAS;YACzBvB,mBAAmB;gBAAEmC,YAAYZ,SAASY,UAAU;YAAC;YACrDtC,WAAW;gBAAEuC,QAAQb,SAASa,MAAM;YAAC;YACrCxC,oBAAoB;gBAAEyC,iBAAiBd,SAASc,eAAe;YAAC;YAChEtC,iBAAiB;gBAAEuC,cAAcf,SAASe,YAAY;YAAC;YACvD3C,gBAAgB;gBAAE4C,aAAahB,SAASgB,WAAW;YAAC;YACpDtC,kBAAkB;gBAAEuC,WAAWjB,SAASiB,SAAS;YAAC;YAClDtC,gBAAgB;gBAAEuC,SAASlB,SAASkB,OAAO;YAAC;YAC5CtC,aAAa;gBAAEuC,UAAUnB,SAASmB,QAAQ;YAAC;YAC3CtC,cAAc;gBAAEuC,OAAOpB,SAASoB,KAAK;YAAC;SACvC;QAED,IAAI7B,oBAAoBoB,SAASU,IAAI,eAAC,oBAACC;YAAKC,MAAK;;QAEjD,qBACE,0CACGZ,SAASa,GAAG,CAAC,CAACC,IAAIC;YACjB,qBAAOvD,MAAMwD,YAAY,CAACF,IAA0B;gBAAEG,KAAKF;YAAM;QACnE;IAGN;IAEA,eAAeG;QACb,MAAM5B,QAAQ,MAAMN;QACpB,IAAIM,OAAO;YACT,MAAMA;QACR;QACA,OAAO;IACT;IAEA,2CAA2C;IAC3C,OAAO;QAACH;QAAc+B;KAAe;AACvC"}

View File

@@ -0,0 +1,399 @@
import { createDefaultMetadata } from "./default-metadata";
import { resolveOpenGraph, resolveTwitter } from "./resolvers/resolve-opengraph";
import { resolveTitle } from "./resolvers/resolve-title";
import { resolveAsArrayOrUndefined } from "./generate/utils";
import { isClientReference } from "../client-reference";
import { getComponentTypeModule, getLayoutOrPageModule } from "../../server/lib/app-dir-module";
import { interopDefault } from "../interop-default";
import { resolveAlternates, resolveAppleWebApp, resolveAppLinks, resolveRobots, resolveThemeColor, resolveVerification, resolveViewport, resolveItunes } from "./resolvers/resolve-basics";
import { resolveIcons } from "./resolvers/resolve-icons";
import { getTracer } from "../../server/lib/trace/tracer";
import { ResolveMetadataSpan } from "../../server/lib/trace/constants";
import { PAGE_SEGMENT_KEY } from "../../shared/lib/constants";
function hasIconsProperty(icons, prop) {
if (!icons) return false;
if (prop === "icon") {
// Detect if icons.icon will be presented, icons array and icons string will all be merged into icons.icon
return !!(typeof icons === "string" || icons instanceof URL || Array.isArray(icons) || prop in icons && icons[prop]);
} else {
// Detect if icons.apple will be presented, only icons.apple will be merged into icons.apple
return !!(typeof icons === "object" && prop in icons && icons[prop]);
}
}
function mergeStaticMetadata(source, target, staticFilesMetadata, metadataContext, titleTemplates) {
var _source_twitter, _source_openGraph;
if (!staticFilesMetadata) return;
const { icon, apple, openGraph, twitter, manifest } = staticFilesMetadata;
// file based metadata is specified and current level metadata icons is not specified
if (icon && !hasIconsProperty(source == null ? void 0 : source.icons, "icon") || apple && !hasIconsProperty(source == null ? void 0 : source.icons, "apple")) {
target.icons = {
icon: icon || [],
apple: apple || []
};
}
// file based metadata is specified and current level metadata twitter.images is not specified
if (twitter && !(source == null ? void 0 : (_source_twitter = source.twitter) == null ? void 0 : _source_twitter.hasOwnProperty("images"))) {
const resolvedTwitter = resolveTwitter({
...target.twitter,
images: twitter
}, target.metadataBase, titleTemplates.twitter);
target.twitter = resolvedTwitter;
}
// file based metadata is specified and current level metadata openGraph.images is not specified
if (openGraph && !(source == null ? void 0 : (_source_openGraph = source.openGraph) == null ? void 0 : _source_openGraph.hasOwnProperty("images"))) {
const resolvedOpenGraph = resolveOpenGraph({
...target.openGraph,
images: openGraph
}, target.metadataBase, metadataContext, titleTemplates.openGraph);
target.openGraph = resolvedOpenGraph;
}
if (manifest) {
target.manifest = manifest;
}
return target;
}
// Merge the source metadata into the resolved target metadata.
function merge({ source, target, staticFilesMetadata, titleTemplates, metadataContext }) {
// If there's override metadata, prefer it otherwise fallback to the default metadata.
const metadataBase = typeof (source == null ? void 0 : source.metadataBase) !== "undefined" ? source.metadataBase : target.metadataBase;
for(const key_ in source){
const key = key_;
switch(key){
case "title":
{
target.title = resolveTitle(source.title, titleTemplates.title);
break;
}
case "alternates":
{
target.alternates = resolveAlternates(source.alternates, metadataBase, metadataContext);
break;
}
case "openGraph":
{
target.openGraph = resolveOpenGraph(source.openGraph, metadataBase, metadataContext, titleTemplates.openGraph);
break;
}
case "twitter":
{
target.twitter = resolveTwitter(source.twitter, metadataBase, titleTemplates.twitter);
break;
}
case "verification":
target.verification = resolveVerification(source.verification);
break;
case "viewport":
{
target.viewport = resolveViewport(source.viewport);
break;
}
case "icons":
{
target.icons = resolveIcons(source.icons);
break;
}
case "appleWebApp":
target.appleWebApp = resolveAppleWebApp(source.appleWebApp);
break;
case "appLinks":
target.appLinks = resolveAppLinks(source.appLinks);
break;
case "robots":
{
target.robots = resolveRobots(source.robots);
break;
}
case "themeColor":
{
target.themeColor = resolveThemeColor(source.themeColor);
break;
}
case "archives":
case "assets":
case "bookmarks":
case "keywords":
{
target[key] = resolveAsArrayOrUndefined(source[key]);
break;
}
case "authors":
{
target[key] = resolveAsArrayOrUndefined(source.authors);
break;
}
case "itunes":
{
target[key] = resolveItunes(source.itunes, metadataBase, metadataContext);
break;
}
// directly assign fields that fallback to null
case "applicationName":
case "description":
case "generator":
case "creator":
case "publisher":
case "category":
case "classification":
case "referrer":
case "colorScheme":
case "formatDetection":
case "manifest":
// @ts-ignore TODO: support inferring
target[key] = source[key] || null;
break;
case "other":
target.other = Object.assign({}, target.other, source.other);
break;
case "metadataBase":
target.metadataBase = metadataBase;
break;
default:
break;
}
}
mergeStaticMetadata(source, target, staticFilesMetadata, metadataContext, titleTemplates);
}
async function getDefinedMetadata(mod, props, tracingProps) {
// Layer is a client component, we just skip it. It can't have metadata exported.
// Return early to avoid accessing properties error for client references.
if (isClientReference(mod)) {
return null;
}
if (typeof mod.generateMetadata === "function") {
const { route } = tracingProps;
return (parent)=>getTracer().trace(ResolveMetadataSpan.generateMetadata, {
spanName: `generateMetadata ${route}`,
attributes: {
"next.page": route
}
}, ()=>mod.generateMetadata(props, parent));
}
return mod.metadata || null;
}
async function collectStaticImagesFiles(metadata, props, type) {
var _this;
if (!(metadata == null ? void 0 : metadata[type])) return undefined;
const iconPromises = metadata[type].map(async (imageModule)=>interopDefault(await imageModule(props)));
return (iconPromises == null ? void 0 : iconPromises.length) > 0 ? (_this = await Promise.all(iconPromises)) == null ? void 0 : _this.flat() : undefined;
}
async function resolveStaticMetadata(components, props) {
const { metadata } = components;
if (!metadata) return null;
const [icon, apple, openGraph, twitter] = await Promise.all([
collectStaticImagesFiles(metadata, props, "icon"),
collectStaticImagesFiles(metadata, props, "apple"),
collectStaticImagesFiles(metadata, props, "openGraph"),
collectStaticImagesFiles(metadata, props, "twitter")
]);
const staticMetadata = {
icon,
apple,
openGraph,
twitter,
manifest: metadata.manifest
};
return staticMetadata;
}
// [layout.metadata, static files metadata] -> ... -> [page.metadata, static files metadata]
export async function collectMetadata({ tree, metadataItems, errorMetadataItem, props, route, errorConvention }) {
let mod;
let modType;
const hasErrorConventionComponent = Boolean(errorConvention && tree[2][errorConvention]);
if (errorConvention) {
mod = await getComponentTypeModule(tree, "layout");
modType = errorConvention;
} else {
[mod, modType] = await getLayoutOrPageModule(tree);
}
if (modType) {
route += `/${modType}`;
}
const staticFilesMetadata = await resolveStaticMetadata(tree[2], props);
const metadataExport = mod ? await getDefinedMetadata(mod, props, {
route
}) : null;
metadataItems.push([
metadataExport,
staticFilesMetadata
]);
if (hasErrorConventionComponent && errorConvention) {
const errorMod = await getComponentTypeModule(tree, errorConvention);
const errorMetadataExport = errorMod ? await getDefinedMetadata(errorMod, props, {
route
}) : null;
errorMetadataItem[0] = errorMetadataExport;
errorMetadataItem[1] = staticFilesMetadata;
}
}
export async function resolveMetadataItems({ tree, parentParams, metadataItems, errorMetadataItem, treePrefix = [], getDynamicParamFromSegment, searchParams, errorConvention }) {
const [segment, parallelRoutes, { page }] = tree;
const currentTreePrefix = [
...treePrefix,
segment
];
const isPage = typeof page !== "undefined";
// Handle dynamic segment params.
const segmentParam = getDynamicParamFromSegment(segment);
/**
* Create object holding the parent params and current params
*/ const currentParams = // Handle null case where dynamic param is optional
segmentParam && segmentParam.value !== null ? {
...parentParams,
[segmentParam.param]: segmentParam.value
} : parentParams;
const layerProps = {
params: currentParams,
...isPage && {
searchParams
}
};
await collectMetadata({
tree,
metadataItems,
errorMetadataItem,
errorConvention,
props: layerProps,
route: currentTreePrefix// __PAGE__ shouldn't be shown in a route
.filter((s)=>s !== PAGE_SEGMENT_KEY).join("/")
});
for(const key in parallelRoutes){
const childTree = parallelRoutes[key];
await resolveMetadataItems({
tree: childTree,
metadataItems,
errorMetadataItem,
parentParams: currentParams,
treePrefix: currentTreePrefix,
searchParams,
getDynamicParamFromSegment,
errorConvention
});
}
if (Object.keys(parallelRoutes).length === 0 && errorConvention) {
// If there are no parallel routes, place error metadata as the last item.
// e.g. layout -> layout -> not-found
metadataItems.push(errorMetadataItem);
}
return metadataItems;
}
const commonOgKeys = [
"title",
"description",
"images"
];
function postProcessMetadata(metadata, titleTemplates) {
const { openGraph, twitter } = metadata;
if (openGraph) {
let autoFillProps = {};
const hasTwTitle = twitter == null ? void 0 : twitter.title.absolute;
const hasTwDescription = twitter == null ? void 0 : twitter.description;
const hasTwImages = Boolean((twitter == null ? void 0 : twitter.hasOwnProperty("images")) && twitter.images);
if (!hasTwTitle) autoFillProps.title = openGraph.title;
if (!hasTwDescription) autoFillProps.description = openGraph.description;
if (!hasTwImages) autoFillProps.images = openGraph.images;
if (Object.keys(autoFillProps).length > 0) {
const partialTwitter = resolveTwitter(autoFillProps, metadata.metadataBase, titleTemplates.twitter);
if (metadata.twitter) {
metadata.twitter = Object.assign({}, metadata.twitter, {
...!hasTwTitle && {
title: partialTwitter == null ? void 0 : partialTwitter.title
},
...!hasTwDescription && {
description: partialTwitter == null ? void 0 : partialTwitter.description
},
...!hasTwImages && {
images: partialTwitter == null ? void 0 : partialTwitter.images
}
});
} else {
metadata.twitter = partialTwitter;
}
}
}
return metadata;
}
export async function accumulateMetadata(metadataItems, metadataContext) {
const resolvedMetadata = createDefaultMetadata();
const resolvers = [];
const generateMetadataResults = [];
let titleTemplates = {
title: null,
twitter: null,
openGraph: null
};
// Loop over all metadata items again, merging synchronously any static object exports,
// awaiting any static promise exports, and resolving parent metadata and awaiting any generated metadata
let resolvingIndex = 0;
for(let i = 0; i < metadataItems.length; i++){
const [metadataExport, staticFilesMetadata] = metadataItems[i];
let metadata = null;
if (typeof metadataExport === "function") {
if (!resolvers.length) {
for(let j = i; j < metadataItems.length; j++){
const [preloadMetadataExport] = metadataItems[j];
// call each `generateMetadata function concurrently and stash their resolver
if (typeof preloadMetadataExport === "function") {
generateMetadataResults.push(preloadMetadataExport(new Promise((resolve)=>{
resolvers.push(resolve);
})));
}
}
}
const resolveParent = resolvers[resolvingIndex];
const generatedMetadata = generateMetadataResults[resolvingIndex++];
// In dev we clone and freeze to prevent relying on mutating resolvedMetadata directly.
// In prod we just pass resolvedMetadata through without any copying.
const currentResolvedMetadata = process.env.NODE_ENV === "development" ? Object.freeze(require("./clone-metadata").cloneMetadata(resolvedMetadata)) : resolvedMetadata;
// This resolve should unblock the generateMetadata function if it awaited the parent
// argument. If it didn't await the parent argument it might already have a value since it was
// called concurrently. Regardless we await the return value before continuing on to the next layer
resolveParent(currentResolvedMetadata);
metadata = generatedMetadata instanceof Promise ? await generatedMetadata : generatedMetadata;
} else if (metadataExport !== null && typeof metadataExport === "object") {
// This metadataExport is the object form
metadata = metadataExport;
}
merge({
metadataContext,
target: resolvedMetadata,
source: metadata,
staticFilesMetadata,
titleTemplates
});
// If the layout is the same layer with page, skip the leaf layout and leaf page
// The leaf layout and page are the last two items
if (i < metadataItems.length - 2) {
var _resolvedMetadata_title, _resolvedMetadata_openGraph, _resolvedMetadata_twitter;
titleTemplates = {
title: ((_resolvedMetadata_title = resolvedMetadata.title) == null ? void 0 : _resolvedMetadata_title.template) || null,
openGraph: ((_resolvedMetadata_openGraph = resolvedMetadata.openGraph) == null ? void 0 : _resolvedMetadata_openGraph.title.template) || null,
twitter: ((_resolvedMetadata_twitter = resolvedMetadata.twitter) == null ? void 0 : _resolvedMetadata_twitter.title.template) || null
};
}
}
return postProcessMetadata(resolvedMetadata, titleTemplates);
}
export async function resolveMetadata({ tree, parentParams, metadataItems, errorMetadataItem, getDynamicParamFromSegment, searchParams, errorConvention, metadataContext }) {
const resolvedMetadataItems = await resolveMetadataItems({
tree,
parentParams,
metadataItems,
errorMetadataItem,
getDynamicParamFromSegment,
searchParams,
errorConvention
});
let metadata = createDefaultMetadata();
let error;
try {
metadata = await accumulateMetadata(resolvedMetadataItems, metadataContext);
} catch (err) {
error = err;
}
return [
metadata,
error
];
}
//# sourceMappingURL=resolve-metadata.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,184 @@
import { resolveAsArrayOrUndefined } from "../generate/utils";
import { resolveAbsoluteUrlWithPathname } from "./resolve-url";
import { ViewPortKeys } from "../constants";
function resolveAlternateUrl(url, metadataBase, pathname) {
// If alter native url is an URL instance,
// we treat it as a URL base and resolve with current pathname
if (url instanceof URL) {
url = new URL(pathname, url);
}
return resolveAbsoluteUrlWithPathname(url, metadataBase, pathname);
}
export const resolveThemeColor = (themeColor)=>{
var _resolveAsArrayOrUndefined;
if (!themeColor) return null;
const themeColorDescriptors = [];
(_resolveAsArrayOrUndefined = resolveAsArrayOrUndefined(themeColor)) == null ? void 0 : _resolveAsArrayOrUndefined.forEach((descriptor)=>{
if (typeof descriptor === "string") themeColorDescriptors.push({
color: descriptor
});
else if (typeof descriptor === "object") themeColorDescriptors.push({
color: descriptor.color,
media: descriptor.media
});
});
return themeColorDescriptors;
};
export const resolveViewport = (viewport)=>{
let resolved = null;
if (typeof viewport === "string") {
resolved = viewport;
} else if (viewport) {
resolved = "";
for(const viewportKey_ in ViewPortKeys){
const viewportKey = viewportKey_;
if (viewportKey in viewport) {
let value = viewport[viewportKey];
if (typeof value === "boolean") value = value ? "yes" : "no";
if (resolved) resolved += ", ";
resolved += `${ViewPortKeys[viewportKey]}=${value}`;
}
}
}
return resolved;
};
function resolveUrlValuesOfObject(obj, metadataBase, pathname) {
if (!obj) return null;
const result = {};
for (const [key, value] of Object.entries(obj)){
if (typeof value === "string" || value instanceof URL) {
result[key] = [
{
url: resolveAlternateUrl(value, metadataBase, pathname)
}
];
} else {
result[key] = [];
value == null ? void 0 : value.forEach((item, index)=>{
const url = resolveAlternateUrl(item.url, metadataBase, pathname);
result[key][index] = {
url,
title: item.title
};
});
}
}
return result;
}
function resolveCanonicalUrl(urlOrDescriptor, metadataBase, pathname) {
if (!urlOrDescriptor) return null;
const url = typeof urlOrDescriptor === "string" || urlOrDescriptor instanceof URL ? urlOrDescriptor : urlOrDescriptor.url;
// Return string url because structureClone can't handle URL instance
return {
url: resolveAlternateUrl(url, metadataBase, pathname)
};
}
export const resolveAlternates = (alternates, metadataBase, { pathname })=>{
if (!alternates) return null;
const canonical = resolveCanonicalUrl(alternates.canonical, metadataBase, pathname);
const languages = resolveUrlValuesOfObject(alternates.languages, metadataBase, pathname);
const media = resolveUrlValuesOfObject(alternates.media, metadataBase, pathname);
const types = resolveUrlValuesOfObject(alternates.types, metadataBase, pathname);
const result = {
canonical,
languages,
media,
types
};
return result;
};
const robotsKeys = [
"noarchive",
"nosnippet",
"noimageindex",
"nocache",
"notranslate",
"indexifembedded",
"nositelinkssearchbox",
"unavailable_after",
"max-video-preview",
"max-image-preview",
"max-snippet"
];
const resolveRobotsValue = (robots)=>{
if (!robots) return null;
if (typeof robots === "string") return robots;
const values = [];
if (robots.index) values.push("index");
else if (typeof robots.index === "boolean") values.push("noindex");
if (robots.follow) values.push("follow");
else if (typeof robots.follow === "boolean") values.push("nofollow");
for (const key of robotsKeys){
const value = robots[key];
if (typeof value !== "undefined" && value !== false) {
values.push(typeof value === "boolean" ? key : `${key}:${value}`);
}
}
return values.join(", ");
};
export const resolveRobots = (robots)=>{
if (!robots) return null;
return {
basic: resolveRobotsValue(robots),
googleBot: typeof robots !== "string" ? resolveRobotsValue(robots.googleBot) : null
};
};
const VerificationKeys = [
"google",
"yahoo",
"yandex",
"me",
"other"
];
export const resolveVerification = (verification)=>{
if (!verification) return null;
const res = {};
for (const key of VerificationKeys){
const value = verification[key];
if (value) {
if (key === "other") {
res.other = {};
for(const otherKey in verification.other){
const otherValue = resolveAsArrayOrUndefined(verification.other[otherKey]);
if (otherValue) res.other[otherKey] = otherValue;
}
} else res[key] = resolveAsArrayOrUndefined(value);
}
}
return res;
};
export const resolveAppleWebApp = (appWebApp)=>{
var _resolveAsArrayOrUndefined;
if (!appWebApp) return null;
if (appWebApp === true) {
return {
capable: true
};
}
const startupImages = appWebApp.startupImage ? (_resolveAsArrayOrUndefined = resolveAsArrayOrUndefined(appWebApp.startupImage)) == null ? void 0 : _resolveAsArrayOrUndefined.map((item)=>typeof item === "string" ? {
url: item
} : item) : null;
return {
capable: "capable" in appWebApp ? !!appWebApp.capable : true,
title: appWebApp.title || null,
startupImage: startupImages,
statusBarStyle: appWebApp.statusBarStyle || "default"
};
};
export const resolveAppLinks = (appLinks)=>{
if (!appLinks) return null;
for(const key in appLinks){
// @ts-ignore // TODO: type infer
appLinks[key] = resolveAsArrayOrUndefined(appLinks[key]);
}
return appLinks;
};
export const resolveItunes = (itunes, metadataBase, { pathname })=>{
if (!itunes) return null;
return {
appId: itunes.appId,
appArgument: itunes.appArgument ? resolveAlternateUrl(itunes.appArgument, metadataBase, pathname) : undefined
};
};
//# sourceMappingURL=resolve-basics.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,34 @@
import { resolveAsArrayOrUndefined } from "../generate/utils";
import { isStringOrURL } from "./resolve-url";
import { IconKeys } from "../constants";
export function resolveIcon(icon) {
if (isStringOrURL(icon)) return {
url: icon
};
else if (Array.isArray(icon)) return icon;
return icon;
}
export const resolveIcons = (icons)=>{
if (!icons) {
return null;
}
const resolved = {
icon: [],
apple: []
};
if (Array.isArray(icons)) {
resolved.icon = icons.map(resolveIcon).filter(Boolean);
} else if (isStringOrURL(icons)) {
resolved.icon = [
resolveIcon(icons)
];
} else {
for (const key of IconKeys){
const values = resolveAsArrayOrUndefined(icons[key]);
if (values) resolved[key] = values.map(resolveIcon);
}
}
return resolved;
};
//# sourceMappingURL=resolve-icons.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/lib/metadata/resolvers/resolve-icons.ts"],"names":["resolveAsArrayOrUndefined","isStringOrURL","IconKeys","resolveIcon","icon","url","Array","isArray","resolveIcons","icons","resolved","apple","map","filter","Boolean","key","values"],"mappings":"AAGA,SAASA,yBAAyB,QAAQ,oBAAmB;AAC7D,SAASC,aAAa,QAAQ,gBAAe;AAC7C,SAASC,QAAQ,QAAQ,eAAc;AAEvC,OAAO,SAASC,YAAYC,IAAU;IACpC,IAAIH,cAAcG,OAAO,OAAO;QAAEC,KAAKD;IAAK;SACvC,IAAIE,MAAMC,OAAO,CAACH,OAAO,OAAOA;IACrC,OAAOA;AACT;AAEA,OAAO,MAAMI,eAAuC,CAACC;IACnD,IAAI,CAACA,OAAO;QACV,OAAO;IACT;IAEA,MAAMC,WAAsC;QAC1CN,MAAM,EAAE;QACRO,OAAO,EAAE;IACX;IACA,IAAIL,MAAMC,OAAO,CAACE,QAAQ;QACxBC,SAASN,IAAI,GAAGK,MAAMG,GAAG,CAACT,aAAaU,MAAM,CAACC;IAChD,OAAO,IAAIb,cAAcQ,QAAQ;QAC/BC,SAASN,IAAI,GAAG;YAACD,YAAYM;SAAO;IACtC,OAAO;QACL,KAAK,MAAMM,OAAOb,SAAU;YAC1B,MAAMc,SAAShB,0BAA0BS,KAAK,CAACM,IAAI;YACnD,IAAIC,QAAQN,QAAQ,CAACK,IAAI,GAAGC,OAAOJ,GAAG,CAACT;QACzC;IACF;IACA,OAAOO;AACT,EAAC"}

View File

@@ -0,0 +1,140 @@
import { resolveAsArrayOrUndefined } from "../generate/utils";
import { getSocialImageFallbackMetadataBase, isStringOrURL, resolveUrl, resolveAbsoluteUrlWithPathname } from "./resolve-url";
import { resolveTitle } from "./resolve-title";
const OgTypeFields = {
article: [
"authors",
"tags"
],
song: [
"albums",
"musicians"
],
playlist: [
"albums",
"musicians"
],
radio: [
"creators"
],
video: [
"actors",
"directors",
"writers",
"tags"
],
basic: [
"emails",
"phoneNumbers",
"faxNumbers",
"alternateLocale",
"audio",
"videos"
]
};
export function resolveImages(images, metadataBase) {
const resolvedImages = resolveAsArrayOrUndefined(images);
if (!resolvedImages) return resolvedImages;
const nonNullableImages = [];
for (const item of resolvedImages){
if (!item) continue;
const isItemUrl = isStringOrURL(item);
const inputUrl = isItemUrl ? item : item.url;
if (!inputUrl) continue;
nonNullableImages.push(isItemUrl ? {
url: resolveUrl(item, metadataBase)
} : {
...item,
// Update image descriptor url
url: resolveUrl(item.url, metadataBase)
});
}
return nonNullableImages;
}
function getFieldsByOgType(ogType) {
switch(ogType){
case "article":
case "book":
return OgTypeFields.article;
case "music.song":
case "music.album":
return OgTypeFields.song;
case "music.playlist":
return OgTypeFields.playlist;
case "music.radio_station":
return OgTypeFields.radio;
case "video.movie":
case "video.episode":
return OgTypeFields.video;
default:
return OgTypeFields.basic;
}
}
export const resolveOpenGraph = (openGraph, metadataBase, { pathname }, titleTemplate)=>{
if (!openGraph) return null;
function resolveProps(target, og) {
const ogType = og && "type" in og ? og.type : undefined;
const keys = getFieldsByOgType(ogType);
for (const k of keys){
const key = k;
if (key in og && key !== "url") {
const value = og[key];
if (value) {
const arrayValue = resolveAsArrayOrUndefined(value);
target[key] = arrayValue;
}
}
}
const imageMetadataBase = getSocialImageFallbackMetadataBase(metadataBase);
target.images = resolveImages(og.images, imageMetadataBase);
}
const resolved = {
...openGraph,
title: resolveTitle(openGraph.title, titleTemplate)
};
resolveProps(resolved, openGraph);
resolved.url = openGraph.url ? resolveAbsoluteUrlWithPathname(openGraph.url, metadataBase, pathname) : null;
return resolved;
};
const TwitterBasicInfoKeys = [
"site",
"siteId",
"creator",
"creatorId",
"description"
];
export const resolveTwitter = (twitter, metadataBase, titleTemplate)=>{
var _resolved_images;
if (!twitter) return null;
let card = "card" in twitter ? twitter.card : undefined;
const resolved = {
...twitter,
title: resolveTitle(twitter.title, titleTemplate)
};
for (const infoKey of TwitterBasicInfoKeys){
resolved[infoKey] = twitter[infoKey] || null;
}
const imageMetadataBase = getSocialImageFallbackMetadataBase(metadataBase);
resolved.images = resolveImages(twitter.images, imageMetadataBase);
card = card || (((_resolved_images = resolved.images) == null ? void 0 : _resolved_images.length) ? "summary_large_image" : "summary");
resolved.card = card;
if ("card" in resolved) {
switch(resolved.card){
case "player":
{
resolved.players = resolveAsArrayOrUndefined(resolved.players) || [];
break;
}
case "app":
{
resolved.app = resolved.app || {};
break;
}
default:
break;
}
}
return resolved;
};
//# sourceMappingURL=resolve-opengraph.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/lib/metadata/resolvers/resolve-opengraph.ts"],"names":["resolveAsArrayOrUndefined","getSocialImageFallbackMetadataBase","isStringOrURL","resolveUrl","resolveAbsoluteUrlWithPathname","resolveTitle","OgTypeFields","article","song","playlist","radio","video","basic","resolveImages","images","metadataBase","resolvedImages","nonNullableImages","item","isItemUrl","inputUrl","url","push","getFieldsByOgType","ogType","resolveOpenGraph","openGraph","pathname","titleTemplate","resolveProps","target","og","type","undefined","keys","k","key","value","arrayValue","imageMetadataBase","resolved","title","TwitterBasicInfoKeys","resolveTwitter","twitter","card","infoKey","length","players","app"],"mappings":"AAWA,SAASA,yBAAyB,QAAQ,oBAAmB;AAC7D,SACEC,kCAAkC,EAClCC,aAAa,EACbC,UAAU,EACVC,8BA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BAAwB,SAAQ;IAC1EP,SAASK,IAAI,GAAGA;IAEhB,IAAI,UAAUL,UAAU;QACtB,OAAQA,SAASK,IAAI;YACnB,KAAK;gBAAU;oBACbL,SAASQ,OAAO,GAAGhD,0BAA0BwC,SAASQ,OAAO,KAAK,EAAE;oBACpE;gBACF;YACA,KAAK;gBAAO;oBACVR,SAASS,GAAG,GAAGT,SAASS,GAAG,IAAI,CAAC;oBAChC;gBACF;YACA;gBACE;QACJ;IACF;IAEA,OAAOT;AACT,EAAC"}

View File

@@ -0,0 +1,30 @@
function resolveTitleTemplate(template, title) {
return template ? template.replace(/%s/g, title) : title;
}
export function resolveTitle(title, stashedTemplate) {
let resolved;
const template = typeof title !== "string" && title && "template" in title ? title.template : null;
if (typeof title === "string") {
resolved = resolveTitleTemplate(stashedTemplate, title);
} else if (title) {
if ("default" in title) {
resolved = resolveTitleTemplate(stashedTemplate, title.default);
}
if ("absolute" in title && title.absolute) {
resolved = title.absolute;
}
}
if (title && typeof title !== "string") {
return {
template,
absolute: resolved || ""
};
} else {
return {
absolute: resolved || title || "",
template
};
}
}
//# sourceMappingURL=resolve-title.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/lib/metadata/resolvers/resolve-title.ts"],"names":["resolveTitleTemplate","template","title","replace","resolveTitle","stashedTemplate","resolved","default","absolute"],"mappings":"AAGA,SAASA,qBACPC,QAAmC,EACnCC,KAAa;IAEb,OAAOD,WAAWA,SAASE,OAAO,CAAC,OAAOD,SAASA;AACrD;AAEA,OAAO,SAASE,aACdF,KAAwB,EACxBG,eAA0C;IAE1C,IAAIC;IACJ,MAAML,WACJ,OAAOC,UAAU,YAAYA,SAAS,cAAcA,QAChDA,MAAMD,QAAQ,GACd;IAEN,IAAI,OAAOC,UAAU,UAAU;QAC7BI,WAAWN,qBAAqBK,iBAAiBH;IACnD,OAAO,IAAIA,OAAO;QAChB,IAAI,aAAaA,OAAO;YACtBI,WAAWN,qBAAqBK,iBAAiBH,MAAMK,OAAO;QAChE;QACA,IAAI,cAAcL,SAASA,MAAMM,QAAQ,EAAE;YACzCF,WAAWJ,MAAMM,QAAQ;QAC3B;IACF;IAEA,IAAIN,SAAS,OAAOA,UAAU,UAAU;QACtC,OAAO;YACLD;YACAO,UAAUF,YAAY;QACxB;IACF,OAAO;QACL,OAAO;YAAEE,UAAUF,YAAYJ,SAAS;YAAID;QAAS;IACvD;AACF"}

View File

@@ -0,0 +1,58 @@
import path from "../../../shared/lib/isomorphic/path";
import * as Log from "../../../build/output/log";
function isStringOrURL(icon) {
return typeof icon === "string" || icon instanceof URL;
}
function createLocalMetadataBase() {
return new URL(`http://localhost:${process.env.PORT || 3000}`);
}
// For deployment url for metadata routes, prefer to use the deployment url if possible
// as these routes are unique to the deployments url.
export function getSocialImageFallbackMetadataBase(metadataBase) {
const isMetadataBaseMissing = !metadataBase;
const defaultMetadataBase = createLocalMetadataBase();
const deploymentUrl = process.env.VERCEL_URL && new URL(`https://${process.env.VERCEL_URL}`);
let fallbackMetadata;
if (process.env.NODE_ENV === "development") {
fallbackMetadata = defaultMetadataBase;
} else {
fallbackMetadata = process.env.NODE_ENV === "production" && deploymentUrl && process.env.VERCEL_ENV === "preview" ? deploymentUrl : metadataBase || deploymentUrl || defaultMetadataBase;
}
if (isMetadataBaseMissing) {
Log.warnOnce("");
Log.warnOnce(`metadata.metadataBase is not set for resolving social open graph or twitter images, using "${fallbackMetadata.origin}". See https://nextjs.org/docs/app/api-reference/functions/generate-metadata#metadatabase`);
}
return fallbackMetadata;
}
function resolveUrl(url, metadataBase) {
if (url instanceof URL) return url;
if (!url) return null;
try {
// If we can construct a URL instance from url, ignore metadataBase
const parsedUrl = new URL(url);
return parsedUrl;
} catch {}
if (!metadataBase) {
metadataBase = createLocalMetadataBase();
}
// Handle relative or absolute paths
const basePath = metadataBase.pathname || "";
const joinedPath = path.join(basePath, url);
return new URL(joinedPath, metadataBase);
}
// Resolve with `pathname` if `url` is a relative path.
function resolveRelativeUrl(url, pathname) {
if (typeof url === "string" && url.startsWith("./")) {
return path.resolve(pathname, url);
}
return url;
}
// Resolve `pathname` if `url` is a relative path the compose with `metadataBase`.
function resolveAbsoluteUrlWithPathname(url, metadataBase, pathname) {
url = resolveRelativeUrl(url, pathname);
const result = metadataBase ? resolveUrl(url, metadataBase) : url;
return result.toString();
}
export { isStringOrURL, resolveUrl, resolveRelativeUrl, resolveAbsoluteUrlWithPathname, };
//# sourceMappingURL=resolve-url.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/lib/metadata/resolvers/resolve-url.ts"],"names":["path","Log","isStringOrURL","icon","URL","createLocalMetadataBase","process","env","PORT","getSocialImageFallbackMetadataBase","metadataBase","isMetadataBaseMissing","defaultMetadataBase","deploymentUrl","VERCEL_URL","fallbackMetadata","NODE_ENV","VERCEL_ENV","warnOnce","origin","resolveUrl","url","parsedUrl","basePath","pathname","joinedPath","join","resolveRelativeUrl","startsWith","resolve","resolveAbsoluteUrlWithPathname","result","toString"],"mappings":"AAAA,OAAOA,UAAU,sCAAqC;AACtD,YAAYC,SAAS,4BAA2B;AAEhD,SAASC,cAAcC,IAAS;IAC9B,OAAO,OAAOA,SAAS,YAAYA,gBAAgBC;AACrD;AAEA,SAASC;IACP,OAAO,IAAID,IAAI,CAAC,iBAAiB,EAAEE,QAAQC,GAAG,CAACC,IAAI,IAAI,KAAK,CAAC;AAC/D;AAEA,uFAAuF;AACvF,qDAAqD;AACrD,OAAO,SAASC,mCACdC,YAAwB;IAExB,MAAMC,wBAAwB,CAACD;IAC/B,MAAME,sBAAsBP;IAC5B,MAAMQ,gBACJP,QAAQC,GAAG,CAACO,UAAU,IAAI,IAAIV,IAAI,CAAC,QAAQ,EAAEE,QAAQC,GAAG,CAACO,UAAU,CAAC,CAAC;IAEvE,IAAIC;IACJ,IAAIT,QAAQC,GAAG,CAACS,QAAQ,KAAK,eAAe;QAC1CD,mBAAmBH;IACrB,OAAO;QACLG,mBACET,QAAQC,GAAG,CAACS,QAAQ,KAAK,gBACzBH,iBACAP,QAAQC,GAAG,CAACU,UAAU,KAAK,YACvBJ,gBACAH,gBAAgBG,iBAAiBD;IACzC;IAEA,IAAID,uBAAuB;QACzBV,IAAIiB,QAAQ,CAAC;QACbjB,IAAIiB,QAAQ,CACV,CAAC,2FAA2F,EAAEH,iBAAiBI,MAAM,CAAC,yFAAyF,CAAC;IAEpN;IAEA,OAAOJ;AACT;AAQA,SAASK,WACPC,GAAoC,EACpCX,YAAwB;IAExB,IAAIW,eAAejB,KAAK,OAAOiB;IAC/B,IAAI,CAACA,KAAK,OAAO;IAEjB,IAAI;QACF,mEAAmE;QACnE,MAAMC,YAAY,IAAIlB,IAAIiB;QAC1B,OAAOC;IACT,EAAE,OAAM,CAAC;IAET,IAAI,CAACZ,cAAc;QACjBA,eAAeL;IACjB;IAEA,oCAAoC;IACpC,MAAMkB,WAAWb,aAAac,QAAQ,IAAI;IAC1C,MAAMC,aAAazB,KAAK0B,IAAI,CAACH,UAAUF;IAEvC,OAAO,IAAIjB,IAAIqB,YAAYf;AAC7B;AAEA,uDAAuD;AACvD,SAASiB,mBAAmBN,GAAiB,EAAEG,QAAgB;IAC7D,IAAI,OAAOH,QAAQ,YAAYA,IAAIO,UAAU,CAAC,OAAO;QACnD,OAAO5B,KAAK6B,OAAO,CAACL,UAAUH;IAChC;IACA,OAAOA;AACT;AAEA,kFAAkF;AAClF,SAASS,+BACPT,GAAiB,EACjBX,YAAwB,EACxBc,QAAgB;IAEhBH,MAAMM,mBAAmBN,KAAKG;IAE9B,MAAMO,SAASrB,eAAeU,WAAWC,KAAKX,gBAAgBW;IAC9D,OAAOU,OAAOC,QAAQ;AACxB;AAEA,SACE9B,aAAa,EACbkB,UAAU,EACVO,kBAAkB,EAClBG,8BAA8B,KAC/B"}

View File

@@ -0,0 +1,4 @@
// Reference: https://hreflang.org/what-is-a-valid-hreflang
export { };
//# sourceMappingURL=alternative-urls-types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/lib/metadata/types/alternative-urls-types.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAE3D,WAucC"}

View File

@@ -0,0 +1,6 @@
// When rendering applink meta tags add a namespace tag before each array instance
// if more than one member exists.
// ref: https://developers.facebook.com/docs/applinks/metadata-reference
export { };
//# sourceMappingURL=extra-types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/lib/metadata/types/extra-types.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,kCAAkC;AAClC,wEAAwE;AAExE,WAmGC"}

View File

@@ -0,0 +1,3 @@
export { };
//# sourceMappingURL=manifest-types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/lib/metadata/types/manifest-types.ts"],"names":[],"mappings":"AAAA,WAmGC"}

View File

@@ -0,0 +1,3 @@
export { };
//# sourceMappingURL=metadata-interface.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/lib/metadata/types/metadata-interface.ts"],"names":[],"mappings":"AAAA,WAmkBuE"}

View File

@@ -0,0 +1,7 @@
/**
*
* Metadata types
*
*/ export { };
//# sourceMappingURL=metadata-types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/lib/metadata/types/metadata-types.ts"],"names":[],"mappings":"AAAA;;;;CAIC,GAED,WAuJC"}

View File

@@ -0,0 +1,3 @@
export { };
//# sourceMappingURL=opengraph-types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/lib/metadata/types/opengraph-types.ts"],"names":[],"mappings":"AAAA,WA0QC"}

View File

@@ -0,0 +1,3 @@
export { };
//# sourceMappingURL=resolvers.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/lib/metadata/types/resolvers.ts"],"names":[],"mappings":"AAAA,WAYC"}

View File

@@ -0,0 +1,4 @@
// Reference: https://developer.twitter.com/en/docs/twitter-for-websites/cards/overview/markup
export { };
//# sourceMappingURL=twitter-types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/lib/metadata/types/twitter-types.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAE9F,WAyF0C"}