Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanc1 authored Oct 18, 2024
1 parent 3491890 commit a2e58e5
Show file tree
Hide file tree
Showing 17 changed files with 347 additions and 345 deletions.
5 changes: 5 additions & 0 deletions .changeset/nine-bats-clean.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@myst-theme/common': patch
---

Expose PageFrontmatterWithDownloads
13 changes: 13 additions & 0 deletions .changeset/sweet-kangaroos-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
'myst-to-react': patch
'@myst-theme/frontmatter': patch
'myst-demo': patch
'@myst-theme/providers': patch
'@myst-theme/jupyter': patch
'@myst-theme/common': patch
'@myst-theme/article': patch
'@myst-theme/site': patch
'@myst-theme/book': patch
---

Update to mystmd 1.3.13
549 changes: 261 additions & 288 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
"build": "npm-run-all -l clean -p build:esm"
},
"dependencies": {
"myst-common": "^1.7.0",
"myst-config": "^1.7.0",
"myst-spec-ext": "^1.7.0",
"myst-common": "^1.7.2",
"myst-config": "^1.7.2",
"myst-spec-ext": "^1.7.2",
"nbtx": "^0.2.3",
"unist-util-select": "^4.0.3"
}
Expand Down
5 changes: 4 additions & 1 deletion packages/common/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ export type FooterLinks = {
};
};

