-
Notifications
You must be signed in to change notification settings - Fork 4
RFD site asciidoc fixes #46
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d8ec169
Updated section and listing and linting
benjaminleonard 51b8752
Format react icons
benjaminleonard 0248a45
Update components/src/asciidoc/Section.tsx
benjaminleonard b0b78fc
Merge branch 'master' into rfd-site-asciidoc-fixes
benjaminleonard c02a6da
Build
benjaminleonard 2e9b211
Swap `useGetContent` for `getContent`
benjaminleonard c6e54c9
Update types
benjaminleonard 8b270f0
Test admonition fix
benjaminleonard 160c80d
Forgot to build
benjaminleonard 9bd47ca
Types
benjaminleonard 69762f4
More RFD fixes
benjaminleonard 253bd0f
Fix casing error
benjaminleonard dd0b47b
Update components/src/asciidoc/Section.tsx
benjaminleonard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,4 @@ header: | |
- '**/*.md' | ||
- 'LICENSE' | ||
|
||
comment: on-failure | ||
comment: on-failure |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, you can obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* Copyright Oxide Computer Company | ||
*/ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, you can obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* Copyright Oxide Computer Company | ||
*/ | ||
|
||
import { Link16Icon } from '@/icons/react' | ||
benjaminleonard marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import { type AdocTypes, Content, getRole } from '@oxide/react-asciidoc' | ||
import cn from 'classnames' | ||
import parse from 'html-react-parser' | ||
import { createElement } from 'react' | ||
|
||
const Section = ({ node }: { node: AdocTypes.Section }) => { | ||
const docAttrs = node.getDocument().getAttributes() | ||
const level = node.getLevel() | ||
let title: JSX.Element | string = '' | ||
|
||
let sectNum = node.getSectionNumeral() | ||
sectNum = sectNum === '.' ? '' : sectNum | ||
|
||
const sectNumLevels = docAttrs['sectnumlevels'] ? parseInt(docAttrs['sectnumlevels']) : 3 | ||
|
||
if (node.getCaption()) { | ||
title = node.getCaptionedTitle() | ||
} else if (node.isNumbered() && level <= sectNumLevels) { | ||
if (level < 2 && node.getDocument().getDoctype() === 'book') { | ||
const sectionName = node.getSectionName() | ||
if (sectionName === 'chapter') { | ||
const signifier = docAttrs['chapter-signifier'] | ||
title = `${signifier || ''} ${sectNum} ${node.getTitle()}` | ||
} else if (sectionName === 'part') { | ||
const signifier = docAttrs['part-signifier'] | ||
title = `${signifier || ''} ${sectNum} ${node.getTitle()}` | ||
} else { | ||
title = node.getTitle() || '' | ||
} | ||
} else { | ||
title = node.getTitle() || '' | ||
} | ||
} else { | ||
title = node.getTitle() || '' | ||
} | ||
|
||
title = ( | ||
<> | ||
<a className="anchor" id={node.getId() || ''} aria-hidden /> | ||
<a className="link group" href={`#${node.getId()}`}> | ||
{parse(title)} | ||
<Link16Icon className="text-accent-secondary hidden group-hover:inline-block ml-2" /> | ||
</a> | ||
</> | ||
) | ||
|
||
if (level === 0) { | ||
return ( | ||
<> | ||
<h1 className={cn('sect0', getRole(node))} data-sectnum={sectNum}> | ||
{title} | ||
</h1> | ||
<Content blocks={node.getBlocks()} /> | ||
</> | ||
) | ||
} else { | ||
return ( | ||
<div className={cn(`sect${level}`, getRole(node))}> | ||
{createElement(`h${level + 1}`, { 'data-sectnum': sectNum }, title)} | ||
<div className="sectionbody"> | ||
<Content blocks={node.getBlocks()} /> | ||
</div> | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
export default Section |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ | |
* | ||
* Copyright Oxide Computer Company | ||
*/ | ||
|
||
import cn from 'classnames' | ||
|
||
export type BadgeColor = | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ | |
* | ||
* Copyright Oxide Computer Company | ||
*/ | ||
|
||
import type { | ||
TabsContentProps, | ||
TabsListProps, | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.