Skip to content

Commit eae65c1

Browse files
update
1 parent 52c0eaa commit eae65c1

2 files changed

Lines changed: 91 additions & 2 deletions

File tree

.github/workflows/purge-cdn.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Purge jsDelivr cache
2+
3+
on:
4+
push:
5+
branches: [trunk]
6+
7+
jobs:
8+
purge:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
13+
- name: Collect changed files
14+
id: files
15+
run: |
16+
FILES=$(git diff --name-only HEAD~1 HEAD -- shared/ snippets/ | tr '\n' ',')
17+
echo "changed=$FILES" >> "$GITHUB_OUTPUT"
18+
19+
- name: Purge jsDelivr cache
20+
if: steps.files.outputs.changed != ''
21+
run: |
22+
IFS=',' read -ra ITEMS <<< "${{ steps.files.outputs.changed }}"
23+
for file in "${ITEMS[@]}"; do
24+
[ -z "$file" ] && continue
25+
URL="https://purge.jsdelivr.net/gh/${{ github.repository }}@trunk/${file}"
26+
echo "Purging: $URL"
27+
curl -s "$URL" | jq -r '.status // "error"'
28+
done

README.md

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,63 @@
1-
# marketing-js
2-
Marketing-js repository
1+
# Marketing JS
2+
3+
Interactive calculators and tools used as lead magnets on [shiftbase.com](https://www.shiftbase.com). Each snippet is a self-contained vanilla JavaScript widget that can be embedded on any page via [jsDelivr](https://www.jsdelivr.com/).
4+
5+
## Available snippets
6+
7+
| Snippet | Mount ID | Description |
8+
|---|---|---|
9+
| `nl-roi-businesscase` | `sb-roi-businesscase` | ROI & business case calculator |
10+
| `nl-zelftest-rooster` | `sb-zelftest-rooster` | Schedule self-assessment checklist |
11+
| `example-counter` | `sb-counter` | Demo snippet (click counter) |
12+
13+
## How to embed
14+
15+
1. Add the shared stylesheet in the `<head>` of your page (once per page):
16+
17+
```html
18+
<link rel="stylesheet"
19+
href="https://cdn.jsdelivr.net/gh/shiftbase-com/marketing-js@trunk/shared/styles.css">
20+
```
21+
22+
2. Place a `<div>` with the correct mount ID where you want the widget to appear, followed by the snippet script:
23+
24+
```html
25+
<div id="sb-roi-businesscase"></div>
26+
<script
27+
src="https://cdn.jsdelivr.net/gh/shiftbase-com/marketing-js@trunk/snippets/nl-roi-businesscase/snippet.js">
28+
</script>
29+
```
30+
31+
The snippet will automatically render inside the `<div>`. Each snippet preview page includes a ready-to-copy embed block.
32+
33+
## HubSpot
34+
35+
When embedding via a HubSpot embed module, make sure the module or column width is set to at least **800px**. By default HubSpot may limit the embed wrapper to 540px, which compresses the layout.
36+
37+
## CDN caching
38+
39+
jsDelivr caches files aggressively. After pushing changes to `trunk`, a GitHub Action automatically purges the cache for any changed files in `shared/` and `snippets/`. If you need to purge manually, replace `cdn` with `purge` in the URL:
40+
41+
```
42+
https://purge.jsdelivr.net/gh/shiftbase-com/marketing-js@trunk/shared/styles.css
43+
```
44+
45+
## Local development
46+
47+
Open `index.html` in the browser (via `file://` or Live Server) for an overview of all snippets. Each snippet folder also has its own `index.html` for a standalone preview. No build step needed.
48+
49+
## Creating a new snippet
50+
51+
1. Create a folder under `snippets/` with a descriptive name (kebab-case)
52+
2. Create `snippet.js` — wrap all code in an IIFE: `(function() { ... })();`
53+
3. The snippet mounts itself on a `<div>` with a specific `id` (e.g. `sb-counter`)
54+
4. Create `index.html` for local preview — load `../../shared/styles.css` and your script
55+
5. Add a link to the snippet grid in the root `index.html`
56+
57+
### Conventions
58+
59+
- All CSS classes use the `sb-` prefix to avoid conflicts with host pages
60+
- The root container gets the class `sb-widget`
61+
- No external dependencies — everything is vanilla JS
62+
- No `document.write()`, no globals
63+
- Snippet-specific styles are injected via JS; shared styles live in `shared/styles.css`

0 commit comments

Comments
 (0)