decaporg / one-click-hugo-cms

Hugo template with Decap CMS
https://master-template-one-click-hugo-cms.netlify.app
MIT License
499 stars 298 forks source link

Updating the build pipeline to include custom CMS templates for preview #678

Closed maxcell closed 2 years ago

maxcell commented 2 years ago

Summary

Looks like when I upgraded all of our dependencies and fixed up some breaking changes in #674, I also broke the Preview Template feature. Fortunately this doesn't stop it from rendering properly once you've published your post in the editor, just need to find a way to bring the src/js/cms.js files into our site/static/admin/index.html.

Current Preview Current Output
CleanShot 2022-07-08 at 17 12 36 CleanShot 2022-07-08 at 17 29 42

Steps to Reproduce

To reproduce this you need to go into the NetlifyCMS (/admin) and see any page or post.

Expected Behavior

We should expect the current output as the current preview, with the same styling and everything we're using.

cgc commented 2 years ago

Seems like the issue might have been introduced in be22c5f6b329c9552f51cd63ece6108c58833d3e, which loads netlify-cms from unpkg instead of the included cms.js file:

--- a/src/cms.html
+++ b/site/static/admin/index.html
@@ -9,6 +9,6 @@
   <script src="https://identity-js.netlify.com/v1/netlify-identity-widget.js"></script>
 </head>
 <body>
-  <script src="<%= htmlWebpackPlugin.files.chunks.cms.entry %>"></script>
+  <script src="https://unpkg.com/netlify-cms@^2.0.0/dist/netlify-cms.js"></script>
 </body>
 </html>

I was able to get a fix working on my site -- here are the changes pulled out into a commit https://github.com/cgc/one-click-hugo-cms/commit/97a313e84f0273dd71932c2efa168a05be0246b7. They deal with breaking changes in two packages during the version updates in #674: