-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🧠 Display known front/back matter parts (#266)
- Loading branch information
Showing
8 changed files
with
121 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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 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,43 @@ | ||
import type { GenericParent } from 'myst-common'; | ||
import { ContentBlocks } from './ContentBlocks.js'; | ||
import { HashLink } from 'myst-to-react'; | ||
import type { KnownParts } from '../utils.js'; | ||
|
||
export function BackmatterParts({ parts }: { parts: KnownParts }) { | ||
return ( | ||
<> | ||
<Backmatter | ||
title="Data Availability" | ||
id="data-availability" | ||
content={parts.data_availability} | ||
/> | ||
<Backmatter title="Acknowledgments" id="acknowledgments" content={parts.acknowledgments} /> | ||
</> | ||
); | ||
} | ||
|
||
export function Backmatter({ | ||
title, | ||
id, | ||
content, | ||
}: { | ||
title: string; | ||
id: string; | ||
content?: GenericParent; | ||
}) { | ||
if (!content) return null; | ||
return ( | ||
<div className="flex flex-col w-full md:flex-row"> | ||
<h2 | ||
id={id} | ||
className="mt-5 text-base font-semibold group md:w-[200px] self-start md:flex-none opacity-90" | ||
> | ||
{title} | ||
<HashLink id={id} title={`Link to ${title}`} hover className="ml-2" /> | ||
</h2> | ||
<div className="grow"> | ||
<ContentBlocks mdast={content} className="opacity-80 col-screen" /> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains 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 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 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 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 |
---|---|---|
@@ -1,5 +1,25 @@ | ||
import type { GenericParent } from 'myst-common'; | ||
import { extractPart } from 'myst-common'; | ||
|
||
export function getDomainFromRequest(request: Request) { | ||
const url = new URL(request.url); | ||
const domain = `${url.protocol}//${url.hostname}${url.port ? `:${url.port}` : ''}`; | ||
return domain; | ||
} | ||
|
||
export type KnownParts = { | ||
abstract?: GenericParent; | ||
summary?: GenericParent; | ||
keypoints?: GenericParent; | ||
data_availability?: GenericParent; | ||
acknowledgments?: GenericParent; | ||
}; | ||
|
||
export function extractKnownParts(tree: GenericParent): KnownParts { | ||
const abstract = extractPart(tree, 'abstract'); | ||
const summary = extractPart(tree, 'summary'); | ||
const keypoints = extractPart(tree, 'keypoints'); | ||
const data_availability = extractPart(tree, 'data_availability'); | ||
const acknowledgments = extractPart(tree, 'acknowledgments'); | ||
return { abstract, summary, keypoints, data_availability, acknowledgments }; | ||
} |
This file contains 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 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