blob: a5222266840e36940f74891cba29ebf6fb580200 [file]
/*
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
import * as fs from 'node:fs';
import * as path from 'node:path';
import type {Config} from '@docusaurus/types';
import type * as Preset from '@docusaurus/preset-classic';
// This runs in Node.js - Don't use client-side code here (browser APIs, JSX...)
// Juneau release version — sourced from JUNEAU_VERSION (set by scripts/build-docs.py
// via current-release.py) with a committed fallback so `docusaurus start` still
// renders a real version. Consumed by the <DependencyInfo> component.
const FALLBACK_JUNEAU_VERSION = '10.0.0';
const juneauVersion = process.env.JUNEAU_VERSION || FALLBACK_JUNEAU_VERSION;
// Load an artifactId -> string JSON map generated by build-docs.py, preferring an env
// override, then a snapshot next to this config, then one in the CWD. Returns {} if
// none are readable.
function loadArtifactMap(envVar: string, fileName: string): Record<string, string> {
const candidates = [
process.env[envVar],
path.resolve(__dirname, fileName),
path.resolve(process.cwd(), fileName),
].filter(Boolean) as string[];
for (const candidate of candidates) {
try {
return JSON.parse(fs.readFileSync(candidate, 'utf8')) as Record<string, string>;
} catch {
// try next candidate
}
}
return {};
}
// artifactId -> module directory (relative to the apache/juneau repo root), used to
// build the "Source" GitHub link in <DependencyInfo>. Generated by build-docs.py from
// the module pom.xml files; a committed artifact-paths.json snapshot is the fallback.
const juneauModulePaths = loadArtifactMap('JUNEAU_ARTIFACT_PATHS', 'artifact-paths.json');
// artifactId -> top-level javadoc package (e.g. "org/apache/juneau/commons"), used to
// point the <DependencyInfo> "Javadocs" link at the module's package summary instead of
// the aggregate index. Generated by build-docs.py from module source trees, validated
// against the generated javadocs; a committed artifact-packages.json snapshot is the
// fallback. Artifacts absent from the map fall back to the aggregate index.
const juneauJavadocPackages = loadArtifactMap('JUNEAU_JAVADOC_PACKAGES', 'artifact-packages.json');
// Site URL - used for external links that need to be environment-aware
const siteUrl = process.env.SITE_URL || 'https://juneau.apache.org';
const baseThemeConfig: Preset.ThemeConfig = {
image: 'img/juneau-social-card.png',
announcementBar: {
id: 'prerelease-10-0',
content:
'These docs describe 10.0 (pre-release, 10.0.0-SNAPSHOT). The latest release is <a href="/downloads">9.2.1</a>.',
backgroundColor: '#fff3cd',
textColor: '#533f03',
isCloseable: false,
},
navbar: {
title: 'Apache Juneau',
logo: {
alt: 'Apache Juneau',
src: 'img/oakleaf.svg',
},
items: [
{
type: 'docSidebar',
sidebarId: 'mainSidebar',
position: 'left',
label: 'Documentation',
},
{to: '/downloads', label: 'Downloads', position: 'left'},
{to: '/security', label: 'Security Analysis', position: 'left'},
{to: '/apache', label: 'Apache', position: 'left'},
{
href: 'https://github.com/apache/juneau',
label: 'GitHub',
position: 'right',
},
{
href: 'https://github.com/apache/juneau/wiki',
label: 'Wiki',
position: 'right',
},
{
// Use pathname:// protocol to tell Docusaurus this is an external link
// (even though it's on the same domain) to bypass link validation
href: 'pathname:///site/apidocs/index.html',
label: 'Javadocs',
position: 'right',
},
],
},
footer: {
style: 'dark',
links: [
{
title: 'Documentation',
items: [
{
label: 'Projects',
to: '/#projects',
},
{
label: 'Downloads',
to: '/downloads',
},
{
label: 'Javadocs',
href: 'pathname:///site/apidocs/index.html',
},
],
},
{
title: 'Community',
items: [
{
label: 'GitHub',
href: 'https://github.com/apache/juneau',
},
{
label: 'Wiki',
href: 'https://github.com/apache/juneau/wiki',
},
{
label: 'Mailing List',
href: 'mailto:dev@juneau.apache.org?Subject=Apache%20Juneau%20question',
},
],
},
{
title: 'Apache',
items: [
{
label: 'Apache Foundation',
href: 'https://www.apache.org/foundation',
},
{
label: 'License',
href: 'https://www.apache.org/licenses/',
},
{
label: 'ASF Security',
href: 'https://www.apache.org/security',
},
],
},
],
copyright: `Copyright © ${new Date().getFullYear()} The Apache Software Foundation. Licensed under the Apache License, Version 2.0. Apache, Apache Juneau, and the Apache feather logo are trademarks of The Apache Software Foundation.`,
},
prism: {
theme: {plain: {}, styles: []}, // Use custom Eclipse colors instead of default theme
darkTheme: {plain: {}, styles: []}, // Use custom Eclipse colors for dark mode too
additionalLanguages: ['java', 'json', 'yaml', 'bash', 'properties', 'ini', 'python'],
defaultLanguage: 'java',
},
} satisfies Preset.ThemeConfig;
const themeConfig: Preset.ThemeConfig = baseThemeConfig;
const config: Config = {
title: 'Apache Juneau',
tagline: 'Universal toolkit for marshalling POJOs to a wide variety of content types using a common framework',
favicon: 'img/oakleaf.svg',
// Render ```mermaid fenced blocks as diagrams (see themes below).
markdown: {
mermaid: true,
hooks: {
onBrokenMarkdownLinks: 'throw',
},
},
// Future flags, see https://docusaurus.io/docs/api/docusaurus-config#future
// `v4: true` also turns on fasterByDefault (Rspack, needs @docusaurus/faster) and
// mdx1CompatDisabledByDefault since 3.9, so the v4 flags are spelled out with those two off.
future: {
v4: {
removeLegacyPostBuildHeadAttribute: true,
useCssCascadeLayers: true,
siteStorageNamespacing: true,
fasterByDefault: false,
mdx1CompatDisabledByDefault: false,
},
},
// Set the production url of your site here
url: siteUrl,
// Set the /<baseUrl>/ pathname under which your site is served
// For GitHub pages deployment, it is often '/<projectName>/'
baseUrl: '/',
// Every page is served from <path>/index.html, so sitemap, canonical URLs and the server agree on one URL form.
trailingSlash: true,
// GitHub pages deployment config.
// If you aren't using GitHub pages, you don't need these.
organizationName: 'apache', // Usually your GitHub org/user name.
projectName: 'juneau', // Usually your repo name.
onBrokenLinks: 'throw',
// Exposed to client-side components (e.g. <DependencyInfo>) via useDocusaurusContext().
customFields: {
juneauVersion,
juneauModulePaths,
juneauJavadocPackages,
},
// Even if you don't use internationalization, you can use this field to set
// useful metadata like html lang. For example, if your site is Chinese, you
// may want to replace "en" with "zh-Hans".
i18n: {
defaultLocale: 'en',
locales: ['en'],
},
presets: [
[
'classic',
{
docs: {
path: './pages',
sidebarPath: './sidebars.ts',
// Please change this to your repo.
// Remove this to remove the "edit this page" links.
editUrl:
'https://github.com/apache/juneau/tree/master/docs/',
},
blog: false,
theme: {
customCss: './src/css/custom.css',
},
} satisfies Preset.Options,
],
],
// Client-side local search — built into the deployed bundle at site-build time.
// Replaces the previous Algolia DocSearch integration: no external service,
// no API key, search index is always in sync with the source.
themes: [
'@docusaurus/theme-mermaid',
[
'@easyops-cn/docusaurus-search-local',
{
hashed: true,
language: ['en'],
indexDocs: true,
indexBlog: false,
indexPages: true,
ignoreCssSelectors: ['.juneau-project-rail', '.juneau-project-cards'],
docsRouteBasePath: '/docs',
// Contributor material and release history get their own indexes so a reader
// searching from the user docs does not see them (search from those pages instead).
searchContextByPaths: [
{ label: 'Developer Info', path: 'docs/developer-info' },
{ label: 'Release Notes', path: 'docs/release-notes' },
],
},
],
],
themeConfig,
};
export default config;