Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 67 additions & 14 deletions unified-doc/build-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,46 @@ QUALIFIER_FLAG=()
OTHER_FLAGS=()
EXTRA_ARGS=()

for arg in "$@"; do
case $arg in
--clean) CLEAN=1; OTHER_FLAGS+=("$arg") ;;
--lint-only) LINT_ONLY=1 ;;
--qualifier=*) BUILD_QUALIFIER="${arg#*=}"; QUALIFIER_FLAG=("$arg") ;;
-*) OTHER_FLAGS+=("$arg") ;; # Pass through flags like -ds, -z
*) EXTRA_ARGS+=("$arg") ;;
while [[ $# -gt 0 ]]; do
case $1 in
--clean) CLEAN=1; shift ;;
--lint-only) LINT_ONLY=1; shift ;;
--qualifier=*) BUILD_QUALIFIER="${1#*=}"; QUALIFIER_FLAG=("$1"); shift ;;
--qualifier)
if [[ -n "${2:-}" && ! "$2" =~ ^- ]]; then
BUILD_QUALIFIER="$2"; QUALIFIER_FLAG=("--qualifier=$2"); shift 2
else
echo "Error: --qualifier requires a value" >&2; exit 1
fi
;;
-*) OTHER_FLAGS+=("$1"); shift ;;
*) EXTRA_ARGS+=("$1"); shift ;;
esac
done

# --- DEBUG CONFIG ---
echo "========================================"
echo "bd BUILD ENVIRONMENT DEBUG"
echo "========================================"
echo "bd CLEAN=$CLEAN"
echo "bd BUILD_QUALIFIER='$BUILD_QUALIFIER'"
echo "bd QUALIFIER_FLAG: ${QUALIFIER_FLAG[*]}"
echo "bd OTHER_FLAGS: ${OTHER_FLAGS[*]}"
echo "bd EXTRA_ARGS: ${EXTRA_ARGS[*]}"
echo "bd QUALIFIER_FLAG: ${QUALIFIER_FLAG[*]:-}"
echo "bd OTHER_FLAGS: ${OTHER_FLAGS[*]:-}"
echo "bd EXTRA_ARGS: ${EXTRA_ARGS[*]:-}"
echo "----------------------------------------"
echo "bd ENV VARS:"
echo "bd IS_VERCEL='${IS_VERCEL:-}'"
echo "bd VERCEL='${VERCEL:-}'"
echo "bd VERCEL_ENV='${VERCEL_ENV:-}'"
echo "bd CI='${CI:-}'"
echo "bd NODE_ENV='${NODE_ENV:-}'"
echo "bd PWD='$(pwd)'"
echo "----------------------------------------"
echo "bd VERSIONS:"
echo "bd node: $(node --version 2>/dev/null || echo 'not found')"
echo "bd yarn: $(yarn --version 2>/dev/null || echo 'not found')"
echo "bd npm: $(npm --version 2>/dev/null || echo 'not found')"
echo "========================================"

script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"

Expand Down Expand Up @@ -261,11 +285,23 @@ if [ "${CLEAN:-0}" -eq 1 ]; then
fi

clone_or_update "https://bitbucket.org/netfoundry/zrok-connector.git" frontdoor develop
clone_or_update "https://bitbucket.org/netfoundry/k8s-on-prem-installations.git" onprem update-to-theme
clone_or_update "https://github.com/openziti/ziti-doc.git" openziti update-to-theme
clone_or_update "https://github.com/netfoundry/zlan.git" zlan use-theme
clone_or_update "https://bitbucket.org/netfoundry/k8s-on-prem-installations.git" onprem main
clone_or_update "https://github.com/openziti/ziti-doc.git" openziti main
clone_or_update "https://github.com/netfoundry/zlan.git" zlan main
clone_or_update "https://github.com/openziti/zrok.git" zrok update-to-theme

echo "========================================"
echo "bd POST-CLONE DEBUG"
echo "========================================"
echo "bd Directories in _remotes:"
ls -la "$script_dir/_remotes" 2>/dev/null || echo " (none)"
echo "----------------------------------------"
echo "bd Looking for build/ and .docusaurus/ dirs in remotes:"
find "$script_dir/_remotes" -type d \( -name "build" -o -name ".docusaurus" \) 2>/dev/null || echo " (none found)"
echo "bd Cleaning stale build artifacts from remotes..."
find "$script_dir/_remotes" -type d \( -name "build" -o -name ".docusaurus" \) -exec rm -rf {} + 2>/dev/null || true
echo "========================================"

echo "copying versionable docs locally..."
"${script_dir}/sync-versioned-remote.sh" zrok

Expand All @@ -282,11 +318,28 @@ export SDK_ROOT_TARGET="${script_dir}/static/openziti/reference/developer/sdk"
echo "creating openziti SDK target if necessary at: ${SDK_ROOT_TARGET}"
mkdir -p "${SDK_ROOT_TARGET}"

"${script_dir}/_remotes/openziti/gendoc.sh" "${OTHER_FLAGS[@]}"
# -d = skip docusaurus build (unified-doc does its own build)
"${script_dir}/_remotes/openziti/gendoc.sh" -d "${OTHER_FLAGS[@]}"

# --- STEP 3: DOCUSAURUS BUILD ---
pushd "${script_dir}" >/dev/null
yarn install

if [ "${CLEAN:-0}" -eq 1 ]; then
echo "bd CLEAN=1: running yarn clear to remove .docusaurus cache"
yarn clear
fi

