@myst-theme/frontmatter 0.1.23 → 0.1.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -22,6 +22,11 @@ export declare function DoiBadge({ doi: possibleLink, className }: {
22
22
  doi?: string;
23
23
  className?: string;
24
24
  }): JSX.Element | null;
25
+ export declare function DateString({ date, format, spacer, }: {
26
+ date?: string;
27
+ format?: Intl.DateTimeFormatOptions;
28
+ spacer?: boolean;
29
+ }): JSX.Element | null;
25
30
  export declare function GitHubLink({ github: possibleLink }: {
26
31
  github?: string;
27
32
  }): JSX.Element | null;
@@ -32,9 +37,10 @@ export declare function Journal({ venue, biblio, }: {
32
37
  venue?: Required<PageFrontmatter>['venue'];
33
38
  biblio?: Required<PageFrontmatter>['biblio'];
34
39
  }): JSX.Element | null;
35
- export declare function FrontmatterBlock({ frontmatter, kind, }: {
40
+ export declare function FrontmatterBlock({ frontmatter, kind, authorStyle, }: {
36
41
  frontmatter: PageFrontmatter;
37
42
  kind?: KINDS;
43
+ authorStyle?: 'block' | 'list';
38
44
  }): JSX.Element;
39
45
  export {};
40
46
  //# sourceMappingURL=FrontmatterBlock.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FrontmatterBlock.d.ts","sourceRoot":"","sources":["../../src/FrontmatterBlock.tsx"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAYxD,aAAK,KAAK;IACR,OAAO,YAAY;IACnB,QAAQ,aAAa;CACtB;AAoBD,wBAAgB,MAAM,CAAC,EACrB,MAAM,EACN,SAAS,GACV,EAAE;IACD,MAAM,EAAE,QAAQ,CAAC,eAAe,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,eA4BA;AAED,wBAAgB,WAAW,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,eAAe,CAAC,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P,EAAE;IACD,KAAK,CAAC,EAAE,QAAQ,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,CAAC;IAC3C,MAAM,CAAC,EAAE,QAAQ,CAAC,eAAe,CAAC,CAAC,QAAQ,CAAC,CAAC;CAC9C,sBA0BA;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,WAAW,EACX,IAAoB,EACpB,WAAqB,GACtB,EAAE;IACD,WAAW,EAAE,eAAe,CAAC;IAC7B,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,WAAW,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CAChC,eA+CA"}
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.FrontmatterBlock = exports.Journal = exports.OpenAccessBadge = exports.GitHubLink = exports.DoiBadge = exports.DoiText = exports.AuthorAndAffiliations = exports.AuthorsList = exports.Author = void 0;
6
+ exports.FrontmatterBlock = exports.Journal = exports.OpenAccessBadge = exports.GitHubLink = exports.DateString = exports.DoiBadge = exports.DoiText = exports.AuthorAndAffiliations = exports.AuthorsList = exports.Author = void 0;
7
7
  const jsx_runtime_1 = require("react/jsx-runtime");
8
8
  const react_1 = __importDefault(require("react"));
9
9
  const classnames_1 = __importDefault(require("classnames"));
@@ -25,9 +25,9 @@ exports.Author = Author;
25
25
  function AuthorsList({ authors }) {
26
26
  if (!authors || authors.length === 0)
27
27
  return null;
28
- return ((0, jsx_runtime_1.jsx)("div", { children: authors.map((a, i) => ((0, jsx_runtime_1.jsx)("span", Object.assign({ className: 'mr-2' }, { children: (0, jsx_runtime_1.jsx)(Author, { author: a, className: (0, classnames_1.default)('inline-block', {
29
- "after:content-[','] after:mr-1": i < authors.length - 1,
30
- }) }) }), a.name))) }));
28
+ return ((0, jsx_runtime_1.jsx)("div", { children: authors.map((a, i) => ((0, jsx_runtime_1.jsx)("span", { children: (0, jsx_runtime_1.jsx)(Author, { author: a, className: (0, classnames_1.default)('inline-block', {
29
+ 'text-comma': i < authors.length - 1,
30
+ }) }) }, a.name))) }));
31
31
  }
32
32
  exports.AuthorsList = AuthorsList;
33
33
  function AuthorAndAffiliations({ authors }) {
@@ -65,20 +65,31 @@ function DoiBadge({ doi: possibleLink, className }) {
65
65
  return null;
66
66
  const doi = possibleLink.replace(/^(https?:\/\/)?(dx\.)?doi\.org\//, '');
67
67
  const url = `https://doi.org/${doi}`;
68
- return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: (0, classnames_1.default)('flex-none pl-1', className), title: "DOI (Digital Object Identifier)" }, { children: ["DOI:", (0, jsx_runtime_1.jsx)("a", Object.assign({ className: "font-light no-underline pl-1", target: "_blank", rel: "noopener noreferrer", href: url }, { children: doi }))] })));
68
+ return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: (0, classnames_1.default)('flex-none', className), title: "DOI (Digital Object Identifier)" }, { children: (0, jsx_runtime_1.jsx)("a", Object.assign({ className: "font-light no-underline", target: "_blank", rel: "noopener noreferrer", href: url }, { children: url })) })));
69
69
  }
