@newskit-render/feed 1.1.1 → 1.2.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 +148 -19
- package/dist/cjs/helpers/createSitemap/buildSiteMapImages.d.ts +2 -0
- package/dist/cjs/helpers/createSitemap/buildSiteMapImages.js +18 -0
- package/dist/cjs/helpers/createSitemap/buildSiteMapImages.js.map +1 -0
- package/dist/cjs/helpers/createSitemap/buildSiteMapVideos.d.ts +10 -0
- package/dist/cjs/helpers/createSitemap/buildSiteMapVideos.js +20 -0
- package/dist/cjs/helpers/createSitemap/buildSiteMapVideos.js.map +1 -0
- package/dist/cjs/helpers/createSitemap/createArticleSitemap.d.ts +2 -0
- package/dist/cjs/helpers/createSitemap/createArticleSitemap.js +38 -0
- package/dist/cjs/helpers/createSitemap/createArticleSitemap.js.map +1 -0
- package/dist/cjs/helpers/createSitemap/createPagesSitemap.d.ts +3 -0
- package/dist/cjs/helpers/createSitemap/createPagesSitemap.js +44 -0
- package/dist/cjs/helpers/createSitemap/createPagesSitemap.js.map +1 -0
- package/dist/cjs/helpers/createSitemap/createSitemapIndex.d.ts +1 -0
- package/dist/cjs/helpers/createSitemap/createSitemapIndex.js +13 -0
- package/dist/cjs/helpers/createSitemap/createSitemapIndex.js.map +1 -0
- package/dist/cjs/helpers/createSitemap/generateArticleSlug.d.ts +1 -0
- package/dist/cjs/helpers/createSitemap/generateArticleSlug.js +13 -0
- package/dist/cjs/helpers/createSitemap/generateArticleSlug.js.map +1 -0
- package/dist/cjs/helpers/createSitemap/getCategorySlug.d.ts +2 -0
- package/dist/cjs/helpers/createSitemap/getCategorySlug.js +10 -0
- package/dist/cjs/helpers/createSitemap/getCategorySlug.js.map +1 -0
- package/dist/cjs/helpers/createSitemap/getSitemapHeaders.d.ts +1 -0
- package/dist/cjs/helpers/createSitemap/getSitemapHeaders.js +10 -0
- package/dist/cjs/helpers/createSitemap/getSitemapHeaders.js.map +1 -0
- package/dist/cjs/helpers/createSitemap/index.d.ts +7 -0
- package/dist/cjs/helpers/createSitemap/index.js +24 -0
- package/dist/cjs/helpers/createSitemap/index.js.map +1 -0
- package/dist/cjs/helpers/queryPages.d.ts +3 -0
- package/dist/{esm/helpers/queryPage.js → cjs/helpers/queryPages.js} +39 -47
- package/dist/cjs/helpers/queryPages.js.map +1 -0
- package/dist/cjs/helpers/types.d.ts +15 -10
- package/dist/cjs/helpers/utils.js +4 -4
- package/dist/cjs/helpers/utils.js.map +1 -1
- package/dist/cjs/sitemap/__tests__/mocks.d.ts +11 -8
- package/dist/cjs/sitemap/__tests__/mocks.js +35 -22
- package/dist/cjs/sitemap/__tests__/mocks.js.map +1 -1
- package/dist/cjs/sitemap/queries/getArticleList.js +1 -1
- package/dist/cjs/sitemap/queries/getArticleList.js.map +1 -1
- package/dist/cjs/sitemap/queries/getCompetitions.d.ts +1 -0
- package/dist/cjs/sitemap/queries/getCompetitions.js +11 -0
- package/dist/cjs/sitemap/queries/getCompetitions.js.map +1 -0
- package/dist/cjs/sitemap/queries/getPages.d.ts +1 -0
- package/dist/cjs/sitemap/queries/getPages.js +11 -0
- package/dist/cjs/sitemap/queries/getPages.js.map +1 -0
- package/dist/cjs/sitemap/queries/index.d.ts +2 -0
- package/dist/cjs/sitemap/queries/index.js +2 -0
- package/dist/cjs/sitemap/queries/index.js.map +1 -1
- package/dist/cjs/sitemap/resolvers/genericSitemapResolver.d.ts +1 -1
- package/dist/cjs/sitemap/resolvers/genericSitemapResolver.js +17 -43
- package/dist/cjs/sitemap/resolvers/genericSitemapResolver.js.map +1 -1
- package/dist/cjs/sitemap/resolvers/newsSitemapResolver.d.ts +1 -1
- package/dist/cjs/sitemap/resolvers/newsSitemapResolver.js +7 -7
- package/dist/cjs/sitemap/resolvers/newsSitemapResolver.js.map +1 -1
- package/dist/esm/helpers/createSitemap/buildSiteMapImages.d.ts +2 -0
- package/dist/esm/helpers/createSitemap/buildSiteMapImages.js +11 -0
- package/dist/esm/helpers/createSitemap/buildSiteMapImages.js.map +1 -0
- package/dist/esm/helpers/createSitemap/buildSiteMapVideos.d.ts +10 -0
- package/dist/esm/helpers/createSitemap/buildSiteMapVideos.js +13 -0
- package/dist/esm/helpers/createSitemap/buildSiteMapVideos.js.map +1 -0
- package/dist/esm/helpers/createSitemap/createArticleSitemap.d.ts +2 -0
- package/dist/esm/helpers/createSitemap/createArticleSitemap.js +31 -0
- package/dist/esm/helpers/createSitemap/createArticleSitemap.js.map +1 -0
- package/dist/esm/helpers/createSitemap/createPagesSitemap.d.ts +3 -0
- package/dist/esm/helpers/createSitemap/createPagesSitemap.js +37 -0
- package/dist/esm/helpers/createSitemap/createPagesSitemap.js.map +1 -0
- package/dist/esm/helpers/createSitemap/createSitemapIndex.d.ts +1 -0
- package/dist/esm/helpers/createSitemap/createSitemapIndex.js +9 -0
- package/dist/esm/helpers/createSitemap/createSitemapIndex.js.map +1 -0
- package/dist/esm/helpers/createSitemap/generateArticleSlug.d.ts +1 -0
- package/dist/esm/helpers/createSitemap/generateArticleSlug.js +9 -0
- package/dist/esm/helpers/createSitemap/generateArticleSlug.js.map +1 -0
- package/dist/esm/helpers/createSitemap/getCategorySlug.d.ts +2 -0
- package/dist/esm/helpers/createSitemap/getCategorySlug.js +6 -0
- package/dist/esm/helpers/createSitemap/getCategorySlug.js.map +1 -0
- package/dist/esm/helpers/createSitemap/getSitemapHeaders.d.ts +1 -0
- package/dist/esm/helpers/createSitemap/getSitemapHeaders.js +6 -0
- package/dist/esm/helpers/createSitemap/getSitemapHeaders.js.map +1 -0
- package/dist/esm/helpers/createSitemap/index.d.ts +7 -0
- package/dist/esm/helpers/createSitemap/index.js +8 -0
- package/dist/esm/helpers/createSitemap/index.js.map +1 -0
- package/dist/esm/helpers/queryPages.d.ts +3 -0
- package/dist/{cjs/helpers/queryPage.js → esm/helpers/queryPages.js} +35 -52
- package/dist/esm/helpers/queryPages.js.map +1 -0
- package/dist/esm/helpers/types.d.ts +15 -10
- package/dist/esm/helpers/utils.js +4 -4
- package/dist/esm/helpers/utils.js.map +1 -1
- package/dist/esm/sitemap/__tests__/mocks.d.ts +11 -8
- package/dist/esm/sitemap/__tests__/mocks.js +34 -21
- package/dist/esm/sitemap/__tests__/mocks.js.map +1 -1
- package/dist/esm/sitemap/queries/getArticleList.js +1 -1
- package/dist/esm/sitemap/queries/getArticleList.js.map +1 -1
- package/dist/esm/sitemap/queries/getCompetitions.d.ts +1 -0
- package/dist/esm/sitemap/queries/getCompetitions.js +8 -0
- package/dist/esm/sitemap/queries/getCompetitions.js.map +1 -0
- package/dist/esm/sitemap/queries/getPages.d.ts +1 -0
- package/dist/esm/sitemap/queries/getPages.js +8 -0
- package/dist/esm/sitemap/queries/getPages.js.map +1 -0
- package/dist/esm/sitemap/queries/index.d.ts +2 -0
- package/dist/esm/sitemap/queries/index.js +2 -0
- package/dist/esm/sitemap/queries/index.js.map +1 -1
- package/dist/esm/sitemap/resolvers/genericSitemapResolver.d.ts +1 -1
- package/dist/esm/sitemap/resolvers/genericSitemapResolver.js +17 -43
- package/dist/esm/sitemap/resolvers/genericSitemapResolver.js.map +1 -1
- package/dist/esm/sitemap/resolvers/newsSitemapResolver.d.ts +1 -1
- package/dist/esm/sitemap/resolvers/newsSitemapResolver.js +7 -7
- package/dist/esm/sitemap/resolvers/newsSitemapResolver.js.map +1 -1
- package/package.json +1 -1
- package/dist/cjs/helpers/create-sitemap.d.ts +0 -16
- package/dist/cjs/helpers/create-sitemap.js +0 -99
- package/dist/cjs/helpers/create-sitemap.js.map +0 -1
- package/dist/cjs/helpers/queryPage.d.ts +0 -4
- package/dist/cjs/helpers/queryPage.js.map +0 -1
- package/dist/cjs/sitemap/queries/getChannelsList.d.ts +0 -1
- package/dist/cjs/sitemap/queries/getChannelsList.js +0 -11
- package/dist/cjs/sitemap/queries/getChannelsList.js.map +0 -1
- package/dist/cjs/sitemap/queries/getPage.d.ts +0 -1
- package/dist/cjs/sitemap/queries/getPage.js +0 -11
- package/dist/cjs/sitemap/queries/getPage.js.map +0 -1
- package/dist/esm/helpers/create-sitemap.d.ts +0 -16
- package/dist/esm/helpers/create-sitemap.js +0 -86
- package/dist/esm/helpers/create-sitemap.js.map +0 -1
- package/dist/esm/helpers/queryPage.d.ts +0 -4
- package/dist/esm/helpers/queryPage.js.map +0 -1
- package/dist/esm/sitemap/queries/getChannelsList.d.ts +0 -1
- package/dist/esm/sitemap/queries/getChannelsList.js +0 -8
- package/dist/esm/sitemap/queries/getChannelsList.js.map +0 -1
- package/dist/esm/sitemap/queries/getPage.d.ts +0 -1
- package/dist/esm/sitemap/queries/getPage.js +0 -8
- package/dist/esm/sitemap/queries/getPage.js.map +0 -1
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ yarn add @newskit-render/feed
|
|
|
18
18
|
|
|
19
19
|
### Create sitemap pages
|
|
20
20
|
|
|
21
|
-
Under your `/pages/api` folder create `sitemap.ts` and `news-sitemap.ts` files.
|
|
21
|
+
Under your `/pages/api` folder create `sitemap.ts`, `pages-sitemap.ts`, `competitions-sitemap.ts` and `news-sitemap.ts` files.
|
|
22
22
|
|
|
23
23
|
update the `next.config.js` file to add rewrites:
|
|
24
24
|
|
|
@@ -29,6 +29,14 @@ async rewrites() {
|
|
|
29
29
|
source: '/sitemap.xml',
|
|
30
30
|
destination: '/api/sitemap',
|
|
31
31
|
},
|
|
32
|
+
{
|
|
33
|
+
source: '/pages-sitemap.xml',
|
|
34
|
+
destination: '/api/pages-sitemap',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
source: '/competitions-sitemap.xml',
|
|
38
|
+
destination: '/api/competitions-sitemap',
|
|
39
|
+
},
|
|
32
40
|
{
|
|
33
41
|
source: '/news-sitemap.xml',
|
|
34
42
|
destination: '/api/news-sitemap',
|
|
@@ -60,37 +68,52 @@ see `rssFeed` funtion
|
|
|
60
68
|
|
|
61
69
|
#### genericSitemap
|
|
62
70
|
|
|
63
|
-
`
|
|
71
|
+
`genericSitemap` - this function will handle the logic for 4 different views that correspond to the sitemap endpoints you should already have set up (see Create sitemap pages section).
|
|
64
72
|
|
|
65
|
-
|
|
73
|
+
- `sitemap.xml` will show a `sitemapindex` of sitemaps by date.
|
|
74
|
+
- `sitemap.xml?query=1` will show all articles created on that day, example `sitemap.xml?yyyy=2022&mm=10&dd=14`.
|
|
75
|
+
- `pages-sitemap.xml` will show all pages including homepage - custom pages not available in the api can be added.
|
|
76
|
+
- `competitions-sitemap.xml` will show all competitions.
|
|
66
77
|
|
|
67
|
-
`context` (required) - Next.js context object (only needs `res` and `query` from context but its easier to destructor as below)
|
|
68
78
|
|
|
69
|
-
`
|
|
70
|
-
The _domain_ is the domain of your website. The _firstArticleDate_ is the date of the first article you have published, this will set from when the generic sitemap will produce query sitemaps. _publisher_ is the name of the publisher in the NewsKit API, this string will be used for fetching the articles for the correct publication. _publicationName_ is the name of the publication, used inside the sitemap `<news:name>${publicationName}</news:name>` tag.
|
|
79
|
+
`genericSitemap` is passes a `context` object, depending on the view, it will include the following parameters:
|
|
71
80
|
|
|
72
|
-
`
|
|
73
|
-
|
|
81
|
+
`dataType` can be `articles`, `pages` or `competitions`. Should be set to show `pages` or `competitions` view. Not setting this will result in default of `articles` used by `sitemap.xml` and `sitemap.xml?query=1`.
|
|
82
|
+
|
|
83
|
+
`res` (required) from the Next.js context object.
|
|
84
|
+
|
|
85
|
+
`query` from the Next.js context object - is required for `sitemap.xml?query=1` view.
|
|
86
|
+
|
|
87
|
+
`publisher` (required) is the name of the publisher in the NewsKit API, this string will be used for fetching the articles for the correct publication.
|
|
88
|
+
|
|
89
|
+
`publicationName` (required) is the name of the publication, used inside the sitemap `<news:name>${publicationName}</news:name>` tag.
|
|
90
|
+
|
|
91
|
+
`domain` (required) is the domain of your website.
|
|
92
|
+
|
|
93
|
+
`firstArticleDate` is the date of the first article you have published. This will determine from when the `sitemapindex` of sitemaps by date starts from. If not added you will get the last 30 days.
|
|
94
|
+
|
|
95
|
+
`CustomStaticPageCollection` provides the possibility to manually add a list of static pages, that do not exist in an API. This will work with pages and competitions, but it would be unlikely to be used with competitions. The format of the static page is in the example `pages-sitemap.xml` below, but has 2 properties. `slug` (required) and `url`
|
|
96
|
+
|
|
97
|
+
`changefreq` you can change the default changefreq for entries on the sitemap
|
|
98
|
+
|
|
99
|
+
`priority` you can change the default priority for entires on the sitemap
|
|
100
|
+
|
|
101
|
+
Example for `sitemap.xml` and `sitemap.xml?query=1`
|
|
74
102
|
|
|
75
103
|
```
|
|
76
104
|
import { NextApiRequest, NextApiResponse } from 'next'
|
|
77
|
-
import { genericSitemap
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
{
|
|
81
|
-
channel: 'test-custom-page',
|
|
82
|
-
},
|
|
83
|
-
]
|
|
105
|
+
import { genericSitemap } from '@newskit-render/sitemap'
|
|
106
|
+
import { Publisher } from '@newskit-render/api'
|
|
107
|
+
import { getHost } from '@newskit-render/shared-components'
|
|
84
108
|
|
|
85
109
|
const handler = async (req: NextApiRequest, res: NextApiResponse) =>
|
|
86
110
|
genericSitemap({
|
|
87
111
|
res,
|
|
88
112
|
query: req.query,
|
|
89
|
-
publisher: process.env.PUBLISHER as
|
|
113
|
+
publisher: process.env.PUBLISHER as Publisher,
|
|
90
114
|
domain: new URL(getHost(req)).host,
|
|
91
115
|
firstArticleDate: process.env.SITEMAP_FIRST_PUBLICATION_DATE,
|
|
92
116
|
publicationName: process.env.SITEMAP_PUBLICATION_NAME,
|
|
93
|
-
customStaticPageCollection: defaultCustomStaticPagesCollection,
|
|
94
117
|
})
|
|
95
118
|
|
|
96
119
|
export default handler
|
|
@@ -99,7 +122,7 @@ export default handler
|
|
|
99
122
|
|
|
100
123
|
You will find the env vars in `/helm/value-{env}.yaml`
|
|
101
124
|
|
|
102
|
-
|
|
125
|
+
Example values are:
|
|
103
126
|
|
|
104
127
|
```
|
|
105
128
|
publisher: 'VIRGIN',
|
|
@@ -108,15 +131,69 @@ firstArticleDate: '2016-3-1',
|
|
|
108
131
|
publicationName: 'Virgin Radio',
|
|
109
132
|
```
|
|
110
133
|
|
|
134
|
+
Example for `pages-sitemap.xml`
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
import { NextApiRequest, NextApiResponse } from 'next'
|
|
138
|
+
import { genericSitemap, CustomStaticPage } from '@newskit-render/feed'
|
|
139
|
+
import { Publisher } from '@newskit-render/api'
|
|
140
|
+
import { getHost } from '@newskit-render/shared-components'
|
|
141
|
+
|
|
142
|
+
const defaultCustomStaticPagesCollection: CustomStaticPage[] = [
|
|
143
|
+
{
|
|
144
|
+
slug: 'test-custom-page',
|
|
145
|
+
},
|
|
146
|
+
]
|
|
147
|
+
const handler = async (req: NextApiRequest, res: NextApiResponse) =>
|
|
148
|
+
genericSitemap({
|
|
149
|
+
res,
|
|
150
|
+
dataType: 'pages',
|
|
151
|
+
publisher: process.env.PUBLISHER as Publisher,
|
|
152
|
+
domain: new URL(getHost(req) as string).host,
|
|
153
|
+
publicationName: process.env.SITEMAP_PUBLICATION_NAME,
|
|
154
|
+
customStaticPageCollection: defaultCustomStaticPagesCollection,
|
|
155
|
+
changefreq: 'hourly',
|
|
156
|
+
priority: '0.8',
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
export default handler
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Example of `competitions-sitemap.xml`
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
import { NextApiRequest, NextApiResponse } from 'next'
|
|
166
|
+
import { genericSitemap } from '@newskit-render/feed'
|
|
167
|
+
import { Publisher } from '@newskit-render/api'
|
|
168
|
+
import { getHost } from '@newskit-render/shared-components'
|
|
169
|
+
|
|
170
|
+
const handler = async (req: NextApiRequest, res: NextApiResponse) =>
|
|
171
|
+
genericSitemap({
|
|
172
|
+
res,
|
|
173
|
+
dataType: 'competitions',
|
|
174
|
+
publisher: process.env.PUBLISHER as Publisher,
|
|
175
|
+
domain: new URL(getHost(req) as string).host,
|
|
176
|
+
publicationName: process.env.SITEMAP_PUBLICATION_NAME,
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
export default handler
|
|
180
|
+
```
|
|
181
|
+
|
|
111
182
|
#### newsSitemap
|
|
112
183
|
|
|
113
|
-
|
|
184
|
+
This function will handle the logic for `news-sitemap.xml` and creates the sitemap required by Google News. You will need to register the sitemap with Google.
|
|
185
|
+
|
|
186
|
+
`newsSitemap` - will receive the following parameters:
|
|
114
187
|
|
|
115
188
|
`context` (required) - Next.js context object (only needs `res` from context but its easier to destructor as below)
|
|
116
189
|
|
|
117
190
|
`publisher, domain, publicationName` (required): Required properties for correctly building the sitemap.xml.
|
|
118
191
|
The _domain_ is the domain of your website. _publisher_ is the name of the publisher in the NewsKit API, this string will be used for fetching the articles for the correct publication. _publicationName_ is the name of the publication, used inside the sitemap `<news:name>${publicationName}</news:name>` tag.
|
|
119
192
|
|
|
193
|
+
`changefreq` you can change the default changefreq for entries on the sitemap
|
|
194
|
+
|
|
195
|
+
`priority` you can change the default priority for entires on the sitemap
|
|
196
|
+
|
|
120
197
|
Below an example.
|
|
121
198
|
|
|
122
199
|
```
|
|
@@ -135,6 +212,58 @@ export default handler
|
|
|
135
212
|
|
|
136
213
|
```
|
|
137
214
|
|
|
215
|
+
### robots.txt
|
|
216
|
+
|
|
217
|
+
Your sitemap files will need to be added to your robots.txt file something like:
|
|
218
|
+
|
|
219
|
+
```
|
|
220
|
+
User-agent: *
|
|
221
|
+
Disallow: /search/
|
|
222
|
+
Disallow: /*?s=*
|
|
223
|
+
Disallow: *&s=*
|
|
224
|
+
Sitemap: https://example.co.uk/sitemap.xml
|
|
225
|
+
Sitemap: https://example.co.uk/news-sitemap.xml
|
|
226
|
+
Sitemap: https://example.co.uk/pages-sitemap.xml
|
|
227
|
+
Sitemap: https://example.co.uk/competitions-sitemap.xml
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
This can be done by adding it into the next.js public folder or you can create something more dynamic to take into account all your environments:
|
|
231
|
+
|
|
232
|
+
Under your `/pages/api` folder create `robots.ts` file with content like:
|
|
233
|
+
|
|
234
|
+
```
|
|
235
|
+
import { NextApiRequest, NextApiResponse } from 'next'
|
|
236
|
+
import { getHost } from '@newskit-render/shared-components'
|
|
237
|
+
|
|
238
|
+
export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
|
239
|
+
const crawable =
|
|
240
|
+
process.env.NODE_ENV === 'production' ? 'Allow: /' : 'Disallow: /'
|
|
241
|
+
const robots = `User-agent: *
|
|
242
|
+
${crawable}
|
|
243
|
+
Sitemap: ${new URL(getHost(req) as string)}sitemap.xml
|
|
244
|
+
Sitemap: ${new URL(getHost(req) as string)}news-sitemap.xml
|
|
245
|
+
Sitemap: ${new URL(getHost(req) as string)}pages-sitemap.xml
|
|
246
|
+
Sitemap: ${new URL(getHost(req) as string)}competitions-sitemap.xml`
|
|
247
|
+
|
|
248
|
+
res.statusCode = 200
|
|
249
|
+
res.setHeader('Content-Type', 'text/plain')
|
|
250
|
+
res.write(robots)
|
|
251
|
+
res.end()
|
|
252
|
+
}
|
|
253
|
+
```
|
|
254
|
+
update the `next.config.js` file to add rewrites:
|
|
255
|
+
|
|
256
|
+
```
|
|
257
|
+
async rewrites() {
|
|
258
|
+
return [
|
|
259
|
+
{
|
|
260
|
+
source: '/robots.txt',
|
|
261
|
+
destination: '/api/robots',
|
|
262
|
+
},
|
|
263
|
+
]
|
|
264
|
+
},
|
|
265
|
+
```
|
|
266
|
+
|
|
138
267
|
### rssFeed
|
|
139
268
|
|
|
140
269
|
`rssFeed` - this funtion will handle the logic for `feed.ts` route. It will receive the following parameters:
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.buildSiteMapImages = void 0;
|
|
7
|
+
var lodash_escape_1 = __importDefault(require("lodash.escape"));
|
|
8
|
+
var buildSiteMapImages = function (body) {
|
|
9
|
+
var images = body.filter(function (block) { return block.url; });
|
|
10
|
+
return images
|
|
11
|
+
.map(function (_a) {
|
|
12
|
+
var url = _a.url, caption = _a.caption, credit = _a.credit;
|
|
13
|
+
return "\n<image:image>\n <image:loc>".concat((0, lodash_escape_1.default)(url), "</image:loc>\n ").concat(caption ? "<image:caption>".concat((0, lodash_escape_1.default)(caption), "</image:caption>") : "", "\n ").concat(credit ? "<image:credit>".concat((0, lodash_escape_1.default)(credit), "</image:credit>") : "", "\n</image:image>\n");
|
|
14
|
+
})
|
|
15
|
+
.join('');
|
|
16
|
+
};
|
|
17
|
+
exports.buildSiteMapImages = buildSiteMapImages;
|
|
18
|
+
//# sourceMappingURL=buildSiteMapImages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildSiteMapImages.js","sourceRoot":"","sources":["../../../../src/helpers/createSitemap/buildSiteMapImages.ts"],"names":[],"mappings":";;;;;;AACA,gEAAkC;AAE3B,IAAM,kBAAkB,GAAG,UAAC,IAAmB;IACpD,IAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CACxB,UAAC,KAAK,IAAK,OAAC,KAAoB,CAAC,GAAG,EAAzB,CAAyB,CACrB,CAAA;IACjB,OAAO,MAAM;SACV,GAAG,CACF,UAAC,EAAoC;YAAlC,GAAG,SAAA,EAAE,OAAO,aAAA,EAAE,MAAM,YAAA;QAAmB,OAAA,wCAEjC,IAAA,uBAAM,EAAC,GAAG,CAAC,6BACtB,OAAO,CAAC,CAAC,CAAC,yBAAkB,IAAA,uBAAM,EAAC,OAAO,CAAC,qBAAkB,CAAC,CAAC,CAAC,EAAE,iBAClE,MAAM,CAAC,CAAC,CAAC,wBAAiB,IAAA,uBAAM,EAAC,MAAM,CAAC,oBAAiB,CAAC,CAAC,CAAC,EAAE,uBAEjE;IAN+C,CAM/C,CACI;SACA,IAAI,CAAC,EAAE,CAAC,CAAA;AACb,CAAC,CAAA;AAfY,QAAA,kBAAkB,sBAe9B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Article, ArticleBody } from '../types';
|
|
2
|
+
export declare const buildSiteMapVideos: ({ domain, body, headline, publishedDateTime, id, publisher, articleCategory, }: {
|
|
3
|
+
domain: string;
|
|
4
|
+
body: ArticleBody[];
|
|
5
|
+
headline: Article['headline'];
|
|
6
|
+
publishedDateTime: Article['publishedDateTime'];
|
|
7
|
+
id: Article['id'];
|
|
8
|
+
publisher: Article['publisher'];
|
|
9
|
+
articleCategory: string;
|
|
10
|
+
}) => string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.buildSiteMapVideos = void 0;
|
|
7
|
+
var lodash_escape_1 = __importDefault(require("lodash.escape"));
|
|
8
|
+
var buildSiteMapVideos = function (_a) {
|
|
9
|
+
var domain = _a.domain, body = _a.body, headline = _a.headline, publishedDateTime = _a.publishedDateTime, articleId = _a.id, publisher = _a.publisher, articleCategory = _a.articleCategory;
|
|
10
|
+
var videos = body.filter(function (block) { return block.playerId; });
|
|
11
|
+
return videos
|
|
12
|
+
.map(function (_a) {
|
|
13
|
+
var accountId = _a.accountId, id = _a.id, playerId = _a.playerId;
|
|
14
|
+
var playerLoc = "https://".concat(domain, "/player/brightcove/?video_id=").concat(id, "&account_id=").concat(accountId, "&player_id=").concat(playerId, "&post_id=").concat(articleId);
|
|
15
|
+
return "\n<video:video>\n <video:player_loc>".concat((0, lodash_escape_1.default)(playerLoc), "</video:player_loc>\n <video:thumbnail_loc>NA</video:thumbnail_loc>\n <video:title>").concat((0, lodash_escape_1.default)(headline), "</video:title>\n <video:description>NA</video:description>\n <video:publication_date>").concat((0, lodash_escape_1.default)(publishedDateTime), "</video:publication_date>\n <video:uploader>").concat((0, lodash_escape_1.default)(publisher), "</video:uploader>\n <video:requires_subscription>No</video:requires_subscription>\n <video:category>").concat((0, lodash_escape_1.default)(articleCategory), "</video:category>\n <video:live>No</video:live>\n</video:video>\n");
|
|
16
|
+
})
|
|
17
|
+
.join('');
|
|
18
|
+
};
|
|
19
|
+
exports.buildSiteMapVideos = buildSiteMapVideos;
|
|
20
|
+
//# sourceMappingURL=buildSiteMapVideos.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildSiteMapVideos.js","sourceRoot":"","sources":["../../../../src/helpers/createSitemap/buildSiteMapVideos.ts"],"names":[],"mappings":";;;;;;AACA,gEAAkC;AAE3B,IAAM,kBAAkB,GAAG,UAAC,EAgBlC;QAfC,MAAM,YAAA,EACN,IAAI,UAAA,EACJ,QAAQ,cAAA,EACR,iBAAiB,uBAAA,EACb,SAAS,QAAA,EACb,SAAS,eAAA,EACT,eAAe,qBAAA;IAUf,IAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CACxB,UAAC,KAAK,IAAK,OAAC,KAA8B,CAAC,QAAQ,EAAxC,CAAwC,CAC1B,CAAA;IAE3B,OAAO,MAAM;SACV,GAAG,CAAC,UAAC,EAAiD;YAA/C,SAAS,eAAA,EAAE,EAAE,QAAA,EAAE,QAAQ,cAAA;QAC7B,IAAM,SAAS,GAAG,kBAAW,MAAM,0CAAgC,EAAE,yBAAe,SAAS,wBAAc,QAAQ,sBAAY,SAAS,CAAE,CAAA;QAC1I,OAAO,+CAES,IAAA,uBAAM,EAAC,SAAS,CAAC,kGAEtB,IAAA,uBAAM,EAAC,QAAQ,CAAC,oGAEL,IAAA,uBAAM,EAAC,iBAAiB,CAAC,0DACjC,IAAA,uBAAM,EAAC,SAAS,CAAC,mHAEjB,IAAA,uBAAM,EAAC,eAAe,CAAC,uEAG1C,CAAA;IACG,CAAC,CAAC;SACD,IAAI,CAAC,EAAE,CAAC,CAAA;AACb,CAAC,CAAA;AAvCY,QAAA,kBAAkB,sBAuC9B"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createArticleSitemap = void 0;
|
|
7
|
+
var getSitemapHeaders_1 = require("./getSitemapHeaders");
|
|
8
|
+
var getCategorySlug_1 = require("./getCategorySlug");
|
|
9
|
+
var generateArticleSlug_1 = require("./generateArticleSlug");
|
|
10
|
+
var buildSiteMapImages_1 = require("./buildSiteMapImages");
|
|
11
|
+
var buildSiteMapVideos_1 = require("./buildSiteMapVideos");
|
|
12
|
+
var lodash_escape_1 = __importDefault(require("lodash.escape"));
|
|
13
|
+
var createArticleSitemap = function (articlesList, domain, publicationName, isNewsSitemap, changefreq, priority) {
|
|
14
|
+
var urlsetHeaders = (0, getSitemapHeaders_1.getSitemapHeaders)(isNewsSitemap);
|
|
15
|
+
return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n <urlset \n ".concat(urlsetHeaders, " \n xmlns:image=\"http://www.google.com/schemas/sitemap-image/1.1\"\n xmlns:video=\"http://www.google.com/schemas/sitemap-video/1.1\"\n >\n ").concat(articlesList
|
|
16
|
+
.map(function (_a) {
|
|
17
|
+
var id = _a.id, publishedDateTime = _a.publishedDateTime, updatedDateTime = _a.updatedDateTime, publisher = _a.publisher, headline = _a.headline, body = _a.body, categories = _a.categories;
|
|
18
|
+
var articleCategory = (0, getCategorySlug_1.getCategorySlug)(categories);
|
|
19
|
+
var articleSlug = (0, generateArticleSlug_1.generateArticleSlug)(headline);
|
|
20
|
+
var imagesSitemap = (0, buildSiteMapImages_1.buildSiteMapImages)(body);
|
|
21
|
+
var videoSitemap = (0, buildSiteMapVideos_1.buildSiteMapVideos)({
|
|
22
|
+
domain: domain,
|
|
23
|
+
body: body,
|
|
24
|
+
headline: headline,
|
|
25
|
+
publishedDateTime: publishedDateTime,
|
|
26
|
+
id: id,
|
|
27
|
+
publisher: publisher,
|
|
28
|
+
articleCategory: articleCategory,
|
|
29
|
+
});
|
|
30
|
+
var loc = "https://".concat(domain, "/").concat(articleCategory, "/").concat(id, "/").concat(articleSlug);
|
|
31
|
+
return "\n <url>\n <loc>".concat((0, lodash_escape_1.default)(loc), "</loc> \n ").concat(isNewsSitemap
|
|
32
|
+
? "<news:news>\n <news:publication>\n <news:name>".concat((0, lodash_escape_1.default)(publicationName), "</news:name>\n <news:language>en</news:language>\n </news:publication>\n <news:publication_date>").concat((0, lodash_escape_1.default)(publishedDateTime), "</news:publication_date>\n <news:title>").concat((0, lodash_escape_1.default)(headline), "</news:title>\n </news:news>")
|
|
33
|
+
: '', " \n <changefreq>").concat((0, lodash_escape_1.default)(changefreq), "</changefreq>\n <priority>").concat((0, lodash_escape_1.default)(priority), "</priority>\n <lastmod>").concat((0, lodash_escape_1.default)(updatedDateTime), "</lastmod>\n ").concat(imagesSitemap, "\n ").concat(videoSitemap, "\n </url>\n ");
|
|
34
|
+
})
|
|
35
|
+
.join(''), "\n </urlset>\n");
|
|
36
|
+
};
|
|
37
|
+
exports.createArticleSitemap = createArticleSitemap;
|
|
38
|
+
//# sourceMappingURL=createArticleSitemap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createArticleSitemap.js","sourceRoot":"","sources":["../../../../src/helpers/createSitemap/createArticleSitemap.ts"],"names":[],"mappings":";;;;;;AAAA,yDAAuD;AACvD,qDAAmD;AACnD,6DAA2D;AAC3D,2DAAyD;AACzD,2DAAyD;AAEzD,gEAAkC;AAE3B,IAAM,oBAAoB,GAAG,UAClC,YAAyB,EACzB,MAAc,EACd,eAAuB,EACvB,aAAsB,EACtB,UAAsB,EACtB,QAAkB;IAElB,IAAM,aAAa,GAAG,IAAA,qCAAiB,EAAC,aAAa,CAAC,CAAA;IACtD,OAAO,sEAEH,aAAa,mKAIb,YAAY;SACX,GAAG,CACF,UAAC,EAQS;YAPR,EAAE,QAAA,EACF,iBAAiB,uBAAA,EACjB,eAAe,qBAAA,EACf,SAAS,eAAA,EACT,QAAQ,cAAA,EACR,IAAI,UAAA,EACJ,UAAU,gBAAA;QAEV,IAAM,eAAe,GAAG,IAAA,iCAAe,EAAC,UAAU,CAAC,CAAA;QACnD,IAAM,WAAW,GAAG,IAAA,yCAAmB,EAAC,QAAQ,CAAC,CAAA;QACjD,IAAM,aAAa,GAAG,IAAA,uCAAkB,EAAC,IAAI,CAAC,CAAA;QAC9C,IAAM,YAAY,GAAG,IAAA,uCAAkB,EAAC;YACtC,MAAM,QAAA;YACN,IAAI,MAAA;YACJ,QAAQ,UAAA;YACR,iBAAiB,mBAAA;YACjB,EAAE,IAAA;YACF,SAAS,WAAA;YACT,eAAe,iBAAA;SAChB,CAAC,CAAA;QACF,IAAM,GAAG,GAAG,kBAAW,MAAM,cAAI,eAAe,cAAI,EAAE,cAAI,WAAW,CAAE,CAAA;QACvE,OAAO,8CAEE,IAAA,uBAAM,EAAC,GAAG,CAAC,iCAEjB,aAAa;YACX,CAAC,CAAC,gFAES,IAAA,uBAAM,EAAC,eAAe,CAAC,iJAGX,IAAA,uBAAM,EAC7B,iBAAiB,CAClB,gEACa,IAAA,uBAAM,EAAC,QAAQ,CAAC,2CACnB;YACT,CAAC,CAAC,EAAE,wCAEO,IAAA,uBAAM,EAAC,UAAU,CAAC,kDACpB,IAAA,uBAAM,EAAC,QAAQ,CAAC,+CACjB,IAAA,uBAAM,EAAC,eAAe,CAAC,qCAChC,aAAa,2BACb,YAAY,iCAEjB,CAAA;IACD,CAAC,CACF;SACA,IAAI,CAAC,EAAE,CAAC,oBAEd,CAAA;AACD,CAAC,CAAA;AApEY,QAAA,oBAAoB,wBAoEhC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { CustomStaticPage, Page, ChangeFreq, Priority, DataType } from '../types';
|
|
2
|
+
import { Publisher } from '@newskit-render/api';
|
|
3
|
+
export declare const createPagesSitemap: (pages: Page[], domain: string, changefreq: ChangeFreq, priority: Priority, dataType: DataType, publisher: Publisher, customStaticPageCollection?: CustomStaticPage[]) => string;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createPagesSitemap = void 0;
|
|
7
|
+
var buildSiteMapImages_1 = require("./buildSiteMapImages");
|
|
8
|
+
var buildSiteMapVideos_1 = require("./buildSiteMapVideos");
|
|
9
|
+
var lodash_escape_1 = __importDefault(require("lodash.escape"));
|
|
10
|
+
var createPagesSitemap = function (pages, domain, changefreq, priority, dataType, publisher, customStaticPageCollection) {
|
|
11
|
+
var vid = dataType === 'pages'
|
|
12
|
+
? 'xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"'
|
|
13
|
+
: '';
|
|
14
|
+
return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n <urlset \n xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"\n xmlns:image=\"http://www.google.com/schemas/sitemap-image/1.1\"\n ".concat(vid, "\n >\n ").concat(dataType === 'pages'
|
|
15
|
+
? "\n <url>\n <loc>".concat((0, lodash_escape_1.default)("https://".concat(domain)), "</loc> \n <changefreq>").concat((0, lodash_escape_1.default)(changefreq), "</changefreq>\n <priority>").concat((0, lodash_escape_1.default)(priority), "</priority>\n <lastmod>").concat((0, lodash_escape_1.default)(new Date().toISOString()), "</lastmod>\n </url> \n ")
|
|
16
|
+
: '', "\n ").concat((customStaticPageCollection === null || customStaticPageCollection === void 0 ? void 0 : customStaticPageCollection.length)
|
|
17
|
+
? customStaticPageCollection
|
|
18
|
+
.map(function (_a) {
|
|
19
|
+
var url = _a.url, slug = _a.slug;
|
|
20
|
+
return "\n <url>\n <loc>".concat((0, lodash_escape_1.default)("https://".concat(url || domain, "/").concat(slug)), "</loc>\n <changefreq>").concat((0, lodash_escape_1.default)(changefreq), "</changefreq>\n <priority>").concat((0, lodash_escape_1.default)(priority), "</priority>\n <lastmod>").concat((0, lodash_escape_1.default)(new Date().toISOString()), "</lastmod>\n </url>\n ");
|
|
21
|
+
})
|
|
22
|
+
.join('')
|
|
23
|
+
: '', "\n ").concat(pages
|
|
24
|
+
.map(function (_a) {
|
|
25
|
+
var dateUpdated = _a.dateUpdated, slug = _a.slug, id = _a.id, body = _a.body, title = _a.title;
|
|
26
|
+
var url = dataType === 'competitions'
|
|
27
|
+
? "https://".concat(domain, "/").concat(dataType, "/").concat(id, "/").concat(slug)
|
|
28
|
+
: "https://".concat(domain, "/").concat(slug);
|
|
29
|
+
var imagesSitemap = (0, buildSiteMapImages_1.buildSiteMapImages)(body);
|
|
30
|
+
var videoSitemap = (0, buildSiteMapVideos_1.buildSiteMapVideos)({
|
|
31
|
+
domain: domain,
|
|
32
|
+
body: body,
|
|
33
|
+
headline: title,
|
|
34
|
+
publishedDateTime: dateUpdated,
|
|
35
|
+
id: id,
|
|
36
|
+
publisher: publisher,
|
|
37
|
+
articleCategory: dataType,
|
|
38
|
+
});
|
|
39
|
+
return "\n <url>\n <loc>".concat((0, lodash_escape_1.default)(url), "</loc> \n <changefreq>").concat((0, lodash_escape_1.default)(changefreq), "</changefreq>\n <priority>").concat((0, lodash_escape_1.default)(priority), "</priority>\n <lastmod>").concat((0, lodash_escape_1.default)(dateUpdated), "</lastmod>\n ").concat(imagesSitemap, "\n ").concat(videoSitemap, "\n </url>\n ");
|
|
40
|
+
})
|
|
41
|
+
.join(''), "\n </urlset>\n ");
|
|
42
|
+
};
|
|
43
|
+
exports.createPagesSitemap = createPagesSitemap;
|
|
44
|
+
//# sourceMappingURL=createPagesSitemap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createPagesSitemap.js","sourceRoot":"","sources":["../../../../src/helpers/createSitemap/createPagesSitemap.ts"],"names":[],"mappings":";;;;;;AAQA,2DAAyD;AACzD,2DAAyD;AACzD,gEAAkC;AAE3B,IAAM,kBAAkB,GAAG,UAChC,KAAa,EACb,MAAc,EACd,UAAsB,EACtB,QAAkB,EAClB,QAAkB,EAClB,SAAoB,EACpB,0BAA+C;IAE/C,IAAM,GAAG,GACP,QAAQ,KAAK,OAAO;QAClB,CAAC,CAAC,+DAA+D;QACjE,CAAC,CAAC,EAAE,CAAA;IACR,OAAO,sMAIH,GAAG,sBAGL,QAAQ,KAAK,OAAO;QAClB,CAAC,CAAC,kCAEK,IAAA,uBAAM,EAAC,kBAAW,MAAM,CAAE,CAAC,wCACpB,IAAA,uBAAM,EAAC,UAAU,CAAC,4CACpB,IAAA,uBAAM,EAAC,QAAQ,CAAC,yCACjB,IAAA,uBAAM,EAAC,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,iCAE9C;QACG,CAAC,CAAC,EAAE,iBAGN,CAAA,0BAA0B,aAA1B,0BAA0B,uBAA1B,0BAA0B,CAAE,MAAM;QAChC,CAAC,CAAC,0BAA0B;aACvB,GAAG,CAAC,UAAC,EAAa;gBAAX,GAAG,SAAA,EAAE,IAAI,UAAA;YACf,OAAO,kCAEN,IAAA,uBAAM,EAAC,kBAAW,GAAG,IAAI,MAAM,cAAI,IAAI,CAAE,CAAC,uCACnC,IAAA,uBAAM,EAAC,UAAU,CAAC,4CACpB,IAAA,uBAAM,EAAC,QAAQ,CAAC,yCACjB,IAAA,uBAAM,EAAC,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,iCAE5C,CAAA;QACK,CAAC,CAAC;aACD,IAAI,CAAC,EAAE,CAAC;QACb,CAAC,CAAC,EAAE,iBAEN,KAAK;SACJ,GAAG,CAAC,UAAC,EAA4C;YAA1C,WAAW,iBAAA,EAAE,IAAI,UAAA,EAAE,EAAE,QAAA,EAAE,IAAI,UAAA,EAAE,KAAK,WAAA;QACxC,IAAM,GAAG,GACP,QAAQ,KAAK,cAAc;YACzB,CAAC,CAAC,kBAAW,MAAM,cAAI,QAAQ,cAAI,EAAE,cAAI,IAAI,CAAE;YAC/C,CAAC,CAAC,kBAAW,MAAM,cAAI,IAAI,CAAE,CAAA;QACjC,IAAM,aAAa,GAAG,IAAA,uCAAkB,EAAC,IAAI,CAAC,CAAA;QAC9C,IAAM,YAAY,GAAG,IAAA,uCAAkB,EAAC;YACtC,MAAM,QAAA;YACN,IAAI,MAAA;YACJ,QAAQ,EAAE,KAAK;YACf,iBAAiB,EAAE,WAAW;YAC9B,EAAE,IAAA;YACF,SAAS,WAAA;YACT,eAAe,EAAE,QAAQ;SAC1B,CAAC,CAAA;QACF,OAAO,sCAEE,IAAA,uBAAM,EAAC,GAAG,CAAC,0CACJ,IAAA,uBAAM,EAAC,UAAU,CAAC,8CACpB,IAAA,uBAAM,EAAC,QAAQ,CAAC,2CACjB,IAAA,uBAAM,EAAC,WAAW,CAAC,iCAC5B,aAAa,uBACb,YAAY,2BAEf,CAAA;IACH,CAAC,CAAC;SACD,IAAI,CAAC,EAAE,CAAC,sBAEV,CAAA;AACH,CAAC,CAAA;AA7EY,QAAA,kBAAkB,sBA6E9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const createSitemapIndex: (domain: string, dateCollection: Array<string>) => string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSitemapIndex = void 0;
|
|
4
|
+
var createSitemapIndex = function (domain, dateCollection) { return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n <sitemapindex \n xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"\n >\n ".concat(dateCollection
|
|
5
|
+
.map(function (date) {
|
|
6
|
+
var year = date.split('-')[0];
|
|
7
|
+
var month = date.split('-')[1];
|
|
8
|
+
var day = date.split('-')[2];
|
|
9
|
+
return "\n <sitemap>\n <loc>https://".concat(domain, "/sitemap.xml?yyyy=").concat(year, "&mm=").concat(month, "&dd=").concat(day, "</loc>\n </sitemap>\n ");
|
|
10
|
+
})
|
|
11
|
+
.join(''), "\n </sitemapindex>\n"); };
|
|
12
|
+
exports.createSitemapIndex = createSitemapIndex;
|
|
13
|
+
//# sourceMappingURL=createSitemapIndex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createSitemapIndex.js","sourceRoot":"","sources":["../../../../src/helpers/createSitemap/createSitemapIndex.ts"],"names":[],"mappings":";;;AAAO,IAAM,kBAAkB,GAAG,UAChC,MAAc,EACd,cAA6B,IAClB,OAAA,wIAIT,cAAc;KACb,GAAG,CAAC,UAAC,IAAI;IACR,IAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IAC/B,IAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IAChC,IAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IAC9B,OAAO,kDAEU,MAAM,+BAAqB,IAAI,qBAAW,KAAK,qBAAW,GAAG,mCAE/E,CAAA;AACD,CAAC,CAAC;KACD,IAAI,CAAC,EAAE,CAAC,0BAEZ,EAjBY,CAiBZ,CAAA;AApBY,QAAA,kBAAkB,sBAoB9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const generateArticleSlug: (title: string) => string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateArticleSlug = void 0;
|
|
4
|
+
var generateArticleSlug = function (title) {
|
|
5
|
+
return title
|
|
6
|
+
.replace(/[^a-zA-Z0-9 ]/g, '')
|
|
7
|
+
.replace(/\s\s+/g, ' ')
|
|
8
|
+
.toLowerCase()
|
|
9
|
+
.replace(/ /g, '-')
|
|
10
|
+
.trim();
|
|
11
|
+
};
|
|
12
|
+
exports.generateArticleSlug = generateArticleSlug;
|
|
13
|
+
//# sourceMappingURL=generateArticleSlug.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateArticleSlug.js","sourceRoot":"","sources":["../../../../src/helpers/createSitemap/generateArticleSlug.ts"],"names":[],"mappings":";;;AAAO,IAAM,mBAAmB,GAAG,UAAC,KAAa;IAC/C,OAAA,KAAK;SACF,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC;SAC7B,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;SACtB,WAAW,EAAE;SACb,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC;SAClB,IAAI,EAAE;AALT,CAKS,CAAA;AANE,QAAA,mBAAmB,uBAMrB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCategorySlug = void 0;
|
|
4
|
+
var getCategorySlug = function (categories) {
|
|
5
|
+
if (!Array.isArray(categories) || categories.length === 0)
|
|
6
|
+
return 'uncategorized';
|
|
7
|
+
return categories[0].slug || 'uncategorized';
|
|
8
|
+
};
|
|
9
|
+
exports.getCategorySlug = getCategorySlug;
|
|
10
|
+
//# sourceMappingURL=getCategorySlug.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCategorySlug.js","sourceRoot":"","sources":["../../../../src/helpers/createSitemap/getCategorySlug.ts"],"names":[],"mappings":";;;AAEO,IAAM,eAAe,GAAG,UAAC,UAAsB;IACpD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QACvD,OAAO,eAAe,CAAA;IACxB,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,eAAe,CAAA;AAC9C,CAAC,CAAA;AAJY,QAAA,eAAe,mBAI3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getSitemapHeaders: (isNewsSitemap: boolean) => string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSitemapHeaders = void 0;
|
|
4
|
+
var getSitemapHeaders = function (isNewsSitemap) {
|
|
5
|
+
return isNewsSitemap
|
|
6
|
+
? "xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\" \n xmlns:news=\"http://www.google.com/schemas/sitemap-news/0.9\""
|
|
7
|
+
: "xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"";
|
|
8
|
+
};
|
|
9
|
+
exports.getSitemapHeaders = getSitemapHeaders;
|
|
10
|
+
//# sourceMappingURL=getSitemapHeaders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSitemapHeaders.js","sourceRoot":"","sources":["../../../../src/helpers/createSitemap/getSitemapHeaders.ts"],"names":[],"mappings":";;;AAAO,IAAM,iBAAiB,GAAG,UAAC,aAAsB;IACtD,OAAA,aAAa;QACX,CAAC,CAAC,2HAC0D;QAC5D,CAAC,CAAC,uDAAqD;AAHzD,CAGyD,CAAA;AAJ9C,QAAA,iBAAiB,qBAI6B"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './createArticleSitemap';
|
|
2
|
+
export * from './createPagesSitemap';
|
|
3
|
+
export * from './createSitemapIndex';
|
|
4
|
+
export * from './getCategorySlug';
|
|
5
|
+
export * from './generateArticleSlug';
|
|
6
|
+
export * from './buildSiteMapImages';
|
|
7
|
+
export * from './buildSiteMapVideos';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./createArticleSitemap"), exports);
|
|
18
|
+
__exportStar(require("./createPagesSitemap"), exports);
|
|
19
|
+
__exportStar(require("./createSitemapIndex"), exports);
|
|
20
|
+
__exportStar(require("./getCategorySlug"), exports);
|
|
21
|
+
__exportStar(require("./generateArticleSlug"), exports);
|
|
22
|
+
__exportStar(require("./buildSiteMapImages"), exports);
|
|
23
|
+
__exportStar(require("./buildSiteMapVideos"), exports);
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/helpers/createSitemap/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAsC;AACtC,uDAAoC;AACpC,uDAAoC;AACpC,oDAAiC;AACjC,wDAAqC;AACrC,uDAAoC;AACpC,uDAAoC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -34,51 +35,42 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
34
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
36
|
}
|
|
36
37
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
case 2:
|
|
73
|
-
data = (_a.sent()).data;
|
|
74
|
-
cursor = data.pages.pageCursors.next;
|
|
75
|
-
channels = channels.concat(data.pages.data);
|
|
76
|
-
_a.label = 3;
|
|
77
|
-
case 3:
|
|
78
|
-
if (cursor !== '') return [3 /*break*/, 1];
|
|
79
|
-
_a.label = 4;
|
|
80
|
-
case 4: return [2 /*return*/, channels];
|
|
81
|
-
}
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.queryPages = void 0;
|
|
40
|
+
var queries_1 = require("../sitemap/queries");
|
|
41
|
+
var queryPages = function (publisher, apolloClient, dataType) {
|
|
42
|
+
if (dataType === void 0) { dataType = 'pages'; }
|
|
43
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
44
|
+
var dateQuery, pages, cursor, data;
|
|
45
|
+
return __generator(this, function (_a) {
|
|
46
|
+
switch (_a.label) {
|
|
47
|
+
case 0:
|
|
48
|
+
dateQuery = {
|
|
49
|
+
pages: queries_1.GET_PAGES,
|
|
50
|
+
competitions: queries_1.GET_COMPETITIONS,
|
|
51
|
+
};
|
|
52
|
+
pages = [];
|
|
53
|
+
cursor = '';
|
|
54
|
+
_a.label = 1;
|
|
55
|
+
case 1: return [4 /*yield*/, apolloClient.query({
|
|
56
|
+
query: dateQuery[dataType],
|
|
57
|
+
variables: {
|
|
58
|
+
cursor: cursor,
|
|
59
|
+
publisher: publisher,
|
|
60
|
+
},
|
|
61
|
+
})];
|
|
62
|
+
case 2:
|
|
63
|
+
data = (_a.sent()).data;
|
|
64
|
+
cursor = data[dataType].pageCursors.next;
|
|
65
|
+
pages = pages.concat(data[dataType].data);
|
|
66
|
+
_a.label = 3;
|
|
67
|
+
case 3:
|
|
68
|
+
if (cursor !== '') return [3 /*break*/, 1];
|
|
69
|
+
_a.label = 4;
|
|
70
|
+
case 4: return [2 /*return*/, pages];
|
|
71
|
+
}
|
|
72
|
+
});
|
|
82
73
|
});
|
|
83
|
-
}
|
|
84
|
-
|
|
74
|
+
};
|
|
75
|
+
exports.queryPages = queryPages;
|
|
76
|
+
//# sourceMappingURL=queryPages.js.map
|