From f78b9ecff5f24fb871d01052ac563df50b837b70 Mon Sep 17 00:00:00 2001 From: Vyacheslav Chernyshev <81693471+slaveeks@users.noreply.github.com> Date: Tue, 27 Dec 2022 16:10:18 +0300 Subject: [PATCH] Fixed copy button path in header.twig, code.twig (#290) * Fixed copy button path in header.twig * Fixed path of copy button in code.twig, updated version * add more logs * Added overwrite property * update version Co-authored-by: Nikita Melnikov --- package.json | 2 +- src/backend/build-static.ts | 19 ++++++++++++++++--- src/backend/utils/appConfig.ts | 1 + src/backend/views/pages/blocks/code.twig | 2 +- src/backend/views/pages/blocks/header.twig | 2 +- 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index fd535020..490b138c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "codex.docs", "license": "Apache-2.0", - "version": "v2.2.0-rc.1", + "version": "v2.2.0-rc.11", "type": "module", "bin": { "codex.docs": "dist/backend/app.js" diff --git a/src/backend/build-static.ts b/src/backend/build-static.ts index d8d45383..2b17fa4b 100644 --- a/src/backend/build-static.ts +++ b/src/backend/build-static.ts @@ -45,8 +45,10 @@ export default async function buildStatic(): Promise { }); } - console.log('Removing old static files'); - await fse.remove(distPath); + if (config.overwrite) { + console.log('Removing old static files'); + await fse.remove(distPath); + } console.log('Building static files'); const pagesOrder = await PagesOrder.getAll(); @@ -118,11 +120,22 @@ export default async function buildStatic(): Promise { console.log('Static files built'); console.log('Copy public directory'); - await fse.copy(path.resolve(dirname, '../../public'), distPath); + const publicDir = path.resolve(dirname, '../../public'); + + console.log(`Copy from ${publicDir} to ${distPath}`); + + try { + await fse.copy(publicDir, distPath); + console.log('Public directory copied'); + } catch (e) { + console.log('Error while copying public directory'); + console.error(e); + } if (appConfig.uploads.driver === 'local') { console.log('Copy uploads directory'); await fse.copy(path.resolve(cwd, appConfig.uploads.local.path), path.resolve(distPath, 'uploads')); + console.log('Uploads directory copied'); } } diff --git a/src/backend/utils/appConfig.ts b/src/backend/utils/appConfig.ts index 8f853c61..8d3e60ed 100644 --- a/src/backend/utils/appConfig.ts +++ b/src/backend/utils/appConfig.ts @@ -90,6 +90,7 @@ const FrontendConfig = z.object({ */ const StaticBuildConfig = z.object({ outputDir: z.string(), // Output directory for static build + overwrite: z.boolean().optional().default(true), indexPage: z.object({ enabled: z.boolean(), // Is index page enabled uri: z.string(), // Index page uri diff --git a/src/backend/views/pages/blocks/code.twig b/src/backend/views/pages/blocks/code.twig index 2402cb57..9ed997e7 100644 --- a/src/backend/views/pages/blocks/code.twig +++ b/src/backend/views/pages/blocks/code.twig @@ -3,7 +3,7 @@
{{ code | escape }}
{% - include 'components/copy-button.twig' with { + include '../../components/copy-button.twig' with { ariaLabel: 'Copy Code to Clipboard', class: 'block-code__copy-button', textToCopy: code | escape, diff --git a/src/backend/views/pages/blocks/header.twig b/src/backend/views/pages/blocks/header.twig index e2e0403e..d854dd97 100644 --- a/src/backend/views/pages/blocks/header.twig +++ b/src/backend/views/pages/blocks/header.twig @@ -1,6 +1,6 @@ {% - include 'components/copy-button.twig' with { + include '../../components/copy-button.twig' with { ariaLabel: 'Copy Link to the ' ~ text, class: 'block-header__copy-button', textToCopy: '#' ~ text | urlify,