70
70
  exports.DoiBadge = DoiBadge;
71
+ function DateString({ date, format = {
72
+ year: 'numeric',
73
+ month: 'long',
74
+ day: 'numeric',
75
+ }, spacer, }) {
76
+ if (!date)
77
+ return null;
78
+ const dateString = new Date(date).toLocaleDateString('en-US', format);
79
+ return ((0, jsx_runtime_1.jsx)("time", Object.assign({ dateTime: date, className: (0, classnames_1.default)({ 'text-spacer': spacer }) }, { children: dateString })));
80
+ }
81
+ exports.DateString = DateString;
71
82
  function GitHubLink({ github: possibleLink }) {
72
83
  if (!possibleLink)
73
84
  return null;
74
85
  const github = possibleLink.replace(/^(https?:\/\/)?github\.com\//, '');
75
- return ((0, jsx_runtime_1.jsx)("a", Object.assign({ href: `https://github.com/${github}`, title: `GitHub Repository: ${github}`, target: "_blank", rel: "noopener noreferrer" }, { children: (0, jsx_runtime_1.jsx)(solid_1.GithubIcon, { className: "w-5 h-5 opacity-60 hover:opacity-100" }) })));
86
+ return ((0, jsx_runtime_1.jsx)("a", Object.assign({ href: `https://github.com/${github}`, title: `GitHub Repository: ${github}`, target: "_blank", rel: "noopener noreferrer" }, { children: (0, jsx_runtime_1.jsx)(solid_1.GithubIcon, { className: "w-5 h-5 mr-1 inline-block opacity-60 hover:opacity-100" }) })));
76
87
  }
77
88
  exports.GitHubLink = GitHubLink;
78
89
  function OpenAccessBadge({ open_access }) {
79
90
  if (!open_access)
80
91
  return null;
81
- return ((0, jsx_runtime_1.jsx)("a", Object.assign({ className: "opacity-60 hover:opacity-100", href: "https://en.wikipedia.org/wiki/Open_access", target: "_blank", rel: "noopener noreferrer", title: "Open Access" }, { children: (0, jsx_runtime_1.jsx)(solid_1.OpenAccessIcon, { className: "w-5 h-5" }) })));
92
+ return ((0, jsx_runtime_1.jsx)("a", Object.assign({ href: "https://en.wikipedia.org/wiki/Open_access", target: "_blank", rel: "noopener noreferrer", title: "Open Access" }, { children: (0, jsx_runtime_1.jsx)(solid_1.OpenAccessIcon, { className: "w-5 h-5 mr-1 inline-block opacity-60 hover:opacity-100 hover:text-[#E18435]" }) })));
82
93
  }
83
94
  exports.OpenAccessBadge = OpenAccessBadge;
84
95
  function Journal({ venue, biblio, }) {
@@ -91,12 +102,14 @@ function Journal({ venue, biblio, }) {
91
102
  return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "flex-none mr-2" }, { children: [url ? ((0, jsx_runtime_1.jsx)(ExternalOrInternalLink, Object.assign({ className: "smallcaps font-semibold no-underline", to: url, title: title }, { children: title }))) : ((0, jsx_runtime_1.jsx)("span", Object.assign({ className: "smallcaps font-semibold" }, { children: title }))), volume != null && ((0, jsx_runtime_1.jsxs)("span", Object.assign({ className: "ml-2 pl-2 border-l" }, { children: ["Volume ", volume, issue != null && (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [", Issue ", issue] })] })))] })));
