For some beginners including myself , still figuring out on how to make our own theme module. But this is how I found a solution myself. Please Note : I don't know if this effects the performance issue on ApostropheCMS , but I'll leave this as a solution for all of us. Let's Begin ! (See Answer Below) :
标签:
apostrophe-cms
相关问题
- How-to access widget data in helper
- ApostropheCMS: How to emit Events from Browser to
- Apostrophe CMS running with Dynamo DB
- How to access custom fields in a data.home._childr
- Adding Link for Button Action
相关文章
- How-to access widget data in helper
- 添加了按钮操作链接(Adding Link for Button Action)
- 问题从弹性魔豆撇号CMS应用程序连接到蒙戈阿特拉斯(Issue connecting to Mong
- ApostropheCMS: How to emit Events from Browser to
- Apostrophe CMS running with Dynamo DB
- How to access custom fields in a data.home._childr
- Adding Link for Button Action
- Issue connecting to Mongo Atlas from Apostrophe CM
UPDATED ANSWER FOR ALL APOSTROPHE DEVELOPERS BEGINNERS
We followed tutorial from Pushing Assets to the Browser , but there is a missing plot somehow on why the assets is still cannot be found. Let's say we have created our own theme module based on that tutorial here. I put mine for example :
Then , you must put this in app.js to load the module :
Then , in our my-theme/index.js , these are my pushAsset method :
IMPORTANT NOTE : You don't have to include a link or script tag in your nunjucks template because it will make your performance issue on ApostropheCMS where minification process may not take if you put a link/script tags in nunjucks template. Let the Apostrophe made it for you , your job is only pushAsset ;)
Now, what if you have TOO MANY ASSETS , and you're too lazy to write the code everytime you upload a new asset , I have a shortcut using lodash , simple ! . In my-theme/index.js :
What if I want to do
<img>
tag with my custom asset PNG for example ? Do I need to pushAsset too ?YOU'RE DONE !
ANOTHER NOTE : If you need to call your asset ONLY via CSS for background-image that using url() or font-face, you need to call by using your own module name :
/modules/your-module-name/path-to-your-asset/
. EASY ! !AND REMEMBER , DON'T PUT LINK and SCRIPT tag to link an asset that you pushed. Apostrophe HAS MADE IT FOR YOU FOR POWERFUL PERFORMANCE ! Again , your job is to push the Asset ONLY.
It is not necessary or advisable to write your own
link
andscript
tags because this prevents Apostrophe from minifying your assets in production, and from compiling your LESS files as a single unit with the benefits of shared mixins, etc.However, the apostrophe-samples project now contains a working example of a "theme" module. I have moved the assets sometimes found at project level in
apostrophe-assets
to thetheme
module to demonstrate how this can correctly be done.The key elements are:
theme
module in app.js.lib/modules/theme/index.js
, push the assets you need inconstruct
, or a method called fromconstruct
.public/css
andpublic/js
subdirectories of yourtheme
module.See the apostrophe-samples project for the exact working code.
To learn about Apostrophe in production and how to minify assets there with no additional code, see Apostrophe in production.
Thanks for the nudge to bring this use case into the samples project.