Skip to content

Commit a411da5

Browse files
committed
Different fixes and improvements
1 parent cb50a8a commit a411da5

25 files changed

Lines changed: 826 additions & 517 deletions

astro.config.mjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export default defineConfig({
2020
base: '/docs',
2121
outDir: './build',
2222
build: {
23-
assets: '_astro',
2423
inlineStylesheets: 'never',
2524
},
2625
vite: {
@@ -95,4 +94,4 @@ export default defineConfig({
9594
}
9695
})
9796
]
98-
});
97+
});

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
2-
"name": "cassiopeia",
2+
"name": "adapty-docs",
33
"type": "module",
44
"version": "0.0.1",
55
"scripts": {
6-
"dev": "npm run build:md && astro dev",
7-
"prebuild": "mkdir -p public && rm -rf public/FF_img public/img_webhook_flows && [ -d src/assets/shared/FF_img ] && cp -r src/assets/shared/FF_img public/ || true && [ -d src/content/docs/version-3.0/img_webhook_flows ] && cp -r src/content/docs/version-3.0/img_webhook_flows public/ || true",
6+
"dev": "npm run prebuild && npm run build:md && astro dev",
7+
"prebuild": "mkdir -p public/api-specs && rm -rf public/FF_img public/img_webhook_flows && [ -d src/assets/shared/FF_img ] && cp -r src/assets/shared/FF_img public/ || true && [ -d src/content/docs/version-3.0/img_webhook_flows ] && cp -r src/content/docs/version-3.0/img_webhook_flows public/ || true && [ -d src/api-reference/specs ] && cp -r src/api-reference/specs/* public/api-specs/ || true",
88
"build": "astro build && npm run build:md:prod",
99
"build:md": "node scripts/generate-md.mjs && node scripts/generate-llms.mjs",
1010
"build:md:prod": "node scripts/generate-md.mjs ../build && node scripts/generate-llms.mjs ../build",

public/api-specs/adapty-api.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2998,6 +2998,3 @@ components:
29982998
- count
29992999
- page
30003000
- pages
3001-
3002-
security:
3003-
- apikeyAuth: []

src/components/ArticleButtons.astro

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@
3535

3636
// Calculate MD URL
3737
let path = window.location.pathname.replace(/\/$/, '');
38-
if (path === '') path = '/what-is-adapty'; // Special case for root
38+
// Special case for root: handle both empty string and base URL
39+
if (path === '' || path === '/docs') {
40+
path = '/docs/what-is-adapty';
41+
}
3942

4043
const mdUrl = `${path}.md`;
4144

src/components/Footer.astro

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<!-- Header Section: Logo & Social -->
88
<div class="footer-header">
99
<a href="https://adapty.io" target="_blank" rel="noopener noreferrer" class="footer-logo">
10-
<img src="/logo.svg" alt="Adapty" class="footer-logo-img" />
10+
<img src={`${import.meta.env.BASE_URL}/logo.svg`.replace(/\/+/g, '/')} alt="Adapty" class="footer-logo-img" />
1111
</a>
1212

1313
<div class="footer-social">
@@ -45,7 +45,7 @@
4545
<div class="footer-column">
4646
<h3 class="footer-column-title">Adapty SDK Sample Apps</h3>
4747
<ul class="footer-column-list">
48-
<li><a href="/sample-apps">Sample apps</a></li>
48+
<li><a href={`${import.meta.env.BASE_URL}/sample-apps`.replace(/\/+/g, '/')}>Sample apps</a></li>
4949
</ul>
5050
</div>
5151

@@ -65,9 +65,9 @@
6565
<div class="footer-column">
6666
<h3 class="footer-column-title">API Reference</h3>
6767
<ul class="footer-column-list">
68-
<li><a href="/api-adapty">Server-side API</a></li>
69-
<li><a href="/api-web">Web API</a></li>
70-
<li><a href="/api-export-analytics">Analytics export API</a></li>
68+
<li><a href={`${import.meta.env.BASE_URL}/api-adapty`.replace(/\/+/g, '/')}>Server-side API</a></li>
69+
<li><a href={`${import.meta.env.BASE_URL}/api-web`.replace(/\/+/g, '/')}>Web API</a></li>
70+
<li><a href={`${import.meta.env.BASE_URL}/api-export-analytics`.replace(/\/+/g, '/')}>Analytics export API</a></li>
7171
</ul>
7272
</div>
7373

src/components/Header.astro

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ const links = [
1616

1717
<div class="flex items-center gap-12">
1818
<!-- Logo -->
19-
<a href={import.meta.env.BASE_URL} class="flex-shrink-0 block hover:opacity-80 transition-opacity">
20-
<img src={`${import.meta.env.BASE_URL}/logo.svg`} alt="Adapty" class="h-6 w-auto header-logo" />
19+
<a href={import.meta.env.BASE_URL.replace(/\/+$/, '') || '/'} class="flex-shrink-0 block hover:opacity-80 transition-opacity">
20+
<img src={`${import.meta.env.BASE_URL}/logo.svg`.replace(/\/+/g, '/')} alt="Adapty" class="h-6 w-auto header-logo" />
2121
</a>
2222

2323
<!-- Desktop Navigation -->
@@ -298,7 +298,7 @@ const links = [
298298
const mobileThemeBtn = document.getElementById('mobile-theme-toggle');
299299
if (mobileThemeBtn) {
300300
// Remove old listener by cloning
301-
const newBtn = mobileThemeBtn.cloneNode(true) as HTMLElement;
301+
const newBtn = mobileThemeBtn.cloneNode(true);
302302
mobileThemeBtn.parentNode?.replaceChild(newBtn, mobileThemeBtn);
303303

304304
const btn = document.getElementById('mobile-theme-toggle');

src/components/PlatformSwitcher.astro

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,23 +65,26 @@ function getTargetLink(platformId: string, targetLabel?: string, activeId?: stri
6565
activeId?.toLowerCase().includes('intro') ||
6666
activeId === 'what-is-adapty';
6767
68+
const baseUrl = import.meta.env.BASE_URL; // e.g. "/docs/"
69+
const normalizedBase = baseUrl.endsWith('/') ? baseUrl : `${baseUrl}/`;
70+
6871
// 1. If current is overview, always try to land on target's overview
6972
if (isCurrentOverview) {
7073
const targetOverview = findOverview(sidebarData);
71-
if (targetOverview) return `${import.meta.env.BASE_URL}/${targetOverview.id}`.replace(/\/+/g, '/');
74+
if (targetOverview) return `${normalizedBase}${targetOverview.id}`.replace(/\/+/g, '/');
7275
}
7376
7477
// 2. Otherwise, try to find matching label first (Topic Consistency)
7578
if (targetLabel) {
7679
const match = findItemByLabel(sidebarData, targetLabel);
77-
if (match) return `${import.meta.env.BASE_URL}/${match.id}`.replace(/\/+/g, '/');
80+
if (match) return `${normalizedBase}${match.id}`.replace(/\/+/g, '/');
7881
}
7982
8083
// 3. Last Fallback: Target platform's overview
8184
const overview = findOverview(sidebarData);
82-
if (overview) return `${import.meta.env.BASE_URL}/${overview.id}`.replace(/\/+/g, '/');
85+
if (overview) return `${normalizedBase}${overview.id}`.replace(/\/+/g, '/');
8386
84-
return `${import.meta.env.BASE_URL}/${platformId}-sdk-overview`.replace(/\/+/g, '/'); // Ultimate hardcoded fallback
87+
return `${normalizedBase}/${platformId}-sdk-overview`.replace(/\/+/g, '/'); // Ultimate hardcoded fallback
8588
}
8689
---
8790

src/components/Sidebar.astro

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,17 @@ function transformItems(items: any[]): any[] {
6868
}
6969
}
7070
71+
// Handle explicit links: /api-adapty -> /docs/api-adapty
72+
if (item.type === 'link' && item.href && item.href.startsWith('/')) {
73+
const baseUrl = import.meta.env.BASE_URL; // e.g. "/docs/"
74+
const normalizedBase = baseUrl.endsWith('/') ? baseUrl : `${baseUrl}/`;
75+
76+
if (!item.href.startsWith(normalizedBase) && item.href !== baseUrl && item.href !== normalizedBase.slice(0, -1)) {
77+
newItem.href = `${normalizedBase}${item.href.startsWith('/') ? item.href.slice(1) : item.href}`;
78+
}
79+
newItem.href = newItem.href.replace(/\/+/g, '/');
80+
}
81+
7182
// Handle category with link
7283
if (item.type === 'category' && item.link?.id && !item.href) {
7384
const customSlug = docSlugs.get(item.link.id);

src/components/SidebarItem.astro

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,9 @@ const { item, activeId, depth = 0 } = Astro.props;
99
1010
const isCategory = item.type === 'category';
1111
12-
// Calculate href automatically if not provided
12+
// Use href provided by Sidebar.astro (which already handles base URL)
1313
const getHref = (item: any) => {
14-
if (item.type === 'link') return item.href;
15-
if (item.href) return item.href;
16-
const id = item.id || item.link?.id;
17-
if (id) return `${import.meta.env.BASE_URL}/${id}`.replace(/\/+/g, '/');
18-
return null;
14+
return item.href || null;
1915
};
2016
2117
const itemHref = getHref(item);
@@ -218,8 +214,8 @@ const textColor = getTextColor(depth, isActive);
218214

219215
toggleButtons.forEach(button => {
220216
const categoryId = button.getAttribute('data-category-id');
221-
const itemsList = document.querySelector(`.category-items-container[data-category-id="${categoryId}"]`) as HTMLElement;
222-
const svg = button.querySelector('svg') as SVGElement;
217+
const itemsList = document.querySelector(`.category-items-container[data-category-id="${categoryId}"]`);
218+
const svg = button.querySelector('svg');
223219

224220
if (!itemsList || !svg) return;
225221

@@ -252,9 +248,9 @@ const textColor = getTextColor(depth, isActive);
252248

253249
link.addEventListener('click', (e) => {
254250
const categoryId = link.getAttribute('data-category-id');
255-
const itemsList = document.querySelector(`.category-items-container[data-category-id="${categoryId}"]`) as HTMLElement;
251+
const itemsList = document.querySelector(`.category-items-container[data-category-id="${categoryId}"]`);
256252
const toggleButton = document.querySelector(`.category-toggle[data-category-id="${categoryId}"]`);
257-
const svg = toggleButton?.querySelector('svg') as SVGElement;
253+
const svg = toggleButton?.querySelector('svg');
258254

259255
if (!itemsList || !svg) return;
260256

src/components/reusable/AddAudience.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11

2-
32
:::note
43
To proceed, ensure that you created a paywall, onboarding, or A/B test you want to run and an audience, you'd like to specify.
54
:::
@@ -8,7 +7,7 @@ To proceed, ensure that you created a paywall, onboarding, or A/B test you want
87
2. If you want to use more than one audience in the placement to create personalized paywalls tailored to different user groups, click the **Add audience** button and choose the desired user segment from the list.
98

109
<Zoom>
11-
<img src="placement-add-audience.webp"
10+
<img src="/img/placement-add-audience.webp"
1211
style={{
1312
border: '1px solid #727272', /* border width and color */
1413
width: '700px', /* image width */

0 commit comments

Comments
 (0)