type PageFrontmatterWithDownloads = Omit<PageFrontmatter, 'parts' | 'downloads' | 'exports'> & {
export type PageFrontmatterWithDownloads = Omit<
PageFrontmatter,
'parts' | 'downloads' | 'exports'
> & {
parts?: Record<string, { frontmatter?: PageFrontmatter; mdast: GenericParent }>;
downloads?: SiteAction[];
exports?: SiteExport[];
Expand Down
18 changes: 10 additions & 8 deletions packages/frontmatter/src/FrontmatterBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,18 @@ export function OpenAccessBadge({ open_access }: { open_access?: boolean }) {

export function Journal({
venue,
biblio,
volume,
issue,
className,
}: {
venue?: Required<PageFrontmatter>['venue'];
biblio?: Required<PageFrontmatter>['biblio'];
volume?: Required<PageFrontmatter>['volume'];
issue?: Required<PageFrontmatter>['issue'];
className?: string;
}) {
if (!venue) return null;
const { title, url } = typeof venue === 'string' ? { title: venue, url: null } : venue;
if (!title) return null;
const { volume, issue } = biblio ?? {};
return (
<div className={classNames('flex-none mr-2', className)}>
{url ? (
Expand All @@ -178,8 +179,8 @@ export function Journal({
)}
{volume != null && (
<span className="pl-2 ml-2 border-l">
Volume {volume}
{issue != null && <>, Issue {issue}</>}
Volume {volume.title}
{issue != null && <>, Issue {issue.title}</>}
</span>
)}
</div>
Expand Down Expand Up @@ -211,7 +212,8 @@ export function FrontmatterBlock({
license,
github,
venue,
biblio,
volume,
issue,
exports,
downloads,
date,
Expand All @@ -221,7 +223,7 @@ export function FrontmatterBlock({
const hasExports = downloads ? downloads.length > 0 : exports && exports.length > 0;
const hasAuthors = authors && authors.length > 0;
const hasBadges = !!open_access || !!license || !!hasExports || !!isJupyter || !!github;
const hasHeaders = !!subject || !!venue || !!biblio;
const hasHeaders = !!subject || !!venue || !!volume || !!issue;
const hasDateOrDoi = !!doi || !!date;
const showHeaderBlock = hasHeaders || (hasBadges && !hideBadges) || (hasExports && !hideExports);
if (!title && !subtitle && !showHeaderBlock && !hasAuthors && !hasDateOrDoi) {
Expand All @@ -245,7 +247,7 @@ export function FrontmatterBlock({
{subject}
</div>
)}
<Journal venue={venue} biblio={biblio} />
<Journal venue={venue} volume={volume} issue={issue} />
<div className="flex-grow"></div>
{!hideBadges && (
<>
Expand Down
7 changes: 4 additions & 3 deletions packages/frontmatter/src/licenses.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import { ScaleIcon } from '@heroicons/react/24/outline';
import classNames from 'classnames';

type License = {
name: string;
url: string;
id: string;
id?: string;
name?: string;
url?: string;
free?: boolean;
CC?: boolean;
osi?: boolean;
Expand All @@ -28,6 +28,7 @@ export function CreativeCommonsBadge({
preamble?: string;
className?: string;
}) {
if (!license.id) return null;
const match = /^([CBYSAND0-]+)(?:(?:-)([0-9].[0-9]))?$/.exec(license.id);
if (!license.CC || !match) return null;
const title = `${preamble}${license.name ?? (license as any).title} (${license.id})`;
Expand Down
8 changes: 4 additions & 4 deletions packages/jupyter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
"buffer": "^6.0.3",
"classnames": "^2.5.1",
"jupyterlab-plotly": "^5.24.0",
"myst-common": "^1.7.0",
"myst-config": "^1.6.0",
"myst-frontmatter": "^1.7.0",
"myst-common": "^1.7.2",
"myst-config": "^1.7.2",
"myst-frontmatter": "^1.7.2",
"myst-spec": "^0.0.5",
"myst-spec-ext": "^1.7.0",
"myst-spec-ext": "^1.7.2",
"myst-to-react": "^0.13.1",
"nanoid": "^4.0.2",
"nbtx": "^0.2.3",
Expand Down
32 changes: 16 additions & 16 deletions packages/myst-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,24 @@
"@heroicons/react": "^2.0.18",
"classnames": "^2.3.2",
"js-yaml": "^4.1.0",
"myst-common": "^1.7.0",
"myst-config": "^1.5.0",
"myst-directives": "^1.5.6",
"myst-ext-card": "^1.0.8",
"myst-ext-exercise": "^1.0.7",
"myst-ext-grid": "^1.0.7",
"myst-ext-proof": "^1.0.10",
"myst-ext-tabs": "^1.0.7",
"myst-frontmatter": "^1.7.0",
"myst-parser": "^1.5.6",
"myst-common": "^1.7.2",
"myst-config": "^1.7.2",
"myst-directives": "^1.5.7",
"myst-ext-card": "^1.0.9",
"myst-ext-exercise": "^1.0.8",
"myst-ext-grid": "^1.0.8",
"myst-ext-proof": "^1.0.11",
"myst-ext-tabs": "^1.0.8",
"myst-frontmatter": "^1.7.2",
"myst-parser": "^1.5.7",
"myst-spec": "^0.0.5",
"myst-to-docx": "^1.0.11",
"myst-to-html": "^1.5.6",
"myst-to-jats": "^1.0.27",
"myst-to-docx": "^1.0.12",
"myst-to-html": "^1.5.7",
"myst-to-jats": "^1.0.30",
"myst-to-react": "^0.13.1",
"myst-to-tex": "^1.0.37",
"myst-to-typst": "^0.0.22",
"myst-transforms": "^1.3.25",
"myst-to-tex": "^1.0.38",
"myst-to-typst": "^0.0.24",
"myst-transforms": "^1.3.26",
"unified": "^10.1.2",
"unist-util-remove": "^4.0.0",
"unist-util-visit": "^4.1.2",
Expand Down
8 changes: 4 additions & 4 deletions packages/myst-demo/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { LatexResult } from 'myst-to-tex'; // Only import the type!!
import type { TypstResult } from 'myst-to-typst'; // Only import the type!!
import { remove } from 'unist-util-remove';
import type { VFileMessage } from 'vfile-message';
import yaml from 'js-yaml';
import { load as yamlLoad, dump as yamlDump } from 'js-yaml';
import {
fileError,
RuleId,
Expand Down Expand Up @@ -60,7 +60,7 @@ function getFrontmatter(vfile: VFile, tree: GenericParent) {
const firstIsYaml = firstNode?.type === 'code' && firstNode?.lang === 'yaml';
if (firstIsYaml) {
try {
frontmatter = (yaml.load(firstNode.value) as Record<string, any>) || {};
frontmatter = (yamlLoad(firstNode.value) as Record<string, any>) || {};
(firstNode as any).type = '__delete__';
} catch (err) {
fileError(vfile, 'Invalid YAML frontmatter', {
Expand Down Expand Up @@ -152,7 +152,7 @@ async function parse(
footnotes: {},
};
const frontmatterRaw = getFrontmatter(vfile, mdast);
const frontmatter = validatePageFrontmatter(frontmatterRaw, {
const frontmatter: Omit<PageFrontmatter, 'parts'> = validatePageFrontmatter(frontmatterRaw, {
property: 'frontmatter',
messages: {},
});
Expand Down Expand Up @@ -449,7 +449,7 @@ export function MySTRenderer({
<CodeBlock
lang={astLang}
value={
astLang === 'yaml' ? yaml.dump(mdastStage) : JSON.stringify(mdastStage, null, 2)
astLang === 'yaml' ? yamlDump(mdastStage) : JSON.stringify(mdastStage, null, 2)
}
/>
</>
Expand Down
6 changes: 3 additions & 3 deletions packages/myst-to-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
"dependencies": {
"@heroicons/react": "^2.0.18",
"@myst-theme/providers": "^0.13.1",
"@scienceicons/react": "^0.0.6",
"@scienceicons/react": "^0.0.11",
"@radix-ui/react-hover-card": "^1.0.6",
"buffer": "^6.0.3",
"classnames": "^2.3.2",
"myst-common": "^1.7.0",
"myst-config": "^1.7.0",
"myst-common": "^1.7.2",
"myst-config": "^1.7.2",
"myst-spec": "^0.0.5",
"nanoid": "^4.0.2",
"react-syntax-highlighter": "15.5.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/myst-to-react/src/code.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export function CodeBlock(props: Props) {
</div>
</div>
)}
<SyntaxHighlighter {...highlighterProps} className="block hljs">
<SyntaxHighlighter {...highlighterProps} className="block p-3 hljs">
{value}
</SyntaxHighlighter>
{showCopy && (
Expand Down
6 changes: 3 additions & 3 deletions packages/providers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
"peerDependencies": {
"@types/react": "^16.8 || ^17.0 || ^18.0",
"@types/react-dom": "^16.8 || ^17.0 || ^18.0",
"myst-common": "^1.7.0",
"myst-config": "^1.7.0",
"myst-frontmatter": "^1.7.0",
"myst-common": "^1.7.2",
"myst-config": "^1.7.2",
"myst-frontmatter": "^1.7.2",
"react": "^16.8 || ^17.0 || ^18.0",
"react-dom": "^16.8 || ^17.0 || ^18.0"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
"@radix-ui/react-visually-hidden": "^1.1.0",
"classnames": "^2.3.2",
"lodash.throttle": "^4.1.1",
"myst-common": "^1.7.0",
"myst-config": "^1.7.0",
"myst-common": "^1.7.2",
"myst-config": "^1.7.2",
"myst-demo": "^0.13.1",
"myst-spec-ext": "^1.7.0",
"myst-spec-ext": "^1.7.2",
"myst-to-react": "^0.13.1",
"nbtx": "^0.2.3",
"node-cache": "^5.1.2",
Expand Down
13 changes: 9 additions & 4 deletions packages/site/src/components/Headers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from '@myst-theme/frontmatter';
import { useGridSystemProvider } from '@myst-theme/providers';
import classNames from 'classnames';
import type { PageFrontmatter } from 'myst-frontmatter';
import type { PageFrontmatterWithDownloads } from '@myst-theme/common';
import { ThemeButton } from './Navigation/index.js';

export function ArticleHeader({
Expand All @@ -16,13 +16,13 @@ export function ArticleHeader({
toggleTheme,
className,
}: {
frontmatter: PageFrontmatter;
frontmatter: PageFrontmatterWithDownloads;
children?: React.ReactNode;
toggleTheme?: boolean;
className?: string;
}) {
const grid = useGridSystemProvider();
const { subject, venue, biblio, ...rest } = frontmatter ?? {};
const { subject, venue, volume, issue, ...rest } = frontmatter ?? {};
const positionBackground = {
'col-page-right': grid === 'article-left-grid',
'col-page': grid === 'article-grid',
Expand Down Expand Up @@ -71,7 +71,12 @@ export function ArticleHeader({
})}
>
{subject && <div className={classNames('flex-none pr-2 smallcaps')}>{subject}</div>}
<Journal venue={venue} biblio={biblio} className="hidden pl-2 border-l md:block" />
<Journal
venue={venue}
volume={volume}
issue={issue}
className="hidden pl-2 border-l md:block"
/>
<div className="flex-grow"></div>
<div className="hidden sm:block">
<LicenseBadges license={frontmatter?.license} />
Expand Down
4 changes: 2 additions & 2 deletions themes/article/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"@remix-run/node": "~1.17.0",
"@remix-run/react": "~1.17.0",
"@remix-run/vercel": "~1.17.0",
"myst-common": "^1.7.0",
"myst-config": "^1.7.0",
"myst-common": "^1.7.2",
"myst-config": "^1.7.2",
"node-fetch": "^2.6.11",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
4 changes: 2 additions & 2 deletions themes/book/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"@remix-run/node": "~1.17.0",
"@remix-run/react": "~1.17.0",
"@remix-run/vercel": "~1.17.0",
"myst-common": "^1.7.0",
"myst-config": "^1.7.0",
"myst-common": "^1.7.2",
"myst-config": "^1.7.2",
"node-fetch": "^2.6.11",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down

0 comments on commit a2e58e5

Please sign in to comment.