coherent-docs-theme 1.0.6 → 1.0.7

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.
@@ -0,0 +1,207 @@
1
+ ---
2
+ import getThemeConfig from "../internal/themeConfig";
3
+ import nativeIcon from "../assets/icons/native.png";
4
+ import unrealIcon from "../assets/icons/unreal.png";
5
+ import unityIcon from "../assets/icons/unity.png";
6
+
7
+ const product = import.meta.env.DOCS_PRODUCT || "gameface";
8
+ const { topicsConfig, version, currentTopicId } = getThemeConfig();
9
+
10
+ const topics = {
11
+ native: {
12
+ label: "Custom Engine",
13
+ href: `https://docs.coherent-labs.com/cpp-${product}`,
14
+ icon: nativeIcon,
15
+ ...(topicsConfig?.native || {}),
16
+ },
17
+ unreal: {
18
+ label: "Unreal Engine",
19
+ href: `https://docs.coherent-labs.com/unreal-${product}`,
20
+ icon: unrealIcon,
21
+ ...(topicsConfig?.unreal || {}),
22
+ },
23
+ unity: {
24
+ label: "Unity 3D",
25
+ href: `https://docs.coherent-labs.com/unity-${product}`,
26
+ icon: unityIcon,
27
+ ...(topicsConfig?.unity || {}),
28
+ },
29
+ };
30
+
31
+ const topicsArray = Object.entries(topics).map(([id, data]) => ({
32
+ id,
33
+ ...data,
34
+ }));
35
+
36
+ const isCurrent = (id: string) => id === currentTopicId;
37
+ const hasContent = topicsArray.length > 0 || version;
38
+ ---
39
+
40
+ {
41
+ hasContent && (
42
+ <>
43
+ {version && (
44
+ <div class="version-badge">
45
+ <span>Version:</span>
46
+ <span class="sl-badge tip small">{version}</span>
47
+ </div>
48
+ )}
49
+ <div class="topics-wrapper">
50
+ <ul class="starlight-sidebar-topics">
51
+ {topicsArray.map((topic) => {
52
+ const iconUrl =
53
+ typeof topic.icon === "object" ? topic.icon.src : topic.icon;
54
+
55
+ const isImage =
56
+ iconUrl &&
57
+ (iconUrl.startsWith("/") ||
58
+ iconUrl.startsWith("http") ||
59
+ iconUrl.startsWith("data:"));
60
+
61
+ return (
62
+ <li>
63
+ <a
64
+ href={topic.href}
65
+ class:list={{
66
+ "starlight-sidebar-topics-current": isCurrent(topic.id),
67
+ }}
68
+ >
69
+ <div class="starlight-sidebar-topics-icon">
70
+ {isImage ? (
71
+ <div
72
+ class="icon-mask"
73
+ style={`--icon-url: url('${iconUrl}')`}
74
+ role="img"
75
+ aria-label={topic.label}
76
+ />
77
+ ) : (
78
+ <span class="text-icon">{topic.icon}</span>
79
+ )}
80
+ </div>
81
+ <div class="label-wrapper">{topic.label}</div>
82
+ </a>
83
+ </li>
84
+ );
85
+ })}
86
+ </ul>
87
+ <div class="sidebar-divider" />
88
+ </div>
89
+ </>
90
+ )
91
+ }
92
+ <style>
93
+ .starlight-sidebar-topics {
94
+ list-style: none;
95
+ padding: 0;
96
+ margin: 0;
97
+ }
98
+
99
+ li + li {
100
+ margin-top: 0.25rem;
101
+ }
102
+
103
+ a {
104
+ align-items: center;
105
+ color: var(--sl-color-gray-2);
106
+ display: flex;
107
+ font-size: 0.85rem;
108
+ font-weight: 700;
109
+ gap: 0.6rem;
110
+ text-decoration: none;
111
+ border-radius: 0.25rem;
112
+ transition:
113
+ background-color 0.2s ease,
114
+ color 0.2s ease;
115
+ }
116
+
117
+ a:hover,
118
+ a:focus-visible {
119
+ color: var(--sl-color-white);
120
+ background-color: var(--sl-color-gray-5);
121
+ }
122
+
123
+ a.starlight-sidebar-topics-current {
124
+ color: var(--gameface-cyan);
125
+ background-color: var(--sl-color-gray-5);
126
+ }
127
+
128
+ .starlight-sidebar-topics-icon {
129
+ align-items: center;
130
+ border-radius: 0.25rem;
131
+ display: flex;
132
+ justify-content: center;
133
+ width: 2.5rem;
134
+ height: 2.5rem;
135
+ flex-shrink: 0;
136
+ transition:
137
+ color 0.2s ease,
138
+ background-color 0.2s ease,
139
+ border-color 0.2s ease;
140
+ }
141
+
142
+ .icon-mask {
143
+ width: 100%;
144
+ height: 100%;
145
+
146
+ -webkit-mask-image: var(--icon-url);
147
+ mask-image: var(--icon-url);
148
+
149
+ -webkit-mask-size: contain;
150
+ mask-size: cover;
151
+
152
+ -webkit-mask-repeat: no-repeat;
153
+ mask-repeat: no-repeat;
154
+
155
+ -webkit-mask-position: center;
156
+ mask-position: center;
157
+
158
+ background-color: var(--sl-color-gray-2);
159
+ transition: background-color 0.2s ease;
160
+ }
161
+
162
+ a:hover .icon-mask,
163
+ a:focus-visible .icon-mask {
164
+ background-color: var(--sl-color-white);
165
+ }
166
+
167
+ a.starlight-sidebar-topics-current .icon-mask {
168
+ background-color: var(--gameface-cyan);
169
+ }
170
+
171
+ :global([data-theme="light"]) a.starlight-sidebar-topics-current {
172
+ color: var(--sl-color-accent-high);
173
+ }
174
+ :global([data-theme="light"]) a.starlight-sidebar-topics-current .icon-mask {
175
+ background-color: var(--sl-color-accent-high);
176
+ }
177
+
178
+ .text-icon {
179
+ font-size: 0.65rem;
180
+ font-weight: 800;
181
+ }
182
+
183
+ .version-badge {
184
+ display: inline-flex;
185
+ align-items: center;
186
+ gap: 0.4rem;
187
+ padding: 0.2rem 0.5rem;
188
+ background-color: var(--sl-color-gray-6);
189
+ border: 1px solid var(--sl-color-gray-5);
190
+ border-radius: 0.3rem;
191
+ color: var(--sl-color-gray-2);
192
+ font-size: 0.85rem;
193
+ font-weight: 700;
194
+ text-transform: uppercase;
195
+ }
196
+
197
+ .sidebar-divider {
198
+ margin-top: 1rem;
199
+ height: 1px;
200
+ border-top: 1px solid var(--sl-color-gray-5);
201
+ }
202
+
203
+ .label-wrapper {
204
+ text-transform: uppercase;
205
+ letter-spacing: 0.03em;
206
+ }
207
+ </style>
@@ -1,6 +1,8 @@
1
1
  ---
