Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add the decap-cms/hooks/body-end hook for customizing Decap CMS #31

Merged
merged 1 commit into from
Nov 22, 2023

Conversation

razonyang
Copy link
Member

@razonyang razonyang commented Nov 22, 2023

Replaces and closes #30

This PR adds a hook for customizing the Decap CMS, take registerPreviewStyle as an example.

To use this hook, you'll need to create the layouts/partials/decap-cms/hooks/body-end.html file on your site root.

// assets/main.scss
h1, h2, h3, h4, h5, h6 {
  color: red;
}
// layouts/partials/decap-cms/hooks/body-end.html
<script>
  {{- $css := resources.Get "main.scss" | toCSS }}
  CMS.registerPreviewStyle('{{ $css.RelPermalink }}');
</script>

If your theme using prebuilt styles (not using Hugo pipes), you can register it directly.

// layouts/partials/decap-cms/hooks/body-end.html
<script>
  CMS.registerPreviewStyle('{{ "/css/main.css" | relURL }}');
</script>

@razonyang razonyang added the enhancement New feature or request label Nov 22, 2023
@razonyang razonyang merged commit e68b7cf into main Nov 22, 2023
2 checks passed
@yippyskippy
Copy link
Contributor

Great! Thanks.

@razonyang razonyang deleted the feat-hook-body-end branch January 27, 2024 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants