@eldrajs/theme-nuxt 0.2.0 → 0.3.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/CHANGELOG.md +77 -0
- package/dist/module.d.mts +48 -2
- package/dist/module.d.ts +48 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +178 -13
- package/dist/runtime/analytics.d.ts +83 -0
- package/dist/runtime/analytics.js +83 -0
- package/dist/runtime/analyticsPlugin.d.ts +15 -0
- package/dist/runtime/analyticsPlugin.js +21 -0
- package/dist/runtime/catalog.d.ts +5 -0
- package/dist/runtime/catalog.js +6 -3
- package/dist/runtime/composables/useEldraAnalytics.d.ts +10 -0
- package/dist/runtime/composables/useEldraAnalytics.js +6 -0
- package/dist/runtime/composables/useEldraForms.d.ts +8 -0
- package/dist/runtime/composables/useEldraForms.js +5 -0
- package/dist/runtime/composables/useEldraSeo.d.ts +27 -0
- package/dist/runtime/composables/useEldraSeo.js +41 -0
- package/dist/runtime/composables/useStructuredData.d.ts +35 -0
- package/dist/runtime/composables/useStructuredData.js +55 -0
- package/dist/runtime/crawl.d.ts +29 -0
- package/dist/runtime/crawl.js +50 -0
- package/dist/runtime/crawlOutput.d.ts +54 -0
- package/dist/runtime/crawlOutput.js +96 -0
- package/dist/runtime/forms.d.ts +29 -0
- package/dist/runtime/forms.js +154 -0
- package/dist/runtime/localeState.d.ts +6 -4
- package/dist/runtime/localeState.js +7 -15
- package/dist/runtime/plugin.js +6 -1
- package/dist/runtime/redirects.d.ts +74 -0
- package/dist/runtime/redirects.js +190 -0
- package/dist/runtime/seo.d.ts +23 -0
- package/dist/runtime/seo.js +95 -0
- package/dist/runtime/seoHead.d.ts +27 -0
- package/dist/runtime/seoHead.js +28 -0
- package/dist/runtime/siteProfile.d.ts +56 -0
- package/dist/runtime/siteProfile.js +69 -0
- package/package.json +6 -5
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { EldraClient } from '@eldrajs/sdk';
|
|
2
|
+
/**
|
|
3
|
+
* The site's public profile exactly as `GET /site/v1/site-profile` answers it (and Studio's
|
|
4
|
+
* `PUT /sites/{siteId}/site-profile` stores it): what the structured data's `Organization` says
|
|
5
|
+
* about the shop. Every field may be unset; the build fills the gaps (`resolveSiteProfile`).
|
|
6
|
+
*/
|
|
7
|
+
export interface SiteProfileSetting {
|
|
8
|
+
revision: number;
|
|
9
|
+
/** The organisation's display name, or `null` for the site name. */
|
|
10
|
+
name: string | null;
|
|
11
|
+
/** A logo override (absolute), or `null` for the site icon's 512 px rendering. */
|
|
12
|
+
logoUrl: string | null;
|
|
13
|
+
/** Social profile URLs (https). */
|
|
14
|
+
sameAs: string[];
|
|
15
|
+
contact: {
|
|
16
|
+
email: string | null;
|
|
17
|
+
telephone: string | null;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/** What a page's `Organization` is written from: gaps already filled, `name` never empty. */
|
|
21
|
+
export interface ResolvedSiteProfile {
|
|
22
|
+
name: string;
|
|
23
|
+
logoUrl: string | null;
|
|
24
|
+
sameAs: string[];
|
|
25
|
+
contact: {
|
|
26
|
+
email: string | null;
|
|
27
|
+
telephone: string | null;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The slice of an `@eldrajs/sdk` client this read needs — a whole `EldraClient` satisfies it. The
|
|
32
|
+
* same narrow shape as `SiteIconsReader`: `GET /site/v1/site-profile` is a site-module read with no
|
|
33
|
+
* typed `features.*` method, so the client's generic `request` carries it.
|
|
34
|
+
*/
|
|
35
|
+
export interface SiteProfileReader {
|
|
36
|
+
request: EldraClient['request'];
|
|
37
|
+
}
|
|
38
|
+
/** The one line a build prints when it could not read the platform's site profile. */
|
|
39
|
+
export declare const SITE_PROFILE_WARNING = "[eldra] could not read the platform\u2019s site profile \u2014 the Organization structured data uses the site name and icon only";
|
|
40
|
+
/** How long the build waits for the answer; see `READ_TIMEOUT_MS` in `./designTokens.ts`. */
|
|
41
|
+
export declare const READ_TIMEOUT_MS = 10000;
|
|
42
|
+
/**
|
|
43
|
+
* The platform's site profile, or `null`. Fail-soft exactly like `readSiteIcons`: no client, an
|
|
44
|
+
* unreachable gateway, a timeout and an answer that is not the documented shape all end in `null`
|
|
45
|
+
* and **one** warning; the build still writes valid markup, from the site name and icon.
|
|
46
|
+
*/
|
|
47
|
+
export declare function readSiteProfile(reader: SiteProfileReader | null, warn?: (message: string) => void): Promise<SiteProfileSetting | null>;
|
|
48
|
+
/**
|
|
49
|
+
* Fills in what the profile leaves unset: the name falls back to the site name, the logo to the
|
|
50
|
+
* site icon's 512 px rendering (`icon512`, not the maskable one: Google wants a logo, not a
|
|
51
|
+
* padded launcher icon). Always answers, so a build whose read failed still has an Organization.
|
|
52
|
+
*/
|
|
53
|
+
export declare function resolveSiteProfile(setting: SiteProfileSetting | null, defaults: {
|
|
54
|
+
siteName: string;
|
|
55
|
+
iconLogoUrl: string | null;
|
|
56
|
+
}): ResolvedSiteProfile;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export const SITE_PROFILE_WARNING = "[eldra] could not read the platform\u2019s site profile \u2014 the Organization structured data uses the site name and icon only";
|
|
2
|
+
export const READ_TIMEOUT_MS = 1e4;
|
|
3
|
+
export async function readSiteProfile(reader, warn = console.warn) {
|
|
4
|
+
const read = reader === null ? { setting: null, cause: null } : await readOrNull(reader);
|
|
5
|
+
if (read.setting === null) {
|
|
6
|
+
warn(read.cause === null ? SITE_PROFILE_WARNING : `${SITE_PROFILE_WARNING} (${read.cause})`);
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
return read.setting;
|
|
10
|
+
}
|
|
11
|
+
async function readOrNull(reader) {
|
|
12
|
+
const controller = new AbortController();
|
|
13
|
+
const timer = setTimeout(
|
|
14
|
+
() => controller.abort(new Error(`timed out after ${READ_TIMEOUT_MS}ms`)),
|
|
15
|
+
READ_TIMEOUT_MS
|
|
16
|
+
);
|
|
17
|
+
try {
|
|
18
|
+
const response = await reader.request({
|
|
19
|
+
path: "/site/v1/site-profile",
|
|
20
|
+
signal: controller.signal
|
|
21
|
+
});
|
|
22
|
+
const setting = toSiteProfile(response);
|
|
23
|
+
return {
|
|
24
|
+
setting,
|
|
25
|
+
cause: setting === null ? "the platform published an unusable response" : null
|
|
26
|
+
};
|
|
27
|
+
} catch (error) {
|
|
28
|
+
return { setting: null, cause: error instanceof Error ? error.message : String(error) };
|
|
29
|
+
} finally {
|
|
30
|
+
clearTimeout(timer);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function toSiteProfile(value) {
|
|
34
|
+
if (typeof value !== "object" || value === null) return null;
|
|
35
|
+
const record = value;
|
|
36
|
+
if (typeof record.revision !== "number" || !Number.isFinite(record.revision)) return null;
|
|
37
|
+
const { name, logoUrl, sameAs, contact } = record;
|
|
38
|
+
if (name !== null && typeof name !== "string") return null;
|
|
39
|
+
if (logoUrl !== null && typeof logoUrl !== "string") return null;
|
|
40
|
+
if (!Array.isArray(sameAs) || sameAs.some((url) => typeof url !== "string")) return null;
|
|
41
|
+
if (typeof contact !== "object" || contact === null) return null;
|
|
42
|
+
const { email, telephone } = contact;
|
|
43
|
+
if (email !== null && typeof email !== "string") return null;
|
|
44
|
+
if (telephone !== null && typeof telephone !== "string") return null;
|
|
45
|
+
return {
|
|
46
|
+
revision: record.revision,
|
|
47
|
+
name: name === null ? null : name.trim() || null,
|
|
48
|
+
logoUrl: logoUrl !== null && isHttpsUrl(logoUrl) ? logoUrl : null,
|
|
49
|
+
// A profile link that is not https is dropped, not repaired: a wrong `sameAs` claims an
|
|
50
|
+
// identity the shop may not hold.
|
|
51
|
+
sameAs: sameAs.map((url) => url.trim()).filter(isHttpsUrl),
|
|
52
|
+
contact: { email: email?.trim() || null, telephone: telephone?.trim() || null }
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function isHttpsUrl(value) {
|
|
56
|
+
try {
|
|
57
|
+
return new URL(value).protocol === "https:";
|
|
58
|
+
} catch {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
export function resolveSiteProfile(setting, defaults) {
|
|
63
|
+
return {
|
|
64
|
+
name: setting?.name ?? defaults.siteName,
|
|
65
|
+
logoUrl: setting?.logoUrl ?? defaults.iconLogoUrl,
|
|
66
|
+
sameAs: setting?.sameAs ?? [],
|
|
67
|
+
contact: setting?.contact ?? { email: null, telephone: null }
|
|
68
|
+
};
|
|
69
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eldrajs/theme-nuxt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Nuxt module for Eldra themes: wires @eldrajs/vite-plugin-theme, the gateway client, draft overlays and the Studio preview bridge into a Nuxt 4 site.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cms",
|
|
@@ -46,16 +46,17 @@
|
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@nuxt/kit": "^4.0.0",
|
|
48
48
|
"defu": "^6.1.4",
|
|
49
|
-
"@eldrajs/sdk": "^0.
|
|
50
|
-
"@eldrajs/theme
|
|
51
|
-
"@eldrajs/theme-
|
|
52
|
-
"@eldrajs/
|
|
49
|
+
"@eldrajs/sdk": "^0.3.0",
|
|
50
|
+
"@eldrajs/vite-plugin-theme": "^0.3.0",
|
|
51
|
+
"@eldrajs/theme-core": "^0.3.0",
|
|
52
|
+
"@eldrajs/theme-vue": "^0.2.1"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@nuxt/module-builder": "^0.8.4",
|
|
56
56
|
"@nuxt/schema": "^4.0.0",
|
|
57
57
|
"@playwright/test": "1.62.1",
|
|
58
58
|
"execa": "^9.5.2",
|
|
59
|
+
"jsdom": "30.1.0",
|
|
59
60
|
"nuxt": "^4.0.0"
|
|
60
61
|
},
|
|
61
62
|
"engines": {
|