diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js index 33619783..34298702 100644 --- a/website/docusaurus.config.js +++ b/website/docusaurus.config.js @@ -1,6 +1,8 @@ // @ts-check // Note: type annotations allow type checking and IDEs autocompletion +const fs = require('fs'); + const lightCodeTheme = require('prism-react-renderer/themes/github'); const darkCodeTheme = require('prism-react-renderer/themes/dracula'); const codeblockVersion = require('./src/remark/codeblockVersion'); @@ -8,6 +10,8 @@ const codeblockVersion = require('./src/remark/codeblockVersion'); const organizationName = 'virtuslab'; const projectName = 'besom'; +const besomVersion = fs.readFileSync('../version.txt').toString().trim() + /** @type {import('@docusaurus/types').Config} */ const config = { title: 'Besom - Pulumi Scala', @@ -37,7 +41,7 @@ const config = { }, customFields: { - besomVersion: '0.2.1' // TODO process.env.BESOM_VERSION + besomVersion: besomVersion }, presets: [ @@ -47,7 +51,7 @@ const config = { ({ docs: { sidebarPath: require.resolve('./sidebars.js'), - remarkPlugins: [codeblockVersion] + remarkPlugins: [codeblockVersion(besomVersion)] }, blog: { showReadingTime: true, diff --git a/website/src/remark/codeblockVersion.js b/website/src/remark/codeblockVersion.js index 3c29b124..cf9a68d3 100644 --- a/website/src/remark/codeblockVersion.js +++ b/website/src/remark/codeblockVersion.js @@ -1,8 +1,8 @@ const visit = require('unist-util-visit'); -const codeblockVersion = () => async (ast) => { +const codeblockVersion = (besomVersion) => () => async (ast) => { visit(ast, 'code', (node) => { - node.value = node.value.replace('$version', '0.2.1') // TODO read from env: process.env.BESOM_VERSION + node.value = node.value.replace('$version', besomVersion) }) }