@rileybathurst/paddle 0.0.49 → 0.0.50
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/package.json +1 -1
- package/src/PaddleSEO.tsx +163 -0
- package/src/index.tsx +3 -0
- package/src/styles/layout.css +6 -2
- package/src/styles/lists.css +1 -1
- package/src/styles/typography.css +1 -0
package/package.json
CHANGED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Script } from "gatsby";
|
|
3
|
+
|
|
4
|
+
interface BreadcrumbsTypes {
|
|
5
|
+
url: string;
|
|
6
|
+
[key: number]: {
|
|
7
|
+
name: string;
|
|
8
|
+
item: string;
|
|
9
|
+
};
|
|
10
|
+
}[]
|
|
11
|
+
// I could probably pass it two arguments instead but for now
|
|
12
|
+
function Breadcrumbs(breadcrumbs: BreadcrumbsTypes) {
|
|
13
|
+
|
|
14
|
+
// console.log(breadcrumbs);
|
|
15
|
+
// console.log(Object.entries(breadcrumbs).length);
|
|
16
|
+
if (!Object.entries(breadcrumbs).length) return null;
|
|
17
|
+
|
|
18
|
+
// remove the breadcrumbs.url from the Object.entries
|
|
19
|
+
// console.log(breadcrumbs.url);
|
|
20
|
+
const { url, ...rest } = breadcrumbs;
|
|
21
|
+
|
|
22
|
+
// console.log(rest);
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<Script type="application/ld+json">
|
|
26
|
+
{`
|
|
27
|
+
{
|
|
28
|
+
"@context": "https://schema.org",
|
|
29
|
+
"@type": "BreadcrumbList",
|
|
30
|
+
"itemListElement": [
|
|
31
|
+
${Object.entries(rest).map(([key, breadcrumb]) => {
|
|
32
|
+
return `{
|
|
33
|
+
"@type": "ListItem",
|
|
34
|
+
"position": ${Number.parseInt(key) + 1},
|
|
35
|
+
"name": "${breadcrumb.name}",
|
|
36
|
+
"item": "${breadcrumbs.url}/${breadcrumb.item}"
|
|
37
|
+
}`
|
|
38
|
+
})}
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
`}
|
|
42
|
+
</Script>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
type SEOtypes = {
|
|
47
|
+
title?: string;
|
|
48
|
+
description?: string;
|
|
49
|
+
url?: string;
|
|
50
|
+
image?: string;
|
|
51
|
+
imageAlt?: string;
|
|
52
|
+
breadcrumbs?: object;
|
|
53
|
+
children?: React.ReactNode;
|
|
54
|
+
|
|
55
|
+
strapiLocale: {
|
|
56
|
+
name: string;
|
|
57
|
+
topbar: {
|
|
58
|
+
topbar: string;
|
|
59
|
+
};
|
|
60
|
+
url: string;
|
|
61
|
+
ogImage: string;
|
|
62
|
+
ogimagedescription: string;
|
|
63
|
+
themeColor: string;
|
|
64
|
+
latitude: string;
|
|
65
|
+
longitude: string;
|
|
66
|
+
geoRadius: string;
|
|
67
|
+
phone: string;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
strapiLocation: {
|
|
71
|
+
streetAddress: string;
|
|
72
|
+
addressLocality: string;
|
|
73
|
+
addressRegion: string;
|
|
74
|
+
postalCode: string;
|
|
75
|
+
opening_time: string;
|
|
76
|
+
closing_time: string;
|
|
77
|
+
paymentAccepted: string;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export const SEO = (strapiLocale, strapiLocation: SEOtypes) => {
|
|
82
|
+
|
|
83
|
+
const businessName = `${strapiLocale.name} Kayak & Paddleboard rentals and tours`;
|
|
84
|
+
|
|
85
|
+
const seo = {
|
|
86
|
+
title: SE0.title ? `${SE0.title} | ${businessName}` : `${businessName} | ${strapiLocale.topbar.topbar} `,
|
|
87
|
+
// TODO: tagline would be a better fallback description
|
|
88
|
+
description: SE0.description || businessName,
|
|
89
|
+
url: `${strapiLocale.url}${SE0.url}` || strapiLocale.url,
|
|
90
|
+
image: strapiLocale.ogImage || SEO.image,
|
|
91
|
+
imageAlt: strapiLocale.ogimagedescription || SEO.imageAlt,
|
|
92
|
+
breadcrumbs: SE0.breadcrumbs || null,
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// const query = '- cash\n - credit card';
|
|
96
|
+
// const formatted = query.split('\n').map((item) => item.trim().replace('- ', '')).join(', ');
|
|
97
|
+
// console.log(formatted);
|
|
98
|
+
|
|
99
|
+
// console.log(strapiLocation.paymentAccepted);
|
|
100
|
+
const paymentAcceptedQuery = strapiLocation.paymentAccepted;
|
|
101
|
+
const paymentAcceptedFormatted = paymentAcceptedQuery.split('\n').map((payment: string) => payment.trim().replace('- ', '')).join(', ');
|
|
102
|
+
// console.log(paymentAcceptedFormatted);
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
<>
|
|
106
|
+
<title>{seo.title}</title>
|
|
107
|
+
<meta name="description" content={seo.description} />
|
|
108
|
+
|
|
109
|
+
<meta property="og:type" content="website" />
|
|
110
|
+
<meta property="og:url" content={seo.url} />
|
|
111
|
+
<meta property="og:title" content={seo.title} />
|
|
112
|
+
<meta property="og:description" content={seo.description} />
|
|
113
|
+
<meta property="og:image" content={seo.image} />
|
|
114
|
+
<meta property="og:image:alt" content={seo.imageAlt} />
|
|
115
|
+
<meta name="theme-color" content={strapiLocale.themeColor} />
|
|
116
|
+
|
|
117
|
+
<Script type="application/ld+json">
|
|
118
|
+
{`
|
|
119
|
+
{
|
|
120
|
+
"@context": "https://schema.org/",
|
|
121
|
+
"@type": "LocalBusiness",
|
|
122
|
+
"name": "${businessName}",
|
|
123
|
+
"url": "${strapiLocale.url}",
|
|
124
|
+
"description": "${strapiLocale.name}",
|
|
125
|
+
"image": "${seo.image}",
|
|
126
|
+
"address": {
|
|
127
|
+
"@type": "PostalAddress",
|
|
128
|
+
"streetAddress": "${strapiLocation.streetAddress}",
|
|
129
|
+
"addressLocality": "${strapiLocation.addressLocality}",
|
|
130
|
+
"addressRegion": "${strapiLocation.addressRegion}",
|
|
131
|
+
"postalCode": "${strapiLocation.postalCode}"
|
|
132
|
+
},
|
|
133
|
+
"geo": {
|
|
134
|
+
"@type": "GeoCoordinates",
|
|
135
|
+
"latitude": "${strapiLocale.latitude}",
|
|
136
|
+
"longitude": "${strapiLocale.longitude}"
|
|
137
|
+
},
|
|
138
|
+
"areaServed": {
|
|
139
|
+
"@type": "GeoCircle",
|
|
140
|
+
"geoMidpoint": {
|
|
141
|
+
"@type": "GeoCoordinates",
|
|
142
|
+
"latitude": "${strapiLocale.latitude}",
|
|
143
|
+
"longitude": "${strapiLocale.longitude}"
|
|
144
|
+
},
|
|
145
|
+
"geoRadius": "${strapiLocale.geoRadius}"
|
|
146
|
+
},
|
|
147
|
+
"paymentAccepted": "${paymentAcceptedFormatted}",
|
|
148
|
+
"telephone": "${strapiLocale.phone}",
|
|
149
|
+
"numberOfEmployees": "10",
|
|
150
|
+
"openingHours": "Mo, Tu, We, Th, Fr, Sa, Su ${strapiLocation.opening_time}-${strapiLocation.closing_time}",
|
|
151
|
+
"priceRange": "$30-$375"
|
|
152
|
+
}
|
|
153
|
+
`}
|
|
154
|
+
</Script>
|
|
155
|
+
|
|
156
|
+
{/* // ? do I have anything but two levels deep? with this maybe */}
|
|
157
|
+
{/* this was being weird inline so i put it in a function i might not need to */}
|
|
158
|
+
{/* {seo?.breadcrumbs ?? */}
|
|
159
|
+
<Breadcrumbs breadcrumbs={seo.breadcrumbs} />
|
|
160
|
+
{SE0.children}
|
|
161
|
+
</>
|
|
162
|
+
);
|
|
163
|
+
};
|
package/src/index.tsx
CHANGED
package/src/styles/layout.css
CHANGED
|
@@ -42,14 +42,14 @@ footer {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
.pelican,
|
|
45
|
-
.react-aria-Breadcrumbs {
|
|
45
|
+
.react-aria-Breadcrumbs.pelican {
|
|
46
46
|
max-width: min(var(--pelican), calc(100vw - var(--denali)));
|
|
47
47
|
flex-basis: var(--pelican);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
.albatross,
|
|
51
51
|
.deck,
|
|
52
|
-
.react-aria-Breadcrumbs
|
|
52
|
+
.react-aria-Breadcrumbs {
|
|
53
53
|
max-width: min(var(--albatross), calc(100vw - var(--denali)));
|
|
54
54
|
flex-basis: var(--albatross);
|
|
55
55
|
}
|
|
@@ -165,6 +165,10 @@ header {
|
|
|
165
165
|
margin-block-end: var(--kosciuszko);
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
+
.zero-block-end {
|
|
169
|
+
margin-block-end: 0;
|
|
170
|
+
}
|
|
171
|
+
|
|
168
172
|
/*------------------*/
|
|
169
173
|
/* #TOP BAR */
|
|
170
174
|
/*------------------*/
|
package/src/styles/lists.css
CHANGED