92
103
  }
93
104
  exports.Journal = Journal;
94
- function FrontmatterBlock({ frontmatter, kind = KINDS.Article, }) {
95
- const { subject, doi, open_access, license, github, venue, biblio, exports } = frontmatter;
96
- const hasHeaders = subject || github || venue || biblio;
97
- const hasLicenses = doi || open_access || license;
105
+ function FrontmatterBlock({ frontmatter, kind = KINDS.Article, authorStyle = 'block', }) {
106
+ const { subject, doi, open_access, license, github, venue, biblio, exports, date } = frontmatter;
107
+ const isJupyter = kind === KINDS.Notebook;
108
+ const hasExports = exports && exports.length > 0;
109
+ const hasHeaders = subject || github || venue || biblio || open_access || license || hasExports || isJupyter;
110
+ const hasDateOrDoi = doi || date;
98
111
  return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [hasHeaders && ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "flex mt-3 mb-5 text-sm font-light" }, { children: [subject && ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: (0, classnames_1.default)('flex-none pr-2 smallcaps', {
99
112
  'border-r mr-2': venue,
100
- }) }, { children: subject }))), (0, jsx_runtime_1.jsx)(Journal, { venue: venue, biblio: biblio }), (0, jsx_runtime_1.jsx)("div", { className: "flex-grow" }), kind === KINDS.Notebook && (0, jsx_runtime_1.jsx)(solid_1.JupyterIcon, { className: "h-5 w-5" }), (0, jsx_runtime_1.jsx)(GitHubLink, { github: github }), (0, jsx_runtime_1.jsx)(downloads_1.DownloadsDropdown, { exports: exports })] }))), (0, jsx_runtime_1.jsx)("h1", Object.assign({ className: (0, classnames_1.default)('title', { 'mb-2': frontmatter.subtitle }) }, { children: frontmatter.title })), frontmatter.subtitle && ((0, jsx_runtime_1.jsx)("h2", Object.assign({ className: "title mt-0 text-zinc-600 dark:text-zinc-400" }, { children: frontmatter.subtitle }))), hasLicenses && ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "flex mt-3 mb-5 text-sm font-light" }, { children: [(0, jsx_runtime_1.jsx)(licenses_1.LicenseBadges, { license: license }), (0, jsx_runtime_1.jsx)(OpenAccessBadge, { open_access: open_access }), (0, jsx_runtime_1.jsx)(DoiBadge, { doi: doi })] }))), (0, jsx_runtime_1.jsx)(AuthorAndAffiliations, { authors: frontmatter.authors })] }));
113
+ }) }, { children: subject }))), (0, jsx_runtime_1.jsx)(Journal, { venue: venue, biblio: biblio }), (0, jsx_runtime_1.jsx)("div", { className: "flex-grow" }), (0, jsx_runtime_1.jsx)(licenses_1.LicenseBadges, { license: license }), (0, jsx_runtime_1.jsx)(OpenAccessBadge, { open_access: open_access }), (0, jsx_runtime_1.jsx)(GitHubLink, { github: github }), isJupyter && ((0, jsx_runtime_1.jsx)("span", { children: (0, jsx_runtime_1.jsx)(solid_1.JupyterIcon, { className: "h-5 w-5 inline-block" }) })), (0, jsx_runtime_1.jsx)(downloads_1.DownloadsDropdown, { exports: exports })] }))), (0, jsx_runtime_1.jsx)("h1", Object.assign({ className: (0, classnames_1.default)('title', { 'mb-2': frontmatter.subtitle }) }, { children: frontmatter.title })), frontmatter.subtitle && ((0, jsx_runtime_1.jsx)("h2", Object.assign({ className: "title mt-0 text-zinc-600 dark:text-zinc-400" }, { children: frontmatter.subtitle }))), authorStyle === 'list' && (0, jsx_runtime_1.jsx)(AuthorsList, { authors: frontmatter.authors }), authorStyle === 'block' && (0, jsx_runtime_1.jsx)(AuthorAndAffiliations, { authors: frontmatter.authors }), hasDateOrDoi && ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: "flex my-6 text-sm font-light" }, { children: [(0, jsx_runtime_1.jsx)(DateString, { date: date, spacer: !!doi }), (0, jsx_runtime_1.jsx)(DoiBadge, { doi: doi })] })))] }));
101
114
  }
