diff --git a/docs/examples.md b/docs/examples.md index 414501f..d4aaa24 100644 --- a/docs/examples.md +++ b/docs/examples.md @@ -16,8 +16,8 @@ QuickFIX/J comes with several example applications located in the `quickfix/exam The QuickFIX/J version number can be determined by running the core JAR file from the command line: ```bash -java -jar quickfixj-core-3.0.0.jar +java -jar quickfixj-core-{{QUICKFIXJ_VERSION}}.jar # Output: -# Version: 3.0.0 +# Version: {{QUICKFIXJ_VERSION}} ``` diff --git a/docs/overview.md b/docs/overview.md index 88ab347..9e9a52e 100644 --- a/docs/overview.md +++ b/docs/overview.md @@ -40,14 +40,14 @@ To start using QuickFIX/J, add the following dependencies to your `pom.xml`. Qui org.quickfixj quickfixj-core - 3.0.0 + {{QUICKFIXJ_VERSION}} org.quickfixj quickfixj-messages-fix44 - 3.0.0 + {{QUICKFIXJ_VERSION}} ``` diff --git a/docusaurus.config.ts b/docusaurus.config.ts index c1a1c94..0fa8e59 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -1,151 +1,201 @@ import {themes as prismThemes} from 'prism-react-renderer'; import type {Config} from '@docusaurus/types'; import type * as Preset from '@docusaurus/preset-classic'; +import type {Plugin} from 'unified'; +import type {Node} from 'unist'; +import type {Root} from 'mdast'; -const config: Config = { - title: 'QuickFIX/J', - tagline: 'The Open Source FIX Protocol Engine for Java', - favicon: 'img/favicon.png', +const VERSION_PLACEHOLDER = '{{QUICKFIXJ_VERSION}}'; +const VERSION_FALLBACK = '3.0.1'; - future: { - v4: true, - }, +async function fetchLatestVersion(fallback: string): Promise { + try { + const response = await fetch( + 'https://api.github.com/repos/quickfix-j/quickfixj/releases/latest', + {headers: {'User-Agent': 'quickfixj-pages-docusaurus'}}, + ); + if (!response.ok) { + console.warn(`GitHub API returned ${response.status}, using fallback version ${fallback}`); + return fallback; + } + const data = (await response.json()) as {tag_name: string}; + return data.tag_name.replace(/^v/, ''); + } catch (err) { + console.warn(`Failed to fetch latest QuickFIX/J version: ${err}. Using fallback ${fallback}`); + return fallback; + } +} - url: 'https://quickfixj.org', // Placeholder URL - baseUrl: process.env.BASE_URL || '/', +// Remark plugin that replaces {{QUICKFIXJ_VERSION}} in all markdown text, +// inline-code, and fenced-code-block nodes at build time. +function versionReplacerPlugin(version: string): Plugin<[], Root> { + return () => (tree: Root) => { + function walk(node: Node & {value?: string; children?: Node[]}) { + if ( + ['text', 'inlineCode', 'code'].includes(node.type) && + typeof node.value === 'string' + ) { + node.value = node.value.replaceAll(VERSION_PLACEHOLDER, version); + } + if (Array.isArray(node.children)) { + node.children.forEach(walk); + } + } + walk(tree); + }; +} - organizationName: 'quickfix-j', - projectName: 'quickfixj', +export default async function createConfig(): Promise { + const quickfixjVersion = await fetchLatestVersion(VERSION_FALLBACK); - onBrokenLinks: 'throw', + return { + title: 'QuickFIX/J', + tagline: 'The Open Source FIX Protocol Engine for Java', + favicon: 'img/favicon.png', - i18n: { - defaultLocale: 'en', - locales: ['en'], - }, + future: { + v4: true, + }, - markdown: { - mermaid: true, - }, + url: 'https://quickfixj.org', // Placeholder URL + baseUrl: process.env.BASE_URL || '/', - themes: ['@docusaurus/theme-mermaid'], + organizationName: 'quickfix-j', + projectName: 'quickfixj', - presets: [ - [ - 'classic', - { - docs: { - sidebarPath: './sidebars.ts', - editUrl: 'https://github.com/quickfix-j/quickfixj-pages/edit/main/', - }, - blog: false, // Disabling blog for a purely technical docs site - theme: { - customCss: './src/css/custom.css', - }, - } satisfies Preset.Options, - ], - ], + onBrokenLinks: 'throw', - themeConfig: { - image: 'img/quickfixj-social-card.jpg', - announcementBar: { - id: 'quickfixj_news', - content: - '⚡ QuickFIX/J — The industry standard open source FIX engine for Java. Star us on GitHub', - isCloseable: true, + i18n: { + defaultLocale: 'en', + locales: ['en'], }, - colorMode: { - defaultMode: 'dark', - disableSwitch: false, - respectPrefersColorScheme: true, + + markdown: { + mermaid: true, }, - navbar: { - title: 'QuickFIX/J', - logo: { - alt: 'QuickFIX/J Logo', - src: 'img/logo.png', - srcDark: 'img/logo-dark.png', - }, - items: [ - { - type: 'docSidebar', - sidebarId: 'docsSidebar', - position: 'left', - label: 'Documentation', - }, - { - to: '/docs/architecture', - label: 'Core Concepts', - position: 'left', - }, - { - to: '/docs/developer-docs', - label: 'Developer Guide', - position: 'left', - }, - { - to: '/docs/acceptor-dynamic', - label: 'Advanced Topics', - position: 'left', - }, - { - href: 'https://github.com/quickfix-j/quickfixj', - label: 'GitHub', - position: 'right', - }, - ], + + themes: ['@docusaurus/theme-mermaid'], + + customFields: { + quickfixjVersion, }, - footer: { - style: 'dark', - links: [ - { - title: 'Learn', - items: [ - { - label: 'Overview', - to: '/docs/overview', - }, - { - label: 'Architecture', - to: '/docs/architecture', - }, - { - label: 'Configuration', - to: '/docs/configuration', - }, - ], - }, - { - title: 'Community', - items: [ - { - label: 'Mailing List', - href: 'https://sourceforge.net/p/quickfixj/mailman/', - }, - { - label: 'Stack Overflow', - href: 'https://stackoverflow.com/questions/tagged/quickfixj', - }, - ], - }, + + presets: [ + [ + 'classic', { - title: 'More', - items: [ - { - label: 'GitHub', - href: 'https://github.com/quickfix-j/quickfixj', - }, - ], - }, + docs: { + sidebarPath: './sidebars.ts', + editUrl: 'https://github.com/quickfix-j/quickfixj-pages/edit/main/', + remarkPlugins: [versionReplacerPlugin(quickfixjVersion)], + }, + blog: false, // Disabling blog for a purely technical docs site + theme: { + customCss: './src/css/custom.css', + }, + } satisfies Preset.Options, ], - copyright: `Copyright © ${new Date().getFullYear()} QuickFIX/J Contributors. Built with Docusaurus.`, - }, - prism: { - theme: prismThemes.github, - darkTheme: prismThemes.dracula, - additionalLanguages: ['java', 'properties', 'bash'], - }, - } satisfies Preset.ThemeConfig, -}; + ], -export default config; + themeConfig: { + image: 'img/quickfixj-social-card.jpg', + announcementBar: { + id: 'quickfixj_news', + content: + '⚡ QuickFIX/J — The industry standard open source FIX engine for Java. Star us on GitHub', + isCloseable: true, + }, + colorMode: { + defaultMode: 'dark', + disableSwitch: false, + respectPrefersColorScheme: true, + }, + navbar: { + title: 'QuickFIX/J', + logo: { + alt: 'QuickFIX/J Logo', + src: 'img/logo.png', + srcDark: 'img/logo-dark.png', + }, + items: [ + { + type: 'docSidebar', + sidebarId: 'docsSidebar', + position: 'left', + label: 'Documentation', + }, + { + to: '/docs/architecture', + label: 'Core Concepts', + position: 'left', + }, + { + to: '/docs/developer-docs', + label: 'Developer Guide', + position: 'left', + }, + { + to: '/docs/acceptor-dynamic', + label: 'Advanced Topics', + position: 'left', + }, + { + href: 'https://github.com/quickfix-j/quickfixj', + label: 'GitHub', + position: 'right', + }, + ], + }, + footer: { + style: 'dark', + links: [ + { + title: 'Learn', + items: [ + { + label: 'Overview', + to: '/docs/overview', + }, + { + label: 'Architecture', + to: '/docs/architecture', + }, + { + label: 'Configuration', + to: '/docs/configuration', + }, + ], + }, + { + title: 'Community', + items: [ + { + label: 'Mailing List', + href: 'https://sourceforge.net/p/quickfixj/mailman/', + }, + { + label: 'Stack Overflow', + href: 'https://stackoverflow.com/questions/tagged/quickfixj', + }, + ], + }, + { + title: 'More', + items: [ + { + label: 'GitHub', + href: 'https://github.com/quickfix-j/quickfixj', + }, + ], + }, + ], + copyright: `Copyright © ${new Date().getFullYear()} QuickFIX/J Contributors. Built with Docusaurus.`, + }, + prism: { + theme: prismThemes.github, + darkTheme: prismThemes.dracula, + additionalLanguages: ['java', 'properties', 'bash'], + }, + } satisfies Preset.ThemeConfig, + }; +} diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 0614edc..b59ca21 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -235,6 +235,8 @@ function TechStackSection() { } function QuickStartSection() { + const { siteConfig } = useDocusaurusContext(); + const version = siteConfig.customFields?.quickfixjVersion as string; return (
@@ -248,12 +250,12 @@ function QuickStartSection() { org.quickfixj quickfixj-core - 3.0.0 + ${version} org.quickfixj quickfixj-messages-fix44 - 3.0.0 + ${version} `}