diff --git a/scripts/md2html/build.sh b/scripts/md2html/build.sh index e70ba8c37f..b40a1a12e2 100755 --- a/scripts/md2html/build.sh +++ b/scripts/md2html/build.sh @@ -24,8 +24,10 @@ cp -p node_modules/respec/builds/respec-w3c.* $deploydir/js/ latest=$(git describe --abbrev=0 --tags) +allVersions=$(ls -1 versions/[23456789].*.md | grep -v -e "\-editors" | sort -r) + if [ -z "$1" ]; then - specifications=$(ls -1 versions/[23456789].*.md | grep -v -e "\-editors" | sort -r) + specifications=$allVersions elif [ "$1" = "latest" ]; then specifications=$(ls -1 versions/$latest.md) elif [ "$1" = "src" ]; then @@ -53,7 +55,7 @@ for specification in $specifications; do echo === Building $version to $destination - node scripts/md2html/md2html.js --maintainers $maintainers $specification > $tempfile + node scripts/md2html/md2html.js --maintainers $maintainers $specification "$allVersions" > $tempfile npx respec --no-sandbox --use-local --src $tempfile --out $destination rm $tempfile diff --git a/scripts/md2html/md2html.js b/scripts/md2html/md2html.js index 29e6d93f26..c3ff28629b 100644 --- a/scripts/md2html/md2html.js +++ b/scripts/md2html/md2html.js @@ -77,6 +77,7 @@ const md = require('markdown-it')({ }); function preface(title,options) { + const otherVersions = options._[1].split("\n").map(v => path.basename(v,'.md')).filter(v => v !== options.subtitle); const respec = { specStatus: "base", latestVersion: "https://spec.openapis.org/oas/latest.html", @@ -96,6 +97,14 @@ function preface(title,options) { height: 48, url: "https://openapis.org/"}], otherLinks: [ + { + key: "Other versions:", + data: otherVersions.map(v => { + return { + href: `https://spec.openapis.org/oas/v${v}.html` + } + }) + }, { key: "Participate", data: [ diff --git a/tests/md2html/fixtures/basic-new.html b/tests/md2html/fixtures/basic-new.html index 67f639d161..9ea00f7808 100644 --- a/tests/md2html/fixtures/basic-new.html +++ b/tests/md2html/fixtures/basic-new.html @@ -1,4 +1,4 @@ -OpenAPI Specification v30.0.1 | Introduction, Definitions, & More +OpenAPI Specification v30.0.1 | Introduction, Definitions, & More +OpenAPI Specification v30.0.1 | Introduction, Definitions, & More