102
115
  exports.FrontmatterBlock = FrontmatterBlock;
@@ -30,7 +30,7 @@ function SingleLicenseBadge({ license: possibleLicense, preamble = '', className
30
30
  if (license.CC) {
31
31
  return (0, jsx_runtime_1.jsx)(CreativeCommonsBadge, { license: license, preamble: preamble, className: className });
32
32
  }
33
- return ((0, jsx_runtime_1.jsxs)("a", Object.assign({ href: license.url || undefined, target: "_blank", rel: "noopener noreferrer", title: `${preamble}${(_a = license.name) !== null && _a !== void 0 ? _a : license.title} (${license.id})` }, { children: [!license.osi && ((0, jsx_runtime_1.jsx)(outline_1.ScaleIcon, { className: (0, classnames_1.default)('h-5 w-5 mx-1 inline-block opacity-60 hover:opacity-100', className) })), license.osi && ((0, jsx_runtime_1.jsx)(solid_1.OsiIcon, { className: (0, classnames_1.default)('h-5 w-5 mx-1 inline-block opacity-60 hover:opacity-100', className) }))] })));
33
+ return ((0, jsx_runtime_1.jsxs)("a", Object.assign({ href: license.url || undefined, target: "_blank", rel: "noopener noreferrer", title: `${preamble}${(_a = license.name) !== null && _a !== void 0 ? _a : license.title} (${license.id})` }, { children: [!license.osi && ((0, jsx_runtime_1.jsx)(outline_1.ScaleIcon, { className: (0, classnames_1.default)('h-5 w-5 mx-1 inline-block opacity-60 hover:opacity-100', className) })), license.osi && ((0, jsx_runtime_1.jsx)(solid_1.OsiIcon, { className: (0, classnames_1.default)('h-5 w-5 mx-1 inline-block opacity-60 hover:opacity-100 hover:text-[#599F46]', className) }))] })));
34
34
  }
35
35
  function LicenseBadges({ license, className, }) {
36
36
  if (!license)
@@ -22,6 +22,11 @@ export declare function DoiBadge({ doi: possibleLink, className }: {
22
22
  doi?: string;
23
23
  className?: string;
24
24
  }): JSX.Element | null;
25
+ export declare function DateString({ date, format, spacer, }: {
26
+ date?: string;
27
+ format?: Intl.DateTimeFormatOptions;
28
+ spacer?: boolean;
29
+ }): JSX.Element | null;
25
30
  export declare function GitHubLink({ github: possibleLink }: {
26
31
  github?: string;
27
32
  }): JSX.Element | null;
@@ -32,9 +37,10 @@ export declare function Journal({ venue, biblio, }: {
32
37
  venue?: Required<PageFrontmatter>['venue'];
33
38
  biblio?: Required<PageFrontmatter>['biblio'];
34
39
  }): JSX.Element | null;
35
- export declare function FrontmatterBlock({ frontmatter, kind, }: {
40
+ export declare function FrontmatterBlock({ frontmatter, kind, authorStyle, }: {
36
41
  frontmatter: PageFrontmatter;
37
42
  kind?: KINDS;
43
+ authorStyle?: 'block' | 'list';
38
44
  }): JSX.Element;
39
45
  export {};
40
46
  //# sourceMappingURL=FrontmatterBlock.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FrontmatterBlock.d.ts","sourceRoot":"","sources":["../../src/FrontmatterBlock.tsx"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAYxD,aAAK,KAAK;IACR,OAAO,YAAY;IACnB,QAAQ,aAAa;CACtB;AAoBD,wBAAgB,MAAM,CAAC,EACrB,MAAM,EACN,SAAS,GACV,EAAE;IACD,MAAM,EAAE,QAAQ,CAAC,eAAe,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,eA4BA;AAED,wBAAgB,WAAW,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,eAAe,CAAC,SAAS,CAAC,CAAA;CAAE,sBAgB/E;AAED,wBAAgB,qBAAqB,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,eAAe,CAAC,SAAS,CAAC,CAAA;CAAE,sBA8DzF;AAED,wBAAgB,OAAO,CAAC,EAAE,GAAG,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,sBAe7F;AAED,wBAAgB,QAAQ,CAAC,EAAE,GAAG,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,sBAoB9F;AAED,wBAAgB,UAAU,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,sBAavE;AAED,wBAAgB,eAAe,CAAC,EAAE,WAAW,EAAE,EAAE;IAA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E,GAAG,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,sBAW9F;AAED,wBAAgB,UAAU,CAAC,EACzB,IAAI,EACJ,MAIC,EACD,MAAM,GACP,EAAE;IACD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,IAAI,CAAC,qBAAqB,CAAC;IACpC,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,sBAQA;AAED,wBAAgB,UAAU,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,sBAavE;AAED,wBAAgB,eAAe,CAAC,EAAE,WAAW,EAAE,EAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE,sBAYzE;AAED,wBAAgB,OAAO,CAAC,EACtB,KAAK,EACL,MAAM,GACP,EAAE;IACD,KAAK,CAAC,EAAE,QAAQ,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,CAAC;IAC3C,MAAM,CAAC,EAAE,QAAQ,CAAC,eAAe,CAAC,CAAC,QAAQ,CAAC,CAAC;CAC9C,sBA0BA;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,WAAW,EACX,IAAoB,EACpB,WAAqB,GACtB,EAAE;IACD,WAAW,EAAE,eAAe,CAAC;IAC7B,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,WAAW,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CAChC,eA+CA"}
@@ -18,9 +18,9 @@ export function Author({ author, className, }) {
18
18
  export function AuthorsList({ authors }) {
19
19
  if (!authors || authors.length === 0)
20
20
  return null;
21
- return (_jsx("div", { children: authors.map((a, i) => (_jsx("span", Object.assign({ className: 'mr-2' }, { children: _jsx(Author, { author: a, className: classNames('inline-block', {
22
- "after:content-[','] after:mr-1": i < authors.length - 1,
23
- }) }) }), a.name))) }));
21
+ return (_jsx("div", { children: authors.map((a, i) => (_jsx("span", { children: _jsx(Author, { author: a, className: classNames('inline-block', {
22
+ 'text-comma': i < authors.length - 1,
23
+ }) }) }, a.name))) }));
24
24
  }
25
25
  export function AuthorAndAffiliations({ authors }) {
26
26
  if (!authors || authors.length === 0)
@@ -55,18 +55,28 @@ export function DoiBadge({ doi: possibleLink, className }) {
55
55
  return null;
56
56
  const doi = possibleLink.replace(/^(https?:\/\/)?(dx\.)?doi\.org\//, '');
57
57
  const url = `https://doi.org/${doi}`;
58
- return (_jsxs("div", Object.assign({ className: classNames('flex-none pl-1', className), title: "DOI (Digital Object Identifier)" }, { children: ["DOI:", _jsx("a", Object.assign({ className: "font-light no-underline pl-1", target: "_blank", rel: "noopener noreferrer", href: url }, { children: doi }))] })));
58
+ return (_jsx("div", Object.assign({ className: classNames('flex-none', className), title: "DOI (Digital Object Identifier)" }, { children: _jsx("a", Object.assign({ className: "font-light no-underline", target: "_blank", rel: "noopener noreferrer", href: url }, { children: url })) })));
59
+ }
60
+ export function DateString({ date, format = {
61
+ year: 'numeric',
62
+ month: 'long',
63
+ day: 'numeric',
64
+ }, spacer, }) {
65
+ if (!date)
66
+ return null;
67
+ const dateString = new Date(date).toLocaleDateString('en-US', format);
68
+ return (_jsx("time", Object.assign({ dateTime: date, className: classNames({ 'text-spacer': spacer }) }, { children: dateString })));
59
69
  }
60
70
  export function GitHubLink({ github: possibleLink }) {
61
71
  if (!possibleLink)
62
72
  return null;
63
73
  const github = possibleLink.replace(/^(https?:\/\/)?github\.com\//, '');
64
- return (_jsx("a", Object.assign({ href: `https://github.com/${github}`, title: `GitHub Repository: ${github}`, target: "_blank", rel: "noopener noreferrer" }, { children: _jsx(GithubIcon, { className: "w-5 h-5 opacity-60 hover:opacity-100" }) })));
74
+ return (_jsx("a", Object.assign({ href: `https://github.com/${github}`, title: `GitHub Repository: ${github}`, target: "_blank", rel: "noopener noreferrer" }, { children: _jsx(GithubIcon, { className: "w-5 h-5 mr-1 inline-block opacity-60 hover:opacity-100" }) })));
65
75
  }
66
76
  export function OpenAccessBadge({ open_access }) {
67
77
  if (!open_access)
68
78
  return null;
69
- return (_jsx("a", Object.assign({ className: "opacity-60 hover:opacity-100", href: "https://en.wikipedia.org/wiki/Open_access", target: "_blank", rel: "noopener noreferrer", title: "Open Access" }, { children: _jsx(OpenAccessIcon, { className: "w-5 h-5" }) })));
79
+ return (_jsx("a", Object.assign({ href: "https://en.wikipedia.org/wiki/Open_access", target: "_blank", rel: "noopener noreferrer", title: "Open Access" }, { children: _jsx(OpenAccessIcon, { className: "w-5 h-5 mr-1 inline-block opacity-60 hover:opacity-100 hover:text-[#E18435]" }) })));
70
80
  }
71
81
  export function Journal({ venue, biblio, }) {
72
82
  if (!venue)
@@ -77,11 +87,13 @@ export function Journal({ venue, biblio, }) {
77
87
  const { volume, issue } = biblio !== null && biblio !== void 0 ? biblio : {};
78
88
  return (_jsxs("div", Object.assign({ className: "flex-none mr-2" }, { children: [url ? (_jsx(ExternalOrInternalLink, Object.assign({ className: "smallcaps font-semibold no-underline", to: url, title: title }, { children: title }))) : (_jsx("span", Object.assign({ className: "smallcaps font-semibold" }, { children: title }))), volume != null && (_jsxs("span", Object.assign({ className: "ml-2 pl-2 border-l" }, { children: ["Volume ", volume, issue != null && _jsxs(_Fragment, { children: [", Issue ", issue] })] })))] })));
79
89
  }
80
- export function FrontmatterBlock({ frontmatter, kind = KINDS.Article, }) {
81
- const { subject, doi, open_access, license, github, venue, biblio, exports } = frontmatter;
82
- const hasHeaders = subject || github || venue || biblio;
83
- const hasLicenses = doi || open_access || license;
90
+ export function FrontmatterBlock({ frontmatter, kind = KINDS.Article, authorStyle = 'block', }) {
91
+ const { subject, doi, open_access, license, github, venue, biblio, exports, date } = frontmatter;
92
+ const isJupyter = kind === KINDS.Notebook;
93
+ const hasExports = exports && exports.length > 0;
94
+ const hasHeaders = subject || github || venue || biblio || open_access || license || hasExports || isJupyter;
95
+ const hasDateOrDoi = doi || date;
84
96
  return (_jsxs(_Fragment, { children: [hasHeaders && (_jsxs("div", Object.assign({ className: "flex mt-3 mb-5 text-sm font-light" }, { children: [subject && (_jsx("div", Object.assign({ className: classNames('flex-none pr-2 smallcaps', {
85
97
  'border-r mr-2': venue,
86
- }) }, { children: subject }))), _jsx(Journal, { venue: venue, biblio: biblio }), _jsx("div", { className: "flex-grow" }), kind === KINDS.Notebook && _jsx(JupyterIcon, { className: "h-5 w-5" }), _jsx(GitHubLink, { github: github }), _jsx(DownloadsDropdown, { exports: exports })] }))), _jsx("h1", Object.assign({ className: classNames('title', { 'mb-2': frontmatter.subtitle }) }, { children: frontmatter.title })), frontmatter.subtitle && (_jsx("h2", Object.assign({ className: "title mt-0 text-zinc-600 dark:text-zinc-400" }, { children: frontmatter.subtitle }))), hasLicenses && (_jsxs("div", Object.assign({ className: "flex mt-3 mb-5 text-sm font-light" }, { children: [_jsx(LicenseBadges, { license: license }), _jsx(OpenAccessBadge, { open_access: open_access }), _jsx(DoiBadge, { doi: doi })] }))), _jsx(AuthorAndAffiliations, { authors: frontmatter.authors })] }));
98
+ }) }, { children: subject }))), _jsx(Journal, { venue: venue, biblio: biblio }), _jsx("div", { className: "flex-grow" }), _jsx(LicenseBadges, { license: license }), _jsx(OpenAccessBadge, { open_access: open_access }), _jsx(GitHubLink, { github: github }), isJupyter && (_jsx("span", { children: _jsx(JupyterIcon, { className: "h-5 w-5 inline-block" }) })), _jsx(DownloadsDropdown, { exports: exports })] }))), _jsx("h1", Object.assign({ className: classNames('title', { 'mb-2': frontmatter.subtitle }) }, { children: frontmatter.title })), frontmatter.subtitle && (_jsx("h2", Object.assign({ className: "title mt-0 text-zinc-600 dark:text-zinc-400" }, { children: frontmatter.subtitle }))), authorStyle === 'list' && _jsx(AuthorsList, { authors: frontmatter.authors }), authorStyle === 'block' && _jsx(AuthorAndAffiliations, { authors: frontmatter.authors }), hasDateOrDoi && (_jsxs("div", Object.assign({ className: "flex my-6 text-sm font-light" }, { children: [_jsx(DateString, { date: date, spacer: !!doi }), _jsx(DoiBadge, { doi: doi })] })))] }));
87
99
  }
