Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔢 Add enumerators to page titles and toc #525

Merged
merged 5 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/itchy-cows-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@myst-theme/frontmatter': patch
'@myst-theme/common': patch
'@myst-theme/site': patch
---

Add enumerators to page titles and toc
11 changes: 11 additions & 0 deletions .changeset/twelve-avocados-perform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'myst-to-react': patch
'myst-demo': patch
'@myst-theme/providers': patch
'@myst-theme/jupyter': patch
'@myst-theme/article': patch
'@myst-theme/site': patch
'@myst-theme/book': patch
---

Bump all myst and thebe package versions
552 changes: 276 additions & 276 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"version": "changeset version && npm install",
"publish": "npm run clean && npm run build -- --force && changeset publish && git push --follow-tags",
"publish:ci": "npm run clean && npm run build && changeset publish && git push --follow-tags",
"bump:myst:packages": "npx npm-upgrade-monorepo -w 'packages/*' 'myst-* @myst-theme/*'",
"bump:myst:themes": "npx npm-upgrade-monorepo -w 'themes/*' 'myst-* @myst-theme/*'",
"bump:myst:packages": "npx npm-upgrade-monorepo -w 'packages/*' 'myst-* @myst-theme/* thebe*'",
"bump:myst:themes": "npx npm-upgrade-monorepo -w 'themes/*' 'myst-* @myst-theme/* thebe*'",
"bump:myst": "npm run bump:myst:packages && npm run bump:myst:themes"
},
"devDependencies": {
Expand Down
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.3",
"myst-config": "^1.7.3",
"myst-spec-ext": "^1.7.3",
"myst-common": "^1.7.8",
"myst-config": "^1.7.8",
"myst-spec-ext": "^1.7.8",
"nbtx": "^0.2.3",
"unist-util-select": "^4.0.3"
}
Expand Down
1 change: 1 addition & 0 deletions packages/common/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export type Heading = {
short_title?: string;
level: number | 'index';
group?: string;
enumerator?: string;
};