2
2
  import type { Props } from "@astrojs/starlight/props";
3
3
  import DefaultFooter from "@astrojs/starlight/components/Footer.astro";
4
+ import "vanilla-cookieconsent/dist/cookieconsent.css";
5
+ import getThemeConfig from "../internal/themeConfig";
4
6
 
5
7
  const currentYear = new Date().getFullYear();
6
8
 
@@ -10,6 +12,7 @@ const { pagination, editUrl, lastUpdated } = (Astro.locals as any)
10
12
  const hasPagination = !!(pagination?.prev || pagination?.next);
11
13
  const hasMeta = !!(editUrl || lastUpdated);
12
14
  const hasAnyFooterContent = hasPagination || hasMeta;
15
+ const { tagManagerId } = getThemeConfig();
13
16
  ---
14
17
 
15
18
  <footer
@@ -33,9 +36,10 @@ const hasAnyFooterContent = hasPagination || hasMeta;
33
36
  <strong>Coherent Labs</strong>. All rights reserved.
34
37
  </p>
35
38
  <div class="links">
36
- <a href="https://coherent-labs.com/privacy-policy" rel="noopener" target="_blank"
37
- >Privacy Policy</a
38
- >
39
+ <a
40
+ href="https://coherent-labs.com/privacy-policy"
41
+ rel="noopener"
42
+ target="_blank">Privacy Policy</a>
39
43
  </div>
40
44
  </div>
41
45
 
@@ -101,3 +105,129 @@ const hasAnyFooterContent = hasPagination || hasMeta;
101
105
  color: var(--sl-color-accent);
102
106
  }
103
107
  </style>
