From 4545ed13f3dfe1aa655f66eb335fd5944fe32c31 Mon Sep 17 00:00:00 2001 From: Till Prochaska Date: Fri, 9 Dec 2022 19:08:46 +0100 Subject: [PATCH] Display version number that introduced schema --- .github/workflows/docs.yml | 4 ++ site/package-lock.json | 4 +- .../src/components/explorer/VersionLink.astro | 23 +++++++++++ .../components/page/SchemaPageHeader.astro | 38 +++++++++++++++++++ site/src/pages/explorer/schemata/[name].astro | 7 +--- 5 files changed, 69 insertions(+), 7 deletions(-) create mode 100644 site/src/components/explorer/VersionLink.astro create mode 100644 site/src/components/page/SchemaPageHeader.astro diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 3a92dcd49..51e7db10e 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -18,6 +18,10 @@ jobs: steps: - name: Checkout repo uses: actions/checkout@v3 + with: + # Fetch all commits and tags + # (required to generate version information on schema pages) + fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v4 diff --git a/site/package-lock.json b/site/package-lock.json index ad27d1a88..3aaa19851 100644 --- a/site/package-lock.json +++ b/site/package-lock.json @@ -1115,7 +1115,7 @@ }, "node_modules/astro-theme-docs": { "version": "0.1.0", - "resolved": "git+ssh://git@github.com/alephdata/astro-theme-docs.git#fb27c07c20472a7501ef737088cc2905807c3fca", + "resolved": "git+ssh://git@github.com/alephdata/astro-theme-docs.git#587cf0bbf33a3331b195bdf526c8247b4972f389", "license": "MIT", "dependencies": { "@astrojs/mdx": "^0.12.0", @@ -7352,7 +7352,7 @@ } }, "astro-theme-docs": { - "version": "git+ssh://git@github.com/alephdata/astro-theme-docs.git#fb27c07c20472a7501ef737088cc2905807c3fca", + "version": "git+ssh://git@github.com/alephdata/astro-theme-docs.git#587cf0bbf33a3331b195bdf526c8247b4972f389", "from": "astro-theme-docs@github:alephdata/astro-theme-docs", "requires": { "@astrojs/mdx": "^0.12.0", diff --git a/site/src/components/explorer/VersionLink.astro b/site/src/components/explorer/VersionLink.astro new file mode 100644 index 000000000..2f229790e --- /dev/null +++ b/site/src/components/explorer/VersionLink.astro @@ -0,0 +1,23 @@ +--- +import options from 'src/options.json'; +const { version } = Astro.props; +const url = `${options.git.githubRepoUrl}/releases/tag/${version}`; +--- + + + + + Since {version} + diff --git a/site/src/components/page/SchemaPageHeader.astro b/site/src/components/page/SchemaPageHeader.astro new file mode 100644 index 000000000..2e71ff7dd --- /dev/null +++ b/site/src/components/page/SchemaPageHeader.astro @@ -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) {} +--- + + + +
+

{schema.label}

+ {firstVersion && } + + { + schema.description && ( +

{schema.description}

+ ) + } +
diff --git a/site/src/pages/explorer/schemata/[name].astro b/site/src/pages/explorer/schemata/[name].astro index 640c61a16..65a6c1971 100644 --- a/site/src/pages/explorer/schemata/[name].astro +++ b/site/src/pages/explorer/schemata/[name].astro @@ -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'; @@ -27,11 +28,7 @@ const headings = [ -
-

{schema.label}

- {schema.description &&

{schema.description}

} -
- +