Hi there @ylc395
First of all just wanted to thank you for the awesome plugin. I've been working in web design for over 15 years and moved from evernote to joplin, and haven't looked back. One of my biggest issues is recommending website platforms for my friends, as I typically use Wordpress. This system is too much for the simple sites my friends want, and I think this plugin is a good alternative. I have been working on a custom template for this plugin, but I seem to have run into an issue:
After extensive testing and reviewing the PageRenderer.ts code in the Joplin Page Publisher plugin, it seems that the _assets folder from the theme directory is not being copied over to the output directory as it should. This issue seems to stem from how the copyAssets() method is implemented.
Here's the critical part of the code:
```javascript
private async copyAssets() {
if (!this.site || !this.themeDir || !this.outputDir || !this.outputAssetsDir) {
throw new Error('pageRenderer is not initialized');
}
const { outputAssetsDir } = this;
await fs.copy(this.themeDir, this.outputDir, {
filter: (src, dest) =>
dest === this.outputDir ||
dest.startsWith(outputAssetsDir) ||
(src.endsWith('.json') && !src.endsWith('config.json')),
});
}
The current filter logic in the copyAssets() method does not account for the fact that the paths for the theme's _assets directory and the output _assets directory are fundamentally different. This results in the _assets folder not being copied as expected from the theme/templates/_assets directory or theme/_assets over to the plugin/output directory.
Tested:
Theme _assets Path: ylc395.pagesPublisher/themes/themename/_assets
Theme _assets Path: ylc395.pagesPublisher/themes/themename/template/_assets
Output _assets Path: ylc395.pagesPublisher/output/_assets
Given these distinct paths, the plugin's logic does not align the theme's _assets directory with the output directory's _assets folder. I notice as well that the _blocks folder does not get copied either.
To resolve this issue, a modification to the copyAssets() method is necessary. I believe we need to explicitly include a step to copy the contents of the theme's _assets directory to the output directory's _assets folder. This adjustment ensures that the intended assets are correctly included in the final output.
- For those facing this issue, a temporary workaround is to open Joplin, then Page Publisher, and then hit Generate. That will generate your site html.
- From there place your _assets directory in the output directory:
/ylc395.pagesPublisher/output/_assets .
- From there hit the publish button in Page Publisher. That then uploads your _assets to github. If you referenced it in your EJS files it will resolve correctly.
Obviously this makes it hard to build and distribute a custom theme.
I am attempting to fix the issue, but my strength is more php than javascript, so it is slow going. If I manage to fix the issue, I'll submit a PR to the github repo.