export type SiteLoader = {
Expand Down
1 change: 1 addition & 0 deletions packages/common/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export function getProjectHeadings(
slug: project.index,
path: project.slug ? `/${project.slug}` : '/',
level: 'index',
enumerator: project.enumerator,
},
...project.pages.map((p) => {
if (!('slug' in p)) return p;
Expand Down
8 changes: 7 additions & 1 deletion packages/frontmatter/src/FrontmatterBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ export function FrontmatterBlock({
downloads,
date,
authors,
enumerator,
} = frontmatter;
const isJupyter = kind === SourceFileKind.Notebook;
const hasExports = downloads ? downloads.length > 0 : exports && exports.length > 0;
Expand Down Expand Up @@ -277,7 +278,12 @@ export function FrontmatterBlock({
{!hideLaunch && thebe && location && <LaunchButton thebe={thebe} location={location} />}
</div>
)}
{title && <h1 className="mb-0">{title}</h1>}
{title && (
<h1 className="mb-0">
{enumerator && <span className="mr-3 select-none">{enumerator}</span>}
{title}
</h1>
)}
{subtitle && <p className="mt-2 mb-0 lead text-zinc-600 dark:text-zinc-400">{subtitle}</p>}
{hasAuthors && authorStyle === 'list' && (
<AuthorsList authors={frontmatter.authors} affiliations={frontmatter.affiliations} />
Expand Down
14 changes: 7 additions & 7 deletions packages/jupyter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@
"buffer": "^6.0.3",
"classnames": "^2.5.1",
"jupyterlab-plotly": "^5.24.0",
"myst-common": "^1.7.3",
"myst-config": "^1.7.3",
"myst-frontmatter": "^1.7.3",
"myst-common": "^1.7.8",
"myst-config": "^1.7.8",
"myst-frontmatter": "^1.7.8",
"myst-spec": "^0.0.5",
"myst-spec-ext": "^1.7.3",
"myst-spec-ext": "^1.7.8",
"myst-to-react": "^0.13.5",
"nanoid": "^4.0.2",
"nbtx": "^0.2.3",
"react-syntax-highlighter": "^15.5.0",
"swr": "^2.1.5",
"thebe-core": "0.4.10",
"thebe-lite": "0.4.10",
"thebe-react": "0.4.10",
"thebe-core": "0.5.0",
"thebe-lite": "0.5.0",
"thebe-react": "0.5.0",
"unist-util-select": "^4.0.3"
},
"peerDependencies": {
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,25 +23,25 @@
"@heroicons/react": "^2.0.18",
"classnames": "^2.3.2",
"js-yaml": "^4.1.0",
"myst-common": "^1.7.3",
"myst-config": "^1.7.3",
"myst-directives": "^1.5.7",
"myst-ext-button": "^0.0.0",
"myst-common": "^1.7.8",
"myst-config": "^1.7.8",
"myst-directives": "^1.5.11",
"myst-ext-button": "^0.0.1",
"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.3",
"myst-parser": "^1.5.7",
"myst-ext-exercise": "^1.0.9",
"myst-ext-grid": "^1.0.9",
"myst-ext-proof": "^1.0.12",
"myst-ext-tabs": "^1.0.9",
"myst-frontmatter": "^1.7.8",
"myst-parser": "^1.5.11",
"myst-spec": "^0.0.5",
"myst-to-docx": "^1.0.12",
"myst-to-html": "^1.5.7",
"myst-to-jats": "^1.0.30",
"myst-to-docx": "^1.0.13",
"myst-to-html": "^1.5.11",
"myst-to-jats": "^1.0.32",
"myst-to-react": "^0.13.5",
"myst-to-tex": "^1.0.38",
"myst-to-typst": "^0.0.25",
"myst-transforms": "^1.3.26",
"myst-to-tex": "^1.0.41",
"myst-to-typst": "^0.0.30",
"myst-transforms": "^1.3.31",
"unified": "^10.1.2",
"unist-util-remove": "^4.0.0",
"unist-util-visit": "^4.1.2",
Expand Down
5 changes: 4 additions & 1 deletion packages/myst-demo/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@
messages: {},
});
const state = new ReferenceState('', {
numbering: frontmatter.numbering ?? defaultFrontmatter?.numbering,
frontmatter: {
...frontmatter,
numbering: frontmatter.numbering ?? defaultFrontmatter?.numbering,
},
vfile,
});
visit(mdast, (n) => {
Expand Down Expand Up @@ -389,7 +392,7 @@
);

const mdastStage = astStage === 'pre' ? mdastPre : mdastPost;
const { downloads, exports, parts, ...reducedFrontmatter } = frontmatter;

Check warning on line 395 in packages/myst-demo/src/index.tsx

View workflow job for this annotation

GitHub Actions / lint

'downloads' is assigned a value but never used

Check warning on line 395 in packages/myst-demo/src/index.tsx

View workflow job for this annotation

GitHub Actions / lint

'exports' is assigned a value but never used

Check warning on line 395 in packages/myst-demo/src/index.tsx

View workflow job for this annotation

GitHub Actions / lint

'parts' is assigned a value but never used

return (
<figure
Expand Down
4 changes: 2 additions & 2 deletions packages/myst-to-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"@radix-ui/react-hover-card": "^1.0.6",
"buffer": "^6.0.3",
"classnames": "^2.3.2",
"myst-common": "^1.7.3",
"myst-config": "^1.7.3",
"myst-common": "^1.7.8",
"myst-config": "^1.7.8",
"myst-spec": "^0.0.5",
"nanoid": "^4.0.2",
"react-syntax-highlighter": "15.5.0",
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.3",
"myst-config": "^1.7.3",
"myst-frontmatter": "^1.7.3",
"myst-common": "^1.7.8",
"myst-config": "^1.7.8",
"myst-frontmatter": "^1.7.8",
"react": "^16.8 || ^17.0 || ^18.0",
"react-dom": "^16.8 || ^17.0 || ^18.0"
},
Expand Down
8 changes: 4 additions & 4 deletions packages/site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@
"@radix-ui/react-visually-hidden": "^1.1.0",
"classnames": "^2.3.2",
"lodash.throttle": "^4.1.1",
"myst-common": "^1.7.3",
"myst-config": "^1.7.3",
"myst-common": "^1.7.8",
"myst-config": "^1.7.8",
"myst-demo": "^0.13.5",
"myst-spec-ext": "^1.7.3",
"myst-spec-ext": "^1.7.8",
"myst-to-react": "^0.13.5",
"nbtx": "^0.2.3",
"node-cache": "^5.1.2",
"node-fetch": "^2.6.11",
"react-merge-refs": "^2.1.1",
"string.prototype.matchall": "^4.0.11",
"thebe-react": "0.4.10",
"thebe-react": "0.5.0",
"unist-util-select": "^4.0.1"
},
"peerDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,20 @@ function LinkItem({
if (!heading.path) {
return (
<div
title={heading.title}
title={`${heading.enumerator ? `${heading.enumerator} ` : ''}${heading.title}`}
className={classNames('block break-words rounded', className)}
onClick={() => {
onClick?.();
}}
>
{heading.short_title || heading.title}
{`${heading.enumerator ? `${heading.enumerator} ` : ''}${heading.short_title || heading.title}`}
</div>
);
}
return (
<NavLink
prefetch="intent"
title={heading.title}
title={`${heading.enumerator ? `${heading.enumerator} ` : ''}${heading.title}`}
className={classNames(
'block break-words focus:outline outline-blue-200 outline-2 rounded',
className,
Expand All @@ -102,7 +102,7 @@ function LinkItem({
setOpen(false);
}}
>
{heading.short_title || heading.title}
{`${heading.enumerator ? `${heading.enumerator} ` : ''}${heading.short_title || heading.title}`}
</NavLink>
);
}
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.3",
"myst-config": "^1.7.3",
"myst-common": "^1.7.8",
"myst-config": "^1.7.8",
"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.3",
"myst-config": "^1.7.3",
"myst-common": "^1.7.8",
"myst-config": "^1.7.8",
"node-fetch": "^2.6.11",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
Loading