@thenewdynamic/astro-seo 0.1.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 +52 -0
- package/dist/core/getData.d.ts +3 -0
- package/dist/core/getData.d.ts.map +1 -0
- package/dist/core/getData.js +87 -0
- package/dist/core/getData.js.map +1 -0
- package/dist/core/getMetasData.d.ts +4 -0
- package/dist/core/getMetasData.d.ts.map +1 -0
- package/dist/core/getMetasData.js +43 -0
- package/dist/core/getMetasData.js.map +1 -0
- package/dist/core/getStructuredData.d.ts +4 -0
- package/dist/core/getStructuredData.d.ts.map +1 -0
- package/dist/core/getStructuredData.js +10 -0
- package/dist/core/getStructuredData.js.map +1 -0
- package/dist/core/index.d.ts +3 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +10 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/sd.d.ts +5 -0
- package/dist/core/sd.d.ts.map +1 -0
- package/dist/core/sd.js +47 -0
- package/dist/core/sd.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +100 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +8 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +26 -0
- package/dist/utils.js.map +1 -0
- package/package.json +57 -0
- package/src/components/SEO.astro +15 -0
package/README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# @thenewdynamic/astro-seo
|
|
2
|
+
|
|
3
|
+
An Astro integration for SEO meta tags and structured data. Wraps `astro-seo` internally and provides a simple, configuration-driven API.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Automatic SEO tags** — generates meta tags for Open Graph, Twitter, and more
|
|
8
|
+
- **JSON-LD structured data** — schema.org support for events, organizations, articles, and more
|
|
9
|
+
- **Virtual module configuration** — centralized setup via `seo.config.ts`
|
|
10
|
+
- **Flexible image resolution** — customize how images are transformed for meta tags
|
|
11
|
+
- **Per-entry transforms** — override SEO fields by content type
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @thenewdynamic/astro-seo
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Quick Setup
|
|
20
|
+
|
|
21
|
+
**`astro.config.mjs`**
|
|
22
|
+
```js
|
|
23
|
+
import tndSeo from '@thenewdynamic/astro-seo'
|
|
24
|
+
|
|
25
|
+
export default defineConfig({
|
|
26
|
+
integrations: [tndSeo()]
|
|
27
|
+
})
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**`seo.config.ts`** (in your project root)
|
|
31
|
+
```ts
|
|
32
|
+
import type { SeoUserConfig } from '@thenewdynamic/astro-seo'
|
|
33
|
+
|
|
34
|
+
export default {
|
|
35
|
+
site: new URL('https://example.com'),
|
|
36
|
+
} satisfies SeoUserConfig
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**In your layout**
|
|
40
|
+
```astro
|
|
41
|
+
import SEO from '@thenewdynamic/astro-seo/SEO.astro'
|
|
42
|
+
|
|
43
|
+
<SEO entry={entry} />
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Configuration
|
|
47
|
+
|
|
48
|
+
See `ARCHITECTURE.md` for detailed configuration options, API reference, and architecture notes.
|
|
49
|
+
|
|
50
|
+
## License
|
|
51
|
+
|
|
52
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getData.d.ts","sourceRoot":"","sources":["../../src/core/getData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAGnE,eAAO,MAAM,WAAW,GAAI,QAAQ,aAAa,MAAM,OAAO,QAAQ,KAAG,OAkIxE,CAAA"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { escapeString, makeAbsUrl, isHome, getExcerpt } from '../utils.js';
|
|
2
|
+
export const makeGetData = (config) => (entry) => {
|
|
3
|
+
const { site, resolveImage, transformEntry } = config;
|
|
4
|
+
const { url: baseURL } = site;
|
|
5
|
+
const absUrl = makeAbsUrl(baseURL);
|
|
6
|
+
const { title: siteTitle, description: siteDescription, image: siteImage, seo: { twitterHandle: siteTwitterHandle } = {}, prod, } = site;
|
|
7
|
+
let { title = 'Missing', type = 'website', _type, _updatedAt, time_start, time_end, venue, date, url, description, descriptionText, locale = 'en_US', image, authors = [], bodyText, translation, twitterCard = 'summary_large_image', twitterHandle = siteTwitterHandle, twitterCreatorHandle = siteTwitterHandle, } = entry;
|
|
8
|
+
const seo = entry.seo || {};
|
|
9
|
+
const { title: seoTitle, description: seoDescription, image: seoImage, canonical: seoCanonical, private: seoPrivate = false, } = seo;
|
|
10
|
+
type = _type === 'post' ? 'article' : 'website';
|
|
11
|
+
url = url ? absUrl(url) || undefined : undefined;
|
|
12
|
+
const isPrivate = seoPrivate || !(prod?.() ?? true);
|
|
13
|
+
const canonical = seoCanonical || url;
|
|
14
|
+
title = seoTitle
|
|
15
|
+
? seoTitle
|
|
16
|
+
: title
|
|
17
|
+
? escapeString(title)
|
|
18
|
+
: siteTitle ?? 'Missing';
|
|
19
|
+
description = seoDescription
|
|
20
|
+
? seoDescription
|
|
21
|
+
: descriptionText
|
|
22
|
+
? escapeString(descriptionText)
|
|
23
|
+
: description && typeof description === 'string'
|
|
24
|
+
? escapeString(description)
|
|
25
|
+
: bodyText
|
|
26
|
+
? getExcerpt(bodyText, 300)
|
|
27
|
+
: siteDescription;
|
|
28
|
+
let ogTitle = title;
|
|
29
|
+
if (siteTitle && !isHome(entry)) {
|
|
30
|
+
title = `${title} | ${siteTitle}`;
|
|
31
|
+
}
|
|
32
|
+
else if (isHome(entry)) {
|
|
33
|
+
title = site.title;
|
|
34
|
+
ogTitle = site.title;
|
|
35
|
+
}
|
|
36
|
+
const resolvedSiteImage = siteImage;
|
|
37
|
+
image = seoImage || image || resolvedSiteImage;
|
|
38
|
+
let imageAlt = '';
|
|
39
|
+
if (image && typeof image !== 'string') {
|
|
40
|
+
const img = image;
|
|
41
|
+
imageAlt = img.altText ?? '';
|
|
42
|
+
image = resolveImage
|
|
43
|
+
? resolveImage(img, { width: 1000 })
|
|
44
|
+
: (img.src ?? img.url ?? '');
|
|
45
|
+
}
|
|
46
|
+
else if (image && typeof image === 'string') {
|
|
47
|
+
image = baseURL + image;
|
|
48
|
+
}
|
|
49
|
+
const languageAlternates = translation
|
|
50
|
+
? [{ href: translation.url, hrefLang: translation.lang }]
|
|
51
|
+
: undefined;
|
|
52
|
+
const localeAlternate = translation ? [translation.lang] : undefined;
|
|
53
|
+
let output = {
|
|
54
|
+
_type,
|
|
55
|
+
title,
|
|
56
|
+
publishedTime: date,
|
|
57
|
+
modifiedTime: _updatedAt,
|
|
58
|
+
authors: authors?.length
|
|
59
|
+
? authors.map((a) => ({ name: a.title ?? a.name ?? '', url: a.url ? absUrl(a.url) : false }))
|
|
60
|
+
: [],
|
|
61
|
+
description,
|
|
62
|
+
canonical,
|
|
63
|
+
noindex: isPrivate,
|
|
64
|
+
nofollow: isPrivate,
|
|
65
|
+
charset: 'UTF-8',
|
|
66
|
+
ogTitle,
|
|
67
|
+
type,
|
|
68
|
+
image: image,
|
|
69
|
+
imageAlt,
|
|
70
|
+
url,
|
|
71
|
+
locale: locale,
|
|
72
|
+
localeAlternate,
|
|
73
|
+
languageAlternates,
|
|
74
|
+
siteTitle: siteTitle ?? '',
|
|
75
|
+
twitterCard: twitterCard,
|
|
76
|
+
twitterHandle: twitterHandle,
|
|
77
|
+
twitterCreatorHandle: twitterCreatorHandle,
|
|
78
|
+
venue,
|
|
79
|
+
timeStart: time_start,
|
|
80
|
+
timeEnd: time_end,
|
|
81
|
+
};
|
|
82
|
+
if (transformEntry) {
|
|
83
|
+
output = { ...output, ...transformEntry(entry) };
|
|
84
|
+
}
|
|
85
|
+
return output;
|
|
86
|
+
};
|
|
87
|
+
//# sourceMappingURL=getData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getData.js","sourceRoot":"","sources":["../../src/core/getData.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE1E,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,MAAqB,EAAE,EAAE,CAAC,CAAC,KAAe,EAAW,EAAE;IACjF,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,cAAc,EAAE,GAAG,MAAM,CAAA;IACrD,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;IAC7B,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO,CAAC,CAAA;IAElC,MAAM,EACJ,KAAK,EAAE,SAAS,EAChB,WAAW,EAAE,eAAe,EAC5B,KAAK,EAAE,SAAS,EAChB,GAAG,EAAE,EAAE,aAAa,EAAE,iBAAiB,EAAE,GAAG,EAAE,EAC9C,IAAI,GACL,GAAG,IAAI,CAAA;IAER,IAAI,EACF,KAAK,GAAG,SAAS,EACjB,IAAI,GAAG,SAAS,EAChB,KAAK,EACL,UAAU,EACV,UAAU,EACV,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,GAAG,EACH,WAAW,EACX,eAAe,EACf,MAAM,GAAG,OAAO,EAChB,KAAK,EACL,OAAO,GAAG,EAAE,EACZ,QAAQ,EACR,WAAW,EACX,WAAW,GAAG,qBAAqB,EACnC,aAAa,GAAG,iBAAiB,EACjC,oBAAoB,GAAG,iBAAiB,GACzC,GAAG,KAAK,CAAA;IAET,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,IAAI,EAAE,CAAA;IAC3B,MAAM,EACJ,KAAK,EAAE,QAAQ,EACf,WAAW,EAAE,cAAc,EAC3B,KAAK,EAAE,QAAQ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AC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;YAC7F,CAAC,CAAC,EAAE;QACN,WAAW;QACX,SAAS;QACT,OAAO,EAAE,SAAS;QAClB,QAAQ,EAAE,SAAS;QACnB,OAAO,EAAE,OAAO;QAChB,OAAO;QACP,IAAI;QACJ,KAAK,EAAE,KAA2B;QAClC,QAAQ;QACR,GAAG;QACH,MAAM,EAAE,MAAgB;QACxB,eAAe;QACf,kBAAkB;QAClB,SAAS,EAAE,SAAS,IAAI,EAAE;QAC1B,WAAW,EAAE,WAAqB;QAClC,aAAa,EAAE,aAAmC;QAClD,oBAAoB,EAAE,oBAA0C;QAChE,KAAK;QACL,SAAS,EAAE,UAAU;QACrB,OAAO,EAAE,QAAQ;KAClB,CAAA;IAED,IAAI,cAAc,EAAE,CAAC;QACnB,MAAM,GAAG,EAAE,GAAG,MAAM,EAAE,GAAG,cAAc,CAAC,KAAK,CAAC,EAAE,CAAA;IAClD,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getMetasData.d.ts","sourceRoot":"","sources":["../../src/core/getMetasData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE/C,eAAO,MAAM,gBAAgB,GAC1B,SAAS,UAAU,CAAC,OAAO,WAAW,CAAC,MACvC,OAAO,QAAQ,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAgExC,CAAA"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export const makeGetMetasData = (getData) => (entry) => {
|
|
2
|
+
const { title, description, canonical, noindex, nofollow, charset, ogTitle, type, authors, publishedTime, modifiedTime, image, imageAlt, url, locale, localeAlternate, languageAlternates, siteTitle, twitterCard, twitterHandle, twitterCreatorHandle, } = getData(entry);
|
|
3
|
+
return {
|
|
4
|
+
title,
|
|
5
|
+
description,
|
|
6
|
+
canonical,
|
|
7
|
+
noindex,
|
|
8
|
+
nofollow,
|
|
9
|
+
charset,
|
|
10
|
+
languageAlternates,
|
|
11
|
+
openGraph: {
|
|
12
|
+
basic: {
|
|
13
|
+
title: ogTitle,
|
|
14
|
+
type,
|
|
15
|
+
image,
|
|
16
|
+
url,
|
|
17
|
+
},
|
|
18
|
+
optional: {
|
|
19
|
+
locale,
|
|
20
|
+
localeAlternate,
|
|
21
|
+
description,
|
|
22
|
+
siteName: siteTitle,
|
|
23
|
+
},
|
|
24
|
+
image: {
|
|
25
|
+
alt: imageAlt,
|
|
26
|
+
},
|
|
27
|
+
...(type === 'article'
|
|
28
|
+
? {
|
|
29
|
+
publishedTime,
|
|
30
|
+
modifiedTime,
|
|
31
|
+
authors: authors.map((a) => a.name),
|
|
32
|
+
}
|
|
33
|
+
: {}),
|
|
34
|
+
},
|
|
35
|
+
twitter: {
|
|
36
|
+
description,
|
|
37
|
+
card: twitterCard,
|
|
38
|
+
site: twitterHandle ? '@' + twitterHandle : undefined,
|
|
39
|
+
creator: twitterCreatorHandle ? '@' + twitterCreatorHandle : undefined,
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=getMetasData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getMetasData.js","sourceRoot":"","sources":["../../src/core/getMetasData.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,gBAAgB,GAC3B,CAAC,OAAuC,EAAE,EAAE,CAC5C,CAAC,KAAe,EAA2B,EAAE;IAC3C,MAAM,EACJ,KAAK,EACL,WAAW,EACX,SAAS,EACT,OAAO,EACP,QAAQ,EACR,OAAO,EACP,OAAO,EACP,IAAI,EACJ,OAAO,EACP,aAAa,EACb,YAAY,EACZ,KAAK,EACL,QAAQ,EACR,GAAG,EACH,MAAM,EACN,eAAe,EACf,kBAAkB,EAClB,SAAS,EACT,WAAW,EACX,aAAa,EACb,oBAAoB,GACrB,GAAG,OAAO,CAAC,KAAK,CAAC,CAAA;IAElB,OAAO;QACL,KAAK;QACL,WAAW;QACX,SAAS;QACT,OAAO;QACP,QAAQ;QACR,OAAO;QACP,kBAAkB;QAClB,SAAS,EAAE;YACT,KAAK,EAAE;gBACL,KAAK,EAAE,OAAO;gBACd,IAAI;gBACJ,KAAK;gBACL,GAAG;aACJ;YACD,QAAQ,EAAE;gBACR,MAAM;gBACN,eAAe;gBACf,WAAW;gBACX,QAAQ,EAAE,SAAS;aACpB;YACD,KAAK,EAAE;gBACL,GAAG,EAAE,QAAQ;aACd;YACD,GAAG,CAAC,IAAI,KAAK,SAAS;gBACpB,CAAC,CAAC;oBACE,aAAa;oBACb,YAAY;oBACZ,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;iBACpC;gBACH,CAAC,CAAC,EAAE,CAAC;SACR;QACD,OAAO,EAAE;YACP,WAAW;YACX,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,GAAG,aAAa,CAAC,CAAC,CAAC,SAAS;YACrD,OAAO,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,GAAG,oBAAoB,CAAC,CAAC,CAAC,SAAS;SACvE;KACF,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SeoEntry } from '../types.js';
|
|
2
|
+
import type { makeGetData } from './getData.js';
|
|
3
|
+
export declare const makeGetStructuredData: (getData: ReturnType<typeof makeGetData>) => (entry: SeoEntry) => Record<string, unknown>;
|
|
4
|
+
//# sourceMappingURL=getStructuredData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getStructuredData.d.ts","sourceRoot":"","sources":["../../src/core/getStructuredData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAG/C,eAAO,MAAM,qBAAqB,GAC/B,SAAS,UAAU,CAAC,OAAO,WAAW,CAAC,MACvC,OAAO,QAAQ,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CASxC,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { parseBase, parseEvent } from './sd.js';
|
|
2
|
+
export const makeGetStructuredData = (getData) => (entry) => {
|
|
3
|
+
const data = getData(entry);
|
|
4
|
+
let output = parseBase(data);
|
|
5
|
+
if (data._type === 'event') {
|
|
6
|
+
output = { ...output, ...parseEvent(data) };
|
|
7
|
+
}
|
|
8
|
+
return output;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=getStructuredData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getStructuredData.js","sourceRoot":"","sources":["../../src/core/getStructuredData.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAE/C,MAAM,CAAC,MAAM,qBAAqB,GAChC,CAAC,OAAuC,EAAE,EAAE,CAC5C,CAAC,KAAe,EAA2B,EAAE;IAC3C,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,CAAA;IAC3B,IAAI,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,CAAA;IAE5B,IAAI,IAAI,CAAC,KAAK,KAAK,OAAO,EAAE,CAAC;QAC3B,MAAM,GAAG,EAAE,GAAG,MAAM,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC,EAAE,CAAA;IAC7C,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAK1D,eAAO,MAAM,cAAc,GAAI,QAAQ,aAAa,KAAG,QAKtD,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { makeGetData } from './getData.js';
|
|
2
|
+
import { makeGetMetasData } from './getMetasData.js';
|
|
3
|
+
import { makeGetStructuredData } from './getStructuredData.js';
|
|
4
|
+
export const createSeoUtils = (config) => {
|
|
5
|
+
const getData = makeGetData(config);
|
|
6
|
+
const getMetasData = makeGetMetasData(getData);
|
|
7
|
+
const getStructuredData = makeGetStructuredData(getData);
|
|
8
|
+
return { getData, getMetasData, getStructuredData };
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAA;AAE9D,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAqB,EAAY,EAAE;IAChE,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,CAAC,CAAA;IACnC,MAAM,YAAY,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAC9C,MAAM,iBAAiB,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAA;IACxD,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,CAAA;AACrD,CAAC,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SeoData } from '../types.js';
|
|
2
|
+
export declare const parseBase: (data: SeoData) => Record<string, unknown>;
|
|
3
|
+
export declare const parseVenue: (data: Record<string, unknown>) => Record<string, unknown>;
|
|
4
|
+
export declare const parseEvent: (data: SeoData) => Record<string, unknown>;
|
|
5
|
+
//# sourceMappingURL=sd.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sd.d.ts","sourceRoot":"","sources":["../../src/core/sd.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAE1C,eAAO,MAAM,SAAS,GAAI,MAAM,OAAO,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAsB/D,CAAA;AAED,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAchF,CAAA;AAED,eAAO,MAAM,UAAU,GAAI,MAAM,OAAO,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAQhE,CAAA"}
|
package/dist/core/sd.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export const parseBase = (data) => {
|
|
2
|
+
const { description, ogTitle, type, publishedTime, modifiedTime, image, authors, url } = data;
|
|
3
|
+
return {
|
|
4
|
+
'@context': 'https://schema.org',
|
|
5
|
+
'@type': type,
|
|
6
|
+
headline: ogTitle,
|
|
7
|
+
url,
|
|
8
|
+
image: [image],
|
|
9
|
+
description,
|
|
10
|
+
...(authors?.length ? {
|
|
11
|
+
author: authors.map(({ name, url }) => ({
|
|
12
|
+
'@type': 'Person',
|
|
13
|
+
name,
|
|
14
|
+
url,
|
|
15
|
+
}))
|
|
16
|
+
} : {}),
|
|
17
|
+
...(type === 'article' ? {
|
|
18
|
+
datePublished: publishedTime,
|
|
19
|
+
dateModified: modifiedTime,
|
|
20
|
+
} : {}),
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export const parseVenue = (data) => {
|
|
24
|
+
const { title, address_1: address, city, country, state, zip } = data;
|
|
25
|
+
return {
|
|
26
|
+
'@type': 'Place',
|
|
27
|
+
name: title,
|
|
28
|
+
address: {
|
|
29
|
+
'@type': 'PostalAddress',
|
|
30
|
+
streetAddress: address,
|
|
31
|
+
addressLocality: city,
|
|
32
|
+
postalCode: zip,
|
|
33
|
+
addressRegion: state,
|
|
34
|
+
addressCountry: country,
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export const parseEvent = (data) => {
|
|
39
|
+
const { timeStart, timeEnd, venue } = data;
|
|
40
|
+
return {
|
|
41
|
+
'@type': 'Event',
|
|
42
|
+
startDate: timeStart,
|
|
43
|
+
endDate: timeEnd,
|
|
44
|
+
...(venue ? { location: parseVenue(venue) } : {}),
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=sd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sd.js","sourceRoot":"","sources":["../../src/core/sd.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,IAAa,EAA2B,EAAE;IAClE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;IAE7F,OAAO;QACL,UAAU,EAAE,oBAAoB;QAChC,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,OAAO;QACjB,GAAG;QACH,KAAK,EAAE,CAAC,KAAK,CAAC;QACd,WAAW;QACX,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;YACpB,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;gBACtC,OAAO,EAAE,QAAQ;gBACjB,IAAI;gBACJ,GAAG;aACJ,CAAC,CAAC;SACJ,CAAC,CAAC,CAAC,EAAE,CAAC;QACP,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC;YACvB,aAAa,EAAE,aAAa;YAC5B,YAAY,EAAE,YAAY;SAC3B,CAAC,CAAC,CAAC,EAAE,CAAC;KACR,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAA6B,EAA2B,EAAE;IACnF,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,IAA8B,CAAA;IAC/F,OAAO;QACL,OAAO,EAAE,OAAO;QAChB,IAAI,EAAE,KAAK;QACX,OAAO,EAAE;YACP,OAAO,EAAE,eAAe;YACxB,aAAa,EAAE,OAAO;YACtB,eAAe,EAAE,IAAI;YACrB,UAAU,EAAE,GAAG;YACf,aAAa,EAAE,KAAK;YACpB,cAAc,EAAE,OAAO;SACxB;KACF,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAa,EAA2B,EAAE;IACnE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,IAAI,CAAA;IAC1C,OAAO;QACL,OAAO,EAAE,OAAO;QAChB,SAAS,EAAE,SAAS;QACpB,OAAO,EAAE,OAAO;QAChB,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,UAAU,CAAC,KAAgC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC7E,CAAA;AACH,CAAC,CAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AstroIntegration } from 'astro';
|
|
2
|
+
import type { TndSeoOptions } from './types.js';
|
|
3
|
+
export default function tndSeo(options?: TndSeoOptions): AstroIntegration;
|
|
4
|
+
export type { SeoUserConfig, SeoEntry, SeoData, SeoUtils, TndSeoOptions } from './types.js';
|
|
5
|
+
export { flattenEntry } from './utils.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAA;AAE7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAc/C,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,OAAO,GAAE,aAAkB,GAAG,gBAAgB,CAmC5E;AAED,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC3F,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
const VIRTUAL_MODULE_ID = 'virtual:tnd/seo';
|
|
4
|
+
const RESOLVED_ID = '\0' + VIRTUAL_MODULE_ID;
|
|
5
|
+
const VIRTUAL_MODULE_TYPES = `
|
|
6
|
+
declare module 'virtual:tnd/seo' {
|
|
7
|
+
import type { SeoEntry, SeoData } from '@thenewdynamic/astro-seo'
|
|
8
|
+
export const getData: (entry: SeoEntry) => SeoData
|
|
9
|
+
export const getMetasData: (entry: SeoEntry) => Record<string, unknown>
|
|
10
|
+
export const getStructuredData: (entry: SeoEntry) => Record<string, unknown>
|
|
11
|
+
}
|
|
12
|
+
`;
|
|
13
|
+
export default function tndSeo(options = {}) {
|
|
14
|
+
let configFilePath;
|
|
15
|
+
let coreModulePath;
|
|
16
|
+
return {
|
|
17
|
+
name: '@thenewdynamic/astro-seo',
|
|
18
|
+
hooks: {
|
|
19
|
+
'astro:config:setup': ({ config, updateConfig }) => {
|
|
20
|
+
const root = fileURLToPath(config.root);
|
|
21
|
+
const userConfigPath = options.configPath ?? './seo.config';
|
|
22
|
+
configFilePath = resolve(root, userConfigPath);
|
|
23
|
+
coreModulePath = fileURLToPath(new URL('./core/index.js', import.meta.url));
|
|
24
|
+
const plugin = {
|
|
25
|
+
name: 'vite-plugin-tnd-seo',
|
|
26
|
+
resolveId(id) {
|
|
27
|
+
if (id === VIRTUAL_MODULE_ID)
|
|
28
|
+
return RESOLVED_ID;
|
|
29
|
+
},
|
|
30
|
+
load(id) {
|
|
31
|
+
if (id !== RESOLVED_ID)
|
|
32
|
+
return;
|
|
33
|
+
return [
|
|
34
|
+
`import userConfig from '${configFilePath}'`,
|
|
35
|
+
`import { createSeoUtils } from '${coreModulePath}'`,
|
|
36
|
+
`export const { getData, getMetasData, getStructuredData } = createSeoUtils(userConfig)`,
|
|
37
|
+
].join('\n');
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
updateConfig({ vite: { plugins: [plugin] } });
|
|
41
|
+
},
|
|
42
|
+
'astro:config:done': ({ injectTypes }) => {
|
|
43
|
+
injectTypes({ filename: 'virtual-tnd-seo.d.ts', content: VIRTUAL_MODULE_TYPES });
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export { flattenEntry } from './utils.js';
|
|
49
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAKnC,MAAM,iBAAiB,GAAG,iBAAiB,CAAA;AAC3C,MAAM,WAAW,GAAG,IAAI,GAAG,iBAAiB,CAAA;AAE5C,MAAM,oBAAoB,GAAG;;;;;;;CAO5B,CAAA;AAED,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,UAAyB,EAAE;IACxD,IAAI,cAAsB,CAAA;IAC1B,IAAI,cAAsB,CAAA;IAE1B,OAAO;QACL,IAAI,EAAE,0BAA0B;QAChC,KAAK,EAAE;YACL,oBAAoB,EAAE,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,EAAE;gBACjD,MAAM,IAAI,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;gBACvC,MAAM,cAAc,GAAG,OAAO,CAAC,UAAU,IAAI,cAAc,CAAA;gBAC3D,cAAc,GAAG,OAAO,CAAC,IAAI,EAAE,cAAc,CAAC,CAAA;gBAC9C,cAAc,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,iBAAiB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;gBAE3E,MAAM,MAAM,GAAW;oBACrB,IAAI,EAAE,qBAAqB;oBAC3B,SAAS,CAAC,EAAE;wBACV,IAAI,EAAE,KAAK,iBAAiB;4BAAE,OAAO,WAAW,CAAA;oBAClD,CAAC;oBACD,IAAI,CAAC,EAAE;wBACL,IAAI,EAAE,KAAK,WAAW;4BAAE,OAAM;wBAC9B,OAAO;4BACL,2BAA2B,cAAc,GAAG;4BAC5C,mCAAmC,cAAc,GAAG;4BACpD,wFAAwF;yBACzF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;oBACd,CAAC;iBACF,CAAA;gBAED,YAAY,CAAC,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,CAAA;YAC/C,CAAC;YACD,mBAAmB,EAAE,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE;gBACvC,WAAW,CAAC,EAAE,QAAQ,EAAE,sBAAsB,EAAE,OAAO,EAAE,oBAAoB,EAAE,CAAC,CAAA;YAClF,CAAC;SACF;KACF,CAAA;AACH,CAAC;AAGD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
export interface SiteConfig {
|
|
2
|
+
url: string;
|
|
3
|
+
title: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
image?: string | Record<string, unknown>;
|
|
6
|
+
seo?: {
|
|
7
|
+
title?: string;
|
|
8
|
+
twitterHandle?: string;
|
|
9
|
+
};
|
|
10
|
+
prod?: () => boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface ImageOptions {
|
|
13
|
+
width?: number;
|
|
14
|
+
height?: number;
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
}
|
|
17
|
+
export interface SeoEntry {
|
|
18
|
+
_type?: string;
|
|
19
|
+
title?: string;
|
|
20
|
+
type?: string;
|
|
21
|
+
_updatedAt?: string;
|
|
22
|
+
time_start?: string;
|
|
23
|
+
time_end?: string;
|
|
24
|
+
venue?: unknown;
|
|
25
|
+
date?: string;
|
|
26
|
+
url?: string;
|
|
27
|
+
description?: string | unknown[];
|
|
28
|
+
descriptionText?: string;
|
|
29
|
+
locale?: string;
|
|
30
|
+
image?: string | Record<string, unknown>;
|
|
31
|
+
authors?: Array<{
|
|
32
|
+
title?: string;
|
|
33
|
+
name?: string;
|
|
34
|
+
url?: string;
|
|
35
|
+
}>;
|
|
36
|
+
bodyText?: string;
|
|
37
|
+
translation?: {
|
|
38
|
+
url: string;
|
|
39
|
+
lang: string;
|
|
40
|
+
};
|
|
41
|
+
twitterCard?: string;
|
|
42
|
+
twitterHandle?: string;
|
|
43
|
+
twitterCreatorHandle?: string;
|
|
44
|
+
home?: boolean;
|
|
45
|
+
seo?: {
|
|
46
|
+
title?: string;
|
|
47
|
+
description?: string;
|
|
48
|
+
image?: Record<string, unknown>;
|
|
49
|
+
canonical?: string;
|
|
50
|
+
private?: boolean;
|
|
51
|
+
};
|
|
52
|
+
[key: string]: unknown;
|
|
53
|
+
}
|
|
54
|
+
export interface SeoData {
|
|
55
|
+
_type?: string;
|
|
56
|
+
title: string;
|
|
57
|
+
publishedTime?: string;
|
|
58
|
+
modifiedTime?: string;
|
|
59
|
+
authors: Array<{
|
|
60
|
+
name: string;
|
|
61
|
+
url: string | false;
|
|
62
|
+
}>;
|
|
63
|
+
description?: string;
|
|
64
|
+
canonical?: string | false;
|
|
65
|
+
noindex: boolean;
|
|
66
|
+
nofollow: boolean;
|
|
67
|
+
charset: string;
|
|
68
|
+
ogTitle: string;
|
|
69
|
+
type: string;
|
|
70
|
+
image?: string | false;
|
|
71
|
+
imageAlt: string;
|
|
72
|
+
url?: string | false;
|
|
73
|
+
locale: string;
|
|
74
|
+
localeAlternate?: string[];
|
|
75
|
+
languageAlternates?: Array<{
|
|
76
|
+
href: string;
|
|
77
|
+
hrefLang: string;
|
|
78
|
+
}>;
|
|
79
|
+
siteTitle: string;
|
|
80
|
+
twitterCard: string;
|
|
81
|
+
twitterHandle?: string;
|
|
82
|
+
twitterCreatorHandle?: string;
|
|
83
|
+
venue?: unknown;
|
|
84
|
+
timeStart?: string;
|
|
85
|
+
timeEnd?: string;
|
|
86
|
+
}
|
|
87
|
+
export interface SeoUserConfig {
|
|
88
|
+
site: SiteConfig;
|
|
89
|
+
resolveImage?: (image: Record<string, unknown>, opts?: ImageOptions) => string;
|
|
90
|
+
transformEntry?: (entry: SeoEntry) => Partial<SeoData>;
|
|
91
|
+
}
|
|
92
|
+
export interface SeoUtils {
|
|
93
|
+
getData: (entry: SeoEntry) => SeoData;
|
|
94
|
+
getMetasData: (entry: SeoEntry) => Record<string, unknown>;
|
|
95
|
+
getStructuredData: (entry: SeoEntry) => Record<string, unknown>;
|
|
96
|
+
}
|
|
97
|
+
export interface TndSeoOptions {
|
|
98
|
+
configPath?: string;
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACxC,GAAG,CAAC,EAAE;QACJ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AAa,CAAC,EAAE,MAAM,CAAA;IACtB,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,UAAU,CAAA;IAChB,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,YAAY,KAAK,MAAM,CAAA;IAC9E,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;CACvD;AAED,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,OAAO,CAAA;IACrC,YAAY,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC1D,iBAAiB,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAChE;AAED,MAAM,WAAW,aAAa;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const escapeString: (string: string) => string;
|
|
2
|
+
export declare const makeAbsUrl: (baseURL: string) => (url: string) => string | false;
|
|
3
|
+
export declare const isHome: (entry: Record<string, unknown>) => boolean;
|
|
4
|
+
export declare const getExcerpt: (string: string, length?: number) => string;
|
|
5
|
+
export declare const flattenEntry: (entry: Record<string, unknown> & {
|
|
6
|
+
data?: Record<string, unknown>;
|
|
7
|
+
}) => Record<string, unknown>;
|
|
8
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,GAAI,QAAQ,MAAM,KAAG,MAK7C,CAAA;AAED,eAAO,MAAM,UAAU,GAAI,SAAS,MAAM,MAAM,KAAK,MAAM,KAAG,MAAM,GAAG,KAItE,CAAA;AAED,eAAO,MAAM,MAAM,GAAI,OAAO,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,OAEvD,CAAA;AAED,eAAO,MAAM,UAAU,GAAI,QAAQ,MAAM,EAAE,eAAY,KAAG,MAKzD,CAAA;AAED,eAAO,MAAM,YAAY,GACvB,OAAO,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,KAClE,MAAM,CAAC,MAAM,EAAE,OAAO,CAGvB,CAAA"}
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export const escapeString = (string) => {
|
|
2
|
+
if (/[*_"]/.test(string)) {
|
|
3
|
+
return string.replace('"', '"').replace(/[*_]/g, '');
|
|
4
|
+
}
|
|
5
|
+
return string;
|
|
6
|
+
};
|
|
7
|
+
export const makeAbsUrl = (baseURL) => (url) => {
|
|
8
|
+
if (typeof url === 'undefined')
|
|
9
|
+
return false;
|
|
10
|
+
const separator = url.charAt(0) !== '/' ? '/' : '';
|
|
11
|
+
return baseURL + separator + url;
|
|
12
|
+
};
|
|
13
|
+
export const isHome = (entry) => {
|
|
14
|
+
return typeof entry.home !== 'undefined' && !!entry.home;
|
|
15
|
+
};
|
|
16
|
+
export const getExcerpt = (string, length = 300) => {
|
|
17
|
+
if (string && string.length > length) {
|
|
18
|
+
return string.substring(0, length) + '...';
|
|
19
|
+
}
|
|
20
|
+
return string;
|
|
21
|
+
};
|
|
22
|
+
export const flattenEntry = (entry) => ({
|
|
23
|
+
...entry,
|
|
24
|
+
...entry.data,
|
|
25
|
+
});
|
|
26
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,MAAc,EAAU,EAAE;IACrD,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACzB,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;IAC3D,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAAe,EAAE,EAAE,CAAC,CAAC,GAAW,EAAkB,EAAE;IAC7E,IAAI,OAAO,GAAG,KAAK,WAAW;QAAE,OAAO,KAAK,CAAA;IAC5C,MAAM,SAAS,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAA;IAClD,OAAO,OAAO,GAAG,SAAS,GAAG,GAAG,CAAA;AAClC,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAA8B,EAAW,EAAE;IAChE,OAAO,OAAO,KAAK,CAAC,IAAI,KAAK,WAAW,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,CAAA;AAC1D,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,MAAc,EAAE,MAAM,GAAG,GAAG,EAAU,EAAE;IACjE,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC;QACrC,OAAO,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG,KAAK,CAAA;IAC5C,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,KAAmE,EAC1C,EAAE,CAAC,CAAC;IAC7B,GAAG,KAAK;IACR,GAAG,KAAK,CAAC,IAAI;CACd,CAAC,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@thenewdynamic/astro-seo",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Astro integration for SEO meta tags and structured data",
|
|
6
|
+
"author": "The New Dynamic",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"homepage": "https://github.com/theNewDynamic/astro-seo",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/theNewDynamic/astro-seo.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/theNewDynamic/astro-seo/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"astro",
|
|
18
|
+
"astro-integration",
|
|
19
|
+
"seo",
|
|
20
|
+
"meta-tags",
|
|
21
|
+
"structured-data",
|
|
22
|
+
"schema-org"
|
|
23
|
+
],
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"src/components"
|
|
27
|
+
],
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
},
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"import": "./dist/index.js"
|
|
35
|
+
},
|
|
36
|
+
"./SEO.astro": "./src/components/SEO.astro",
|
|
37
|
+
"./core": {
|
|
38
|
+
"types": "./dist/core/index.d.ts",
|
|
39
|
+
"import": "./dist/core/index.js"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "tsc",
|
|
44
|
+
"prepublishOnly": "npm run build"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/node": "^20.0.0",
|
|
48
|
+
"astro": "^4.14.0",
|
|
49
|
+
"typescript": "^5.0.0"
|
|
50
|
+
},
|
|
51
|
+
"peerDependencies": {
|
|
52
|
+
"astro": ">=4.14.0"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"astro-seo": "^0.7.2"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { SEO as AstroSEO } from 'astro-seo'
|
|
3
|
+
import { getMetasData, getStructuredData } from 'virtual:tnd/seo'
|
|
4
|
+
import type { SeoEntry } from '../types.js'
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
entry: SeoEntry
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const { entry } = Astro.props
|
|
11
|
+
const metasData = getMetasData(entry)
|
|
12
|
+
const structuredData = getStructuredData(entry)
|
|
13
|
+
---
|
|
14
|
+
<AstroSEO {...metasData} />
|
|
15
|
+
<script type="application/ld+json" is:inline set:html={JSON.stringify(structuredData)} />
|