@@ -23,7 +23,7 @@ function SingleLicenseBadge({ license: possibleLicense, preamble = '', className
23
23
  if (license.CC) {
24
24
  return _jsx(CreativeCommonsBadge, { license: license, preamble: preamble, className: className });
25
25
  }
26
- return (_jsxs("a", Object.assign({ href: license.url || undefined, target: "_blank", rel: "noopener noreferrer", title: `${preamble}${(_a = license.name) !== null && _a !== void 0 ? _a : license.title} (${license.id})` }, { children: [!license.osi && (_jsx(ScaleIcon, { className: classNames('h-5 w-5 mx-1 inline-block opacity-60 hover:opacity-100', className) })), license.osi && (_jsx(OsiIcon, { className: classNames('h-5 w-5 mx-1 inline-block opacity-60 hover:opacity-100', className) }))] })));
26
+ return (_jsxs("a", Object.assign({ href: license.url || undefined, target: "_blank", rel: "noopener noreferrer", title: `${preamble}${(_a = license.name) !== null && _a !== void 0 ? _a : license.title} (${license.id})` }, { children: [!license.osi && (_jsx(ScaleIcon, { className: classNames('h-5 w-5 mx-1 inline-block opacity-60 hover:opacity-100', className) })), license.osi && (_jsx(OsiIcon, { className: classNames('h-5 w-5 mx-1 inline-block opacity-60 hover:opacity-100 hover:text-[#599F46]', className) }))] })));
27
27
  }
28
28
  export function LicenseBadges({ license, className, }) {
29
29
  if (!license)
@@ -22,6 +22,11 @@ export declare function DoiBadge({ doi: possibleLink, className }: {
22
22
  doi?: string;
23
23
  className?: string;
24
24
  }): JSX.Element | null;
25
+ export declare function DateString({ date, format, spacer, }: {
26
+ date?: string;
27
+ format?: Intl.DateTimeFormatOptions;
28
+ spacer?: boolean;
29
+ }): JSX.Element | null;
25
30
  export declare function GitHubLink({ github: possibleLink }: {
26
31
  github?: string;
27
32
  }): JSX.Element | null;
@@ -32,9 +37,10 @@ export declare function Journal({ venue, biblio, }: {
32
37
  venue?: Required<PageFrontmatter>['venue'];
33
38
  biblio?: Required<PageFrontmatter>['biblio'];
34
39
  }): JSX.Element | null;
35
- export declare function FrontmatterBlock({ frontmatter, kind, }: {
40
+ export declare function FrontmatterBlock({ frontmatter, kind, authorStyle, }: {
36
41
  frontmatter: PageFrontmatter;
37
42
  kind?: KINDS;
43
+ authorStyle?: 'block' | 'list';
38
44
  }): JSX.Element;
39
45
  export {};
40
46
  //# sourceMappingURL=FrontmatterBlock.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FrontmatterBlock.d.ts","sourceRoot":"","sources":["../../src/FrontmatterBlock.tsx"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAYxD,aAAK,KAAK;IACR,OAAO,YAAY;IACnB,QAAQ,aAAa;CACtB;AAoBD,wBAAgB,MAAM,CAAC,EACrB,MAAM,EACN,SAAS,GACV,EAAE;IACD,MAAM,EAAE,QAAQ,CAAC,eAAe,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,eA4BA;AAED,wBAAgB,WAAW,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,eAAe,CAAC,SAAS,CAAC,CAAA;CAAE,sBAgB/E;AAED,wBAAgB,qBAAqB,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,eAAe,CAAC,SAAS,CAAC,CAAA;CAAE,sBA8DzF;AAED,wBAAgB,OAAO,CAAC,EAAE,GAAG,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,sBAe7F;AAED,wBAAgB,QAAQ,CAAC,EAAE,GAAG,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,sBAoB9F;AAED,wBAAgB,UAAU,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE;IAAE,MAAM,CAAC,EA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;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,sBAe7F;AAED,wBAAgB,QAAQ,CAAC,EAAE,GAAG,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,sBAW9F;AAED,wBAAgB,UAAU,CAAC,EACzB,IAAI,EACJ,MAIC,EACD,MAAM,GACP,EAAE;IACD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,IAAI,CAAC,qBAAqB,CAAC;IACpC,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,sBAQA;AAED,wBAAgB,UAAU,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,sBAavE;AAED,wBAAgB,eAAe,CAAC,EAAE,WAAW,EAAE,EAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE,sBAYzE;AAED,wBAAgB,OAAO,CAAC,EACtB,KAAK,EACL,MAAM,GACP,EAAE;IACD,KAAK,CAAC,EAAE,QAAQ,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,CAAC;IAC3C,MAAM,CAAC,EAAE,QAAQ,CAAC,eAAe,CAAC,CAAC,QAAQ,CAAC,CAAC;CAC9C,sBA0BA;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,WAAW,EACX,IAAoB,EACpB,WAAqB,GACtB,EAAE;IACD,WAAW,EAAE,eAAe,CAAC;IAC7B,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,WAAW,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CAChC,eA+CA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myst-theme/frontmatter",
3
- "version": "0.1.23",
3
+ "version": "0.1.25",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",