@triggator/public-nav-embed 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # @triggator/public-nav-embed
2
+
3
+ Builds `NavBar` (isLoggedIn=false) as a UMD bundle for use in WordPress/Thrive Themes.
4
+
5
+ ## Build
6
+
7
+ ```bash
8
+ npm run build:public-nav
9
+ ```
10
+
11
+ Output: `dist/public-nav.umd.js`
12
+
13
+ ## WordPress Integration
14
+
15
+ **1. Deploy the bundle**
16
+
17
+ Copy or symlink `dist/public-nav.umd.js` into the WordPress theme's assets directory or serve it from the existing nginx static path.
18
+
19
+ **2. Enqueue in functions.php**
20
+
21
+ ```php
22
+ wp_enqueue_script(
23
+ 'triggator-public-nav',
24
+ get_template_directory_uri() . '/assets/js/public-nav.umd.js',
25
+ [],
26
+ '1.0.0',
27
+ true
28
+ );
29
+ ```
30
+
31
+ **3. Register shortcode in functions.php**
32
+
33
+ ```php
34
+ add_shortcode('triggator_nav', function() {
35
+ return '<div id="triggator-public-nav"></div>';
36
+ });
37
+ ```
38
+
39
+ **4. Place in Thrive**
40
+
41
+ Drop `[triggator_nav]` into the Thrive header template or `header.php`.
package/package.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "@triggator/public-nav-embed",
3
+ "version": "1.0.0",
4
+ "private": false,
5
+ "scripts": {
6
+ "build": "vite build",
7
+ "dev": "vite build --watch"
8
+ },
9
+ "dependencies": {
10
+ "@triggator/navbar": "*",
11
+ "react": ">=18.0.0 <20.0.0",
12
+ "react-dom": ">=18.0.0 <20.0.0"
13
+ },
14
+ "devDependencies": {
15
+ "@vitejs/plugin-react": "*",
16
+ "vite": "*"
17
+ }
18
+ }
package/src/index.ts ADDED
@@ -0,0 +1,15 @@
1
+ import React from "react"
2
+ import { createRoot } from "react-dom/client"
3
+ import { NavBar } from "@triggator/navbar"
4
+
5
+ function mount() {
6
+ const el = document.getElementById("triggator-public-nav")
7
+ if (!el) return
8
+ createRoot(el).render(React.createElement(NavBar, { isLoggedIn: false }))
9
+ }
10
+
11
+ if (document.readyState === "loading") {
12
+ document.addEventListener("DOMContentLoaded", mount)
13
+ } else {
14
+ mount()
15
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "extends": "../../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "rootDir": "src",
5
+ "outDir": "dist/types",
6
+ "declaration": true,
7
+ "declarationMap": true,
8
+ "emitDeclarationOnly": true,
9
+ "noEmit": false
10
+ },
11
+ "include": ["src"]
12
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,18 @@
1
+ import react from "@vitejs/plugin-react"
2
+ import { defineConfig } from "vite"
3
+
4
+ export default defineConfig({
5
+ plugins: [react()],
6
+ build: {
7
+ lib: {
8
+ entry: "src/index.ts",
9
+ name: "TriggatorPublicNav",
10
+ fileName: "public-nav",
11
+ formats: ["umd"],
12
+ },
13
+ rollupOptions: {
14
+ external: [],
15
+ },
16
+ outDir: "dist",
17
+ },
18
+ })