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

docs(nx-dev): year 2025 review post #29460

Merged
merged 2 commits into from
Dec 23, 2024
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
8 changes: 8 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,14 @@ You can have a more dynamic visualization of a terminal output by using the foll
{% terminal-video src="/documentation/shared/images/caching/cache-terminal-animation.mp4" /%}
```

#### Table of Contents

You can add a table of contents to your document by using the following component. This is mostly useful for blog posts.

```markdown
{% toc /%}
```

#### Custom iframes

We can display a special iframe and setting its width inside the document.
Expand Down
1 change: 0 additions & 1 deletion docs/blog/2024-10-03-nx-20-release.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ authors: [Mike Hartington]
tags: [nx, release]
cover_image: /blog/images/2024-10-03/nx-20-header.png
youtubeUrl: https://youtu.be/5-QwtlhaJK8
pinned: true
---

I know it's hard to believe but Nx 20 is here! There's a lot of great updates in this release, but look back at some of the major features from Nx 19:
Expand Down
281 changes: 281 additions & 0 deletions docs/blog/2024-12-22-nx-highlights-2024.md

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file added docs/blog/media/nx-console-pipeline-running.mp4
Binary file not shown.
Binary file added docs/blog/media/nxconsole-ci-completion.mp4
Binary file not shown.
Binary file added docs/blog/media/nxconsole-project-view.mp4
Binary file not shown.
4 changes: 4 additions & 0 deletions nx-dev/ui-markdoc/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ import { pill } from './lib/tags/pill.schema';
import { fence } from './lib/nodes/fence.schema';
import { FenceWrapper } from './lib/nodes/fence-wrapper.component';
import { VideoPlayer, videoPlayer } from './lib/tags/video-player.component';
import { TableOfContents } from './lib/tags/table-of-contents.component';
import { tableOfContents } from './lib/tags/table-of-contents.schema';
// TODO fix this export
export { GithubRepository } from './lib/tags/github-repository.component';

Expand Down Expand Up @@ -92,6 +94,7 @@ export const getMarkdocCustomConfig = (
tab,
tabs,
'terminal-video': terminalVideo,
toc: tableOfContents,
tweet,
youtube,
'video-link': videoLink,
Expand Down Expand Up @@ -121,6 +124,7 @@ export const getMarkdocCustomConfig = (
SideBySide,
Tab,
Tabs,
TableOfContents,
TerminalVideo,
Tweet,
YouTube,
Expand Down
70 changes: 70 additions & 0 deletions nx-dev/ui-markdoc/src/lib/tags/table-of-contents.component.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
'use client';

import { useEffect, useState } from 'react';

interface TocItem {
id: string;
text: string;
level: number;
}

interface TableOfContentsProps {
maxDepth?: number;
}

export function TableOfContents({
maxDepth = 3,
}: TableOfContentsProps): JSX.Element {
const [headings, setHeadings] = useState<TocItem[]>([]);

useEffect(() => {
// Find the main content wrapper where markdown content is rendered
const content = document.querySelector('[data-document="main"]');
if (!content) return;

// Get all headings h1-h6 within the content
const headingElements = content.querySelectorAll('h1, h2, h3, h4, h5, h6');

const items: TocItem[] = Array.from(headingElements)
.map((heading) => {
const level = parseInt(heading.tagName[1]);
if (level > maxDepth) return null;

return {
id: heading.id,
text: heading.textContent || '',
level,
};
})
.filter((item): item is TocItem => item !== null);

setHeadings(items);
}, [maxDepth]);

if (headings.length === 0) {
return null;
}

return (
<nav className="toc not-prose mb-8 rounded-lg border border-slate-200 bg-slate-50 p-4 dark:border-slate-800 dark:bg-slate-900/50">
<p className="mb-3 text-sm font-semibold text-slate-900 dark:text-slate-100">
Table of Contents
</p>
<ul className="space-y-2 text-sm">
{headings.map((heading) => (
<li
key={heading.id}
style={{ paddingLeft: `${(heading.level - 1) * 1}rem` }}
>
<a
href={`#${heading.id}`}
className="text-slate-600 hover:text-slate-900 dark:text-slate-400 dark:hover:text-slate-200"
>
{heading.text}
</a>
</li>
))}
</ul>
</nav>
);
}
11 changes: 11 additions & 0 deletions nx-dev/ui-markdoc/src/lib/tags/table-of-contents.schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Schema } from '@markdoc/markdoc';

export const tableOfContents: Schema = {
render: 'TableOfContents',
attributes: {
maxDepth: {
type: 'Number',
default: 3,
},
},
};
Loading