echo "========================================"
echo "bd PRE-BUILD DEBUG"
echo "========================================"
echo "bd IS_VERCEL='${IS_VERCEL:-}'"
echo "bd VERCEL='${VERCEL:-}'"
echo "bd script_dir='${script_dir}'"
echo "bd BUILD_QUALIFIER='${BUILD_QUALIFIER}'"
echo "bd output dir: build${BUILD_QUALIFIER}"
echo "========================================"

now=$(date)
echo "$now" > "${script_dir}/static/build-time.txt"
echo "BUILDING docs into: build${BUILD_QUALIFIER} at $now"
Expand Down
43 changes: 42 additions & 1 deletion unified-doc/docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ const cfg: PublishConfig = process.env.DOCUSAURUS_PUBLISH_ENV === 'prod' ? prod
const REMARK_MAPPINGS = [
{ from: '@onpremdocs', to: `${docsBase}onprem` },
{ from: '@openzitidocs', to: `${docsBase}openziti`},
{ from: '@zrokdocs', to: `${docsBase}zrok`},
{ from: '@static', to: docsBase},
];

Expand All @@ -87,6 +88,8 @@ console.log(" docsBase : " + docsBase);
console.log(" algolia index : " + cfg.algolia.indexName);
console.log(" build mask : " + buildMask);
console.log(" hotjar app : " + cfg.hotjar.id);
console.log('REMARK_MAPPINGS:', JSON.stringify(REMARK_MAPPINGS, null, 2));


function extendDocsPlugins(plugin: PluginConfig): PluginConfig {
if (!Array.isArray(plugin)) return plugin;
Expand All @@ -107,6 +110,44 @@ function extendDocsPlugins(plugin: PluginConfig): PluginConfig {
return [pluginName, config];
}

function dumpRoutes() {
return {
name: 'dump-routes',
async allContentLoaded({allContent, actions}: any) {
const fs = require('node:fs');

// route list (most stable in v3)
const routes = actions.routesPaths ?? actions.routePaths ?? [];

// optional: also dump plugin content ids so you can correlate routes
fs.writeFileSync(
'routes.json',
JSON.stringify({routes, allContent}, null, 2),
);
},
};
}

function assertNoDocsPrefix() {
return (tree: any, file: any) => {
const p = String(file.path || '');
const {visit} = require('unist-util-visit');

visit(tree, 'link', (node: any) => {
if (typeof node.url === 'string' && node.url.startsWith('/docs/')) {
console.log(`[assertNoDocsPrefix] ${p} url=${node.url}`);
}
});

visit(tree, 'jsx', (node: any) => {
if (typeof node.value === 'string' && node.value.includes('"/docs/')) {
console.log(`[assertNoDocsPrefix] ${p} jsx contains "/docs/`);
}
});
};
}


const config: Config = {
title: 'NetFoundry Documentation',
tagline: 'Documentation for NetFoundry products and projects',
Expand Down Expand Up @@ -293,7 +334,7 @@ const config: Config = {
blogSidebarTitle: 'All posts',
},
],
build(BUILD_FLAGS.ZROK) && extendDocsPlugins(zrokDocsPluginConfig(zrokRoot)),
build(BUILD_FLAGS.ZROK) && extendDocsPlugins(zrokDocsPluginConfig(zrokRoot, REMARK_MAPPINGS)),
// Fallback redirects for JSX pages with hardcoded /docs/ paths (from upstream repos)
isVercel && [
'@docusaurus/plugin-client-redirects',
Expand Down
30 changes: 19 additions & 11 deletions unified-doc/src/theme/Layout/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, {type ReactNode} from 'react';
import {NetFoundryLayout, NetFoundryLayoutProps, StarUsProps} from '@netfoundry/docusaurus-theme/ui';
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
import {useLocation} from "@docusaurus/router";
import {unifiedFooter} from "@site/src/components/footer";
import {frontdoorFooter} from "@frontdoor/src/components/footer";
Expand All @@ -9,22 +8,31 @@ import {zlanFooter} from "@zlan/src/components/footer";
import {openZitiFooter} from "@openziti/src/components/footer";
import {zrokFooter} from "@zrok/src/components/footer";

const matchPath = (p: string, segment: string) =>
p.startsWith(`/${segment}`) || p.startsWith(`/docs/${segment}`);

const mapFooter = (p: string) => {
if (p.startsWith('/docs/frontdoor')) return frontdoorFooter;
if (p.startsWith('/docs/onprem')) return onpremFooter;
if (p.startsWith('/docs/openziti')) return openZitiFooter;
if (p.startsWith('/docs/zlan')) return zlanFooter;
if (p.startsWith('/docs/zrok')) return zrokFooter;
if (matchPath(p, 'frontdoor')) return frontdoorFooter;
if (matchPath(p, 'onprem')) return onpremFooter;
if (matchPath(p, 'openziti')) return openZitiFooter;
if (matchPath(p, 'zlan')) return zlanFooter;
if (matchPath(p, 'zrok')) return zrokFooter;
return unifiedFooter;
};

export default function LayoutWrapper(props: NetFoundryLayoutProps): ReactNode {
const {siteConfig} = useDocusaurusContext();
const {pathname} = useLocation();
const starProps: StarUsProps = {}
if (pathname.startsWith('/docs/openziti')) {
starProps.repoUrl = 'https://github.com/openziti/ziti';
starProps.label = 'Support OpenZiti, give us a GitHub Star';
let starProps: StarUsProps | undefined;
if (matchPath(pathname, 'openziti')) {
starProps = {
repoUrl: 'https://github.com/openziti/ziti',
label: 'Star OpenZiti on GitHub',
};
} else if (matchPath(pathname, 'zrok')) {
starProps = {
repoUrl: 'https://github.com/openziti/zrok',
label: 'Star zrok on GitHub',
};
}
const footerToShow = mapFooter(pathname);
return (
Expand Down