Skip to content

Commit

Permalink
Fixed copy button path in header.twig, code.twig (#290)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
slaveeks and nikmel2803 authored Dec 27, 2022
1 parent d3e0cb1 commit f78b9ec
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
19 changes: 16 additions & 3 deletions src/backend/build-static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ export default async function buildStatic(): Promise<void> {
});
}

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();
Expand Down Expand Up @@ -118,11 +120,22 @@ export default async function buildStatic(): Promise<void> {
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');
}
}

1 change: 1 addition & 0 deletions src/backend/utils/appConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/backend/views/pages/blocks/code.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="block-code__content">{{ code | escape }}</div>
</div>
{%
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,
Expand Down
2 changes: 1 addition & 1 deletion src/backend/views/pages/blocks/header.twig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h{{ level }} id="{{ text | urlify }}" class="block-header block-header--{{ level }}">
{%
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,
Expand Down

0 comments on commit f78b9ec

Please sign in to comment.