@coaktion/hc-lib
v0.2.0
Published
An typescript library to implement common function and utilities for Help Center development
Readme
Help Center utilities kit.
Utility library for Zendesk Help Center development. Supports both v3 and v4 Help Center versions through a single factory method.
CDN Usage
Add the script tag to your Help Center template:
<script src="https://cdn.jsdelivr.net/npm/@coaktion/[email protected]/dist/index.global.js"></script> This exposes the global AktieHC object.
Instantiating
Call AktieHC.create() with the Help Center version:
<script>
// For Help Center v3
const hc = AktieHC.create("v3");
// For Help Center v4
const hc = AktieHC.create("v4");
// Bring API utilities like getArticles()
const hc = AktieHC.create("v4", ["articles"]);
</script>The returned hc object has the same interface regardless of version — the implementation details are handled internally.
Docs
- Form Fields —
hideFields,showFields,hideFieldOptions,invoke,FormFielde afins - DOM —
ready,setWithExpiry,getWithExpiry
Desenvolvimento local com tema Zendesk
Para desenvolver a lib e testar diretamente no tema Zendesk sem precisar publicar uma nova versão, use o modo dev:theme. A cada mudança em src/, o bundle é recompilado e copiado automaticamente para os assets do tema. Ao encerrar, tudo é revertido.
1. Configure o .env
cp .env.example .envEdite o .env com o caminho do seu tema:
HC_THEME_PATH=/caminho/para/seu-tema-zendeskPor padrão, o script localiza o template em templates/document_head.hbs dentro de HC_THEME_PATH. Se o seu template estiver em outro lugar, defina também:
HC_THEME_TEMPLATE=/caminho/para/seu-tema-zendesk/templates/document_head.hbs2. (Opcional) Adicione o script da CDN ao template
Se o document_head.hbs já tiver o import da lib via CDN, o script o substituirá automaticamente pela versão local ao iniciar:
<script src="https://cdn.jsdelivr.net/npm/@coaktion/hc-lib@VERSION/dist/index.global.js"></script>Caso o import não exista, o script injeta {{asset 'hc-lib.js'}} automaticamente — na primeira linha, ou logo após as tags <meta> iniciais caso existam.
3. Inicie o modo watch
npm run dev:themeO que acontece ao rodar:
- O script da CDN no template é substituído por
{{asset 'hc-lib.js'}}(ou injetado, caso não exista) - A cada alteração em
src/, o bundle é recompilado e copiado paraassets/hc-lib.js
O que acontece ao encerrar (Ctrl+C):
- O arquivo
assets/hc-lib.jsé removido - O template é restaurado ao estado exato em que estava antes, preservando qualquer edição feita durante a sessão
Use o zcli themes:preview no repositório do tema para visualizar as mudanças em tempo real.
Publishing a new version
Open a new Pull Request with your desirable changes to the main branch
After review and merge
Run
npm version patch
git push --follow-tagsDraft the release from the bumped tag and the gh action should take care of the rest