108
+
109
+ <script>
110
+ import { run } from "vanilla-cookieconsent";
111
+
112
+ const config = {
113
+ hideFromBots: true,
114
+ // See https://github.com/orestbida/cookieconsent#how-to-enablemanage-revisions
115
+ // Left for future reference if we change the consent.
116
+ // revision: 0,
117
+ cookie: {
118
+ name: "cc_cookie",
119
+ domain: location.hostname,
120
+ expiresAfterDays: 365,
121
+ },
122
+ categories: {
123
+ necessary: {
124
+ readOnly: true,
125
+ },
126
+ analytics: {
127
+ autoClear: {
128
+ cookies: [
129
+ {
130
+ name: /^_ga/, // regex: match all cookies starting with '_ga'
131
+ },
132
+ {
133
+ name: "_gid", // string: exact cookie name
134
+ },
135
+ ],
136
+ },
137
+ },
138
+ },
139
+ language: {
140
+ default: "en",
141
+ translations: {
142
+ en: {
143
+ consentModal: {
144
+ title: "We use cookies!",
145
+ description:
146
+ 'Hi, this website uses essential cookies to ensure its proper operation and tracking cookies to understand how you interact with it. The latter will be set only after consent. <a data-cc="show-preferencesModal" class="cc-link">Let me choose</a>',
147
+ acceptAllBtn: "Accept all",
148
+ acceptNecessaryBtn: "Reject all",
149
+ showPreferencesBtn: "Manage Individual preferences",
150
+ },
151
+ preferencesModal: {
152
+ title: "Cookie preferences",
153
+ acceptAllBtn: "Accept all",
154
+ acceptNecessaryBtn: "Reject all",
155
+ savePreferencesBtn: "Save settings",
156
+ closeIconLabel: "Close",
157
+ serviceCounterLabel: "Service|Services",
158
+ sections: [
159
+ {
160
+ title: "Cookie usage 📢",
161
+ description: `Cookies are used to ensure the basic functionalities of the website and to enhance your online experience. You can choose for each category to opt-in/out whenever you want. For more details relative to cookies and other sensitive data, please read the full <a href="/privacy-policy" class="cc-link" target="_blank">privacy policy</a>.`,
162
+ },
163
+ {
164
+ title: "Strictly necessary cookies",
165
+ description:
166
+ "These cookies are essential for the proper functioning of my website. Without these cookies, the website may not work properly.",
167
+ linkedCategory: "necessary",
168
+ },
169
+ {
170
+ title: "Performance and Analytics cookies",
171
+ description:
172
+ "These cookies allow the website to remember the choices you have made in the past.",
173
+ linkedCategory: "analytics",
174
+ cookieTable: {
175
+ caption: "Cookie table",
176
+ headers: {
177
+ name: "Cookie",
178
+ domain: "Domain",
179
+ desc: "Description",
180
+ duration: "Duration",
181
+ },
182
+ body: [
183
+ {
184
+ name: "_ga",
185
+ domain: "google.com",
186
+ desc: "This cookie is a Google Analytics persistent cookie.",
187
+ duration: "2 years",
188
+ },
189
+ {
190
+ name: "_gid",
191
+ domain: "google.com",
192
+ desc: "This cookie is a Google Analytics persistent cookie.",
193
+ duration: "1 day",
194
+ },
195
+ ],
196
+ },
197
+ },
198
+ ],
199
+ },
200
+ },
201
+ },
202
+ },
203
+ };
204
+
205
+ run(config);
206
+ </script>
207
+
208
+ <!-- Google tag (gtag.js) -->
209
+ {tagManagerId && (
210
+ <>
211
+ <script
212
+ type="text/plain"
213
+ data-category="analytics"
214
+ data-service="Google Analytics"
215
+ async
216
+ src={`https://www.googletagmanager.com/gtag/js?id=${tagManagerId}`}
217
+ ></script>
218
+
219
+ <script
220
+ type="text/plain"
221
+ data-category="analytics"
222
+ data-service="Google Analytics"
223
+ define:vars={{ tagManagerId }}
224
+ >
225
+ window.dataLayer = window.dataLayer || [];
226
+ function gtag() {
227
+ dataLayer.push(arguments);
228
+ }
229
+ gtag("js", new Date());
230
+ gtag("config", tagManagerId);
231
+ </script>
232
+ </>
233
+ )}
@@ -0,0 +1,14 @@
1
+ ---
2
+ import DefaultMarkdownContent from '@astrojs/starlight/components/MarkdownContent.astro';
3
+
4
+ const pathname = Astro.url.pathname.toLowerCase();
5
+ const isApiReference = pathname.includes('/api_reference') || pathname.includes('/api-reference');
6
+
7
+ const pageWeight = isApiReference ? "0.1" : "1.0";
8
+ ---
9
+
10
+ <div data-pagefind-weight={pageWeight} style="display: contents;">
11
+ <DefaultMarkdownContent {...Astro.props}>
12
+ <slot />
13
+ </DefaultMarkdownContent>
14
+ </div>