diff --git a/.nvmrc b/.nvmrc index 6f7f377bf..3f430af82 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -v16 +v18 diff --git a/docs/.vuepress/build.config.js b/docs/.vuepress/build.config.js new file mode 100644 index 000000000..633ea41f3 --- /dev/null +++ b/docs/.vuepress/build.config.js @@ -0,0 +1,12 @@ +/** + * Docs build configuration. + * Override any of these via environment variables: + * DOCS_BASE — public base path (must start and end with `/`) + * DOCS_DEST — output directory (relative to repo root) + * DOCS_HOSTNAME — absolute origin used for the sitemap + */ +module.exports = { + base: '/docs/', + dest: 'docs/.vuepress/dist/docs', + hostname: 'https://hyperformula.handsontable.com', +}; diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index 70456f0da..2726f697a 100644 --- a/docs/.vuepress/config.js +++ b/docs/.vuepress/config.js @@ -8,6 +8,26 @@ const includeCodeSnippet = require('./plugins/markdown-it-include-code-snippet') const searchPattern = new RegExp('^/api', 'i'); +// Build configuration (override via env vars or docs/.vuepress/build.config.js) +const buildConfigOverrides = (() => { + try { + return require('./build.config.js'); + } catch (e) { + return {}; + } +})(); + +const normalizeBase = (b) => { + if (!b) return '/'; + let v = b.startsWith('/') ? b : '/' + b; + if (!v.endsWith('/')) v += '/'; + return v; +}; + +const DOCS_BASE = normalizeBase(process.env.DOCS_BASE || buildConfigOverrides.base || '/'); +const DOCS_DEST = process.env.DOCS_DEST || buildConfigOverrides.dest || 'docs/.vuepress/dist'; +const DOCS_HOSTNAME = process.env.DOCS_HOSTNAME || buildConfigOverrides.hostname || 'https://hyperformula.handsontable.com'; + module.exports = { title: 'HyperFormula (v' + HyperFormula.version + ')', description: 'HyperFormula is an open-source, high-performance calculation engine for spreadsheets and web applications.', @@ -61,10 +81,11 @@ module.exports = { ['link', { rel: 'manifest', href: '/favicon/site.webmanifest' }], ['link', { rel: 'mask-icon', color: '#ffffff', href: '/favicon/safari-pinned-tab.svg' }], ], - base: '/', + base: DOCS_BASE, + dest: DOCS_DEST, plugins: [ ['sitemap', { - hostname: 'https://hyperformula.handsontable.com', + hostname: DOCS_HOSTNAME, exclude: ['/404.html'], changefreq: 'weekly' }], diff --git a/netlify.toml b/netlify.toml new file mode 100644 index 000000000..239f5392e --- /dev/null +++ b/netlify.toml @@ -0,0 +1,6 @@ +[build] + command = "npm run docs:build" + publish = "docs/.vuepress/dist/docs" + +[build.environment] + NODE_VERSION = "18"