Skip to content

Commit

Permalink
Display version number that introduced schema
Browse files Browse the repository at this point in the history
  • Loading branch information
tillprochaska committed Dec 9, 2022
1 parent 87f8a89 commit 178d6f4
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 7 deletions.
4 changes: 2 additions & 2 deletions site/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions site/src/components/explorer/VersionLink.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
import options from 'src/options.json';
const { version } = Astro.props;
const url = `${options.git.githubRepoUrl}/releases/tag/${version}`;
---

<style>
.VersionLink {
display: inline-block;
padding-inline: var(--space-xs);
border-radius: var(--radius-full);
font-size: var(--font-size-sm);
background-color: var(--color-bg-elevated);
border: 1px solid var(--color-border-default);
color: var(--color-fg-muted);
text-decoration: none;
font-weight: 400;
}
</style>

<a class="VersionLink" href={url} noreferrer noopener>
Since {version}
</a>
38 changes: 38 additions & 0 deletions site/src/components/page/SchemaPageHeader.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
import path from 'node:path';
import { getGitFirstTag } from 'astro-theme-docs';
import VersionLink from '@components/explorer/VersionLink.astro';
const { schema } = Astro.props;
let firstVersion = null;
const schemaPath = path.join('followthemoney', 'schema', `${schema.name}.yaml`);
try {
firstVersion = await getGitFirstTag(schemaPath);
} catch (error) {}
---

<style>
.SchemaPageHeader {
display: flex;
flex-direction: column;
row-gap: var(--space-sm);
align-items: start;
}

.SchemaPageHeader__name {
margin-block-end: 0;
}
</style>

<header class="SchemaPageHeader">
<h1 class="SchemaPageHeader__name alpha">{schema.label}</h1>
{firstVersion && <VersionLink version={firstVersion} />}

{
schema.description && (
<p class="SchemaPageHeader__description lead">{schema.description}</p>
)
}
</header>
7 changes: 2 additions & 5 deletions site/src/pages/explorer/schemata/[name].astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { model } from '@util/ftm';
import { Stack, TocNav } from 'astro-theme-docs/components';
import ExplorerLayout from '@layouts/ExplorerLayout.astro';
import SchemaPageHeader from '@components/page/SchemaPageHeader.astro';
import SchemaExtends from '@components/explorer/SchemaExtends.astro';
import SchemaSemantics from '@components/explorer/SchemaSemantics.astro';
import SchemaProperties from '@components/explorer/SchemaProperties.astro';
Expand All @@ -27,11 +28,7 @@ const headings = [
<TocNav {headings} slot="toc" />

<Stack size="xl">
<header>
<h1 class="alpha">{schema.label}</h1>
{schema.description && <p class="lead">{schema.description}</p>}
</header>

<SchemaPageHeader schema={schema} />
<SchemaExtends id="inheritance" schema={schema} />
<SchemaSemantics id="semantics" schema={schema} />
<SchemaProperties id="properties" schema={schema} />
Expand Down

0 comments on commit 178d6f4

Please sign in to comment.