@cocreate/sitemap 1.0.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/.github/FUNDING.yml +3 -0
- package/.github/workflows/automated.yml +69 -0
- package/CHANGELOG.md +6 -0
- package/CONTRIBUTING.md +96 -0
- package/CoCreate.config.js +24 -0
- package/LICENSE +683 -0
- package/README.md +91 -0
- package/demo/index.html +18 -0
- package/docs/index.html +228 -0
- package/package.json +47 -0
- package/release.config.js +22 -0
- package/src/index.js +72 -0
package/README.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# CoCreate-sitemap
|
|
2
|
+
|
|
3
|
+
A simple sitemap component in vanilla javascript. Easily configured using HTML5 data-attributes and/or JavaScript API. Take it for a spin in our [playground!](https://cocreate.app/docs/sitemap)
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
9
|
+

|
|
10
|
+

|
|
11
|
+
|
|
12
|
+

|
|
13
|
+
|
|
14
|
+
## [Docs & Demo](https://cocreate.app/docs/sitemap)
|
|
15
|
+
|
|
16
|
+
For a complete guide and working demo refer to the [doumentation](https://cocreate.app/docs/sitemap)
|
|
17
|
+
|
|
18
|
+
## CDN
|
|
19
|
+
|
|
20
|
+
```html
|
|
21
|
+
<script src="https://cdn.cocreate.app/sitemap/latest/CoCreate-sitemap.min.js"></script>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
```html
|
|
25
|
+
<script src="https://cdn.cocreate.app/sitemap/latest/CoCreate-sitemap.min.css"></script>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## NPM
|
|
29
|
+
|
|
30
|
+
```shell
|
|
31
|
+
$ npm i @cocreate/sitemap
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## yarn
|
|
35
|
+
|
|
36
|
+
```shell
|
|
37
|
+
$ yarn install @cocreate/sitemap
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
# Table of Contents
|
|
41
|
+
|
|
42
|
+
- [Table of Contents](#table-of-contents)
|
|
43
|
+
- [Announcements](#announcements)
|
|
44
|
+
- [Roadmap](#roadmap)
|
|
45
|
+
- [How to Contribute](#how-to-contribute)
|
|
46
|
+
- [About](#about)
|
|
47
|
+
- [License](#license)
|
|
48
|
+
|
|
49
|
+
<a name="announcements"></a>
|
|
50
|
+
|
|
51
|
+
# Announcements
|
|
52
|
+
|
|
53
|
+
All updates to this library are documented in our [CHANGELOG](https://github.com/CoCreate-app/CoCreate-sitemap/blob/master/CHANGELOG.md) and [releases](https://github.com/CoCreate-app/CoCreate-sitemap/releases). You may also subscribe to email for releases and breaking changes.
|
|
54
|
+
|
|
55
|
+
<a name="roadmap"></a>
|
|
56
|
+
|
|
57
|
+
# Roadmap
|
|
58
|
+
|
|
59
|
+
If you are interested in the future direction of this project, please take a look at our open [issues](https://github.com/CoCreate-app/CoCreate-sitemap/issues) and [pull requests](https://github.com/CoCreate-app/CoCreate-sitemap/pulls). We would love to hear your feedback.
|
|
60
|
+
|
|
61
|
+
<a name="about"></a>
|
|
62
|
+
|
|
63
|
+
# About
|
|
64
|
+
|
|
65
|
+
CoCreate-sitemap is guided and supported by the CoCreate Developer Experience Team.
|
|
66
|
+
|
|
67
|
+
Please Email the Developer Experience Team [here](mailto:develop@cocreate.app) in case of any queries.
|
|
68
|
+
|
|
69
|
+
CoCreate-sitemap is maintained and funded by CoCreate. The names and logos for CoCreate are trademarks of CoCreate, LLC.
|
|
70
|
+
|
|
71
|
+
<a name="contribute"></a>
|
|
72
|
+
|
|
73
|
+
# How to Contribute
|
|
74
|
+
|
|
75
|
+
We encourage contribution to our libraries (you might even score some nifty swag), please see our [CONTRIBUTING](https://github.com/CoCreate-app/CoCreate-sitemap/blob/master/CONTRIBUTING.md) guide for details.
|
|
76
|
+
|
|
77
|
+
We want this library to be community-driven, and CoCreate led. We need your help to realize this goal. To help make sure we are building the right things in the right order, we ask that you create [issues](https://github.com/CoCreate-app/CoCreate-sitemap/issues) and [pull requests](https://github.com/CoCreate-app/CoCreate-sitemap/pulls) or merely upvote or comment on existing issues or pull requests.
|
|
78
|
+
|
|
79
|
+
We appreciate your continued support, thank you!
|
|
80
|
+
|
|
81
|
+
<a name="license"></a>
|
|
82
|
+
|
|
83
|
+
# License
|
|
84
|
+
|
|
85
|
+
This software is dual-licensed under the GNU Affero General Public License version 3 (AGPLv3) and a commercial license.
|
|
86
|
+
|
|
87
|
+
- **Open Source Use**: For open-source projects and non-commercial use, this software is available under the AGPLv3. The AGPLv3 allows you to freely use, modify, and distribute this software, provided that all modifications and derivative works are also licensed under the AGPLv3. For the full license text, see the [LICENSE file](https://github.com/CoCreate-app/CoCreate-sitemap/blob/master/LICENSE).
|
|
88
|
+
|
|
89
|
+
- **Commercial Use**: For-profit companies and individuals intending to use this software for commercial purposes must obtain a commercial license. The commercial license is available when you sign up for an API key on our [website](https://cocreate.app). This license permits proprietary use and modification of the software without the copyleft requirements of the AGPLv3. It is ideal for integrating this software into proprietary commercial products and applications.
|
|
90
|
+
|
|
91
|
+
If you have not purchased a commercial license and intend to use this software for commercial purposes, you are required to sign up for an API key on our website.
|
package/demo/index.html
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
|
+
<link
|
|
8
|
+
rel="icon"
|
|
9
|
+
type="image/png"
|
|
10
|
+
sizes="32x32"
|
|
11
|
+
href="../assets/favicon.ico" />
|
|
12
|
+
<title>sitemap | CoCreateJS</title>
|
|
13
|
+
</head>
|
|
14
|
+
|
|
15
|
+
<body>
|
|
16
|
+
<script src="https://CoCreate.app/dist/CoCreate.js"></script>
|
|
17
|
+
</body>
|
|
18
|
+
</html>
|
package/docs/index.html
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
|
+
<title>CoCreate-sitemap Documentation | CoCreateJS</title>
|
|
8
|
+
<link
|
|
9
|
+
rel="icon"
|
|
10
|
+
type="image/png"
|
|
11
|
+
sizes="32x32"
|
|
12
|
+
href="https://cocreate.app/images/favicon.ico" />
|
|
13
|
+
<meta
|
|
14
|
+
name="description"
|
|
15
|
+
content="A simple HTML5 and pure javascript component. Easy configuration using data-attributes and highly styleable." />
|
|
16
|
+
<meta
|
|
17
|
+
name="keywords"
|
|
18
|
+
content="helper classes, utility classes, css framework, css library, inline style classes" />
|
|
19
|
+
<meta name="robots" content="index,follow" />
|
|
20
|
+
|
|
21
|
+
<!-- CoCreate CSS CDN -->
|
|
22
|
+
</head>
|
|
23
|
+
|
|
24
|
+
<body>
|
|
25
|
+
<div array="" object="" key="" id="cocreate-sitemap">
|
|
26
|
+
<div
|
|
27
|
+
class="display:flex flex-wrap:wrap justify-content:space-between margin:10px">
|
|
28
|
+
<div class="display:flex align-items:center">
|
|
29
|
+
<h2>CoCreate-sitemap</h2>
|
|
30
|
+
</div>
|
|
31
|
+
<div
|
|
32
|
+
class="display:flex align-items:center font-size:20px"
|
|
33
|
+
share-height="600"
|
|
34
|
+
share-width="500"
|
|
35
|
+
share-media="https://via.placeholder.com/300/09f/fff.png">
|
|
36
|
+
<a
|
|
37
|
+
href="https://github.com/CoCreate-app/CoCreate-sitemap"
|
|
38
|
+
target="_blank"
|
|
39
|
+
class="margin-right:15px"
|
|
40
|
+
><i class="fab fa-github"></i
|
|
41
|
+
></a>
|
|
42
|
+
<a
|
|
43
|
+
class="margin-right:15px share"
|
|
44
|
+
share-network="twitter"
|
|
45
|
+
title="Share on twitter"
|
|
46
|
+
><i class="fab fa-twitter"></i
|
|
47
|
+
></a>
|
|
48
|
+
<a
|
|
49
|
+
class="margin-right:15px share"
|
|
50
|
+
share-network="facebook"
|
|
51
|
+
title="Share on Facebook"
|
|
52
|
+
><i class="fab fa-facebook"></i
|
|
53
|
+
></a>
|
|
54
|
+
<a
|
|
55
|
+
class="margin-right:15px share"
|
|
56
|
+
share-network="instagram"
|
|
57
|
+
title="Share on instagram"
|
|
58
|
+
><i class="fab fa-instagram"></i
|
|
59
|
+
></a>
|
|
60
|
+
<a
|
|
61
|
+
class="margin-right:15px share"
|
|
62
|
+
share-network="share"
|
|
63
|
+
title="Share on share"
|
|
64
|
+
><i class="fas fa-share-alt"></i
|
|
65
|
+
></a>
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
<h1 class="max-width:500px margin:20px_10px">
|
|
69
|
+
A simple HTML5, CSS and pure javascript component. Easy
|
|
70
|
+
configuration using data-attributes and highly styleable.
|
|
71
|
+
</h1>
|
|
72
|
+
<div id="sitemap-section" class="display:flex flex-wrap:wrap">
|
|
73
|
+
<div class="flex-grow:1 width:300px padding:20px_10px">
|
|
74
|
+
<h2
|
|
75
|
+
class="border-bottom:1px_solid_lightgrey padding:5px_0px">
|
|
76
|
+
Install
|
|
77
|
+
</h2>
|
|
78
|
+
<pre
|
|
79
|
+
class="margin-top:15px"><code class="language-javascript">npm install cocreate-sitemap</code></pre>
|
|
80
|
+
<p class="padding:10px_0px">Or you can use cdn link:</p>
|
|
81
|
+
<pre><code class="language-javascript">https://cdn.cocreate.app/js/CoCreate-sitemap.min.js</code></pre>
|
|
82
|
+
|
|
83
|
+
<h2
|
|
84
|
+
class="border-bottom:1px_solid_lightgrey margin-top:20px padding:5px_0px">
|
|
85
|
+
Usage
|
|
86
|
+
</h2>
|
|
87
|
+
<p class="padding:10px_0px">sitemap usage content</p>
|
|
88
|
+
<pre><code class="language-html"><div></div></code></pre>
|
|
89
|
+
|
|
90
|
+
<h2
|
|
91
|
+
class="border-bottom:1px_solid_lightgrey margin-top:20px padding:5px_0px">
|
|
92
|
+
Reference
|
|
93
|
+
</h2>
|
|
94
|
+
<p class="padding:10px_0px">
|
|
95
|
+
This is sitemap reference content
|
|
96
|
+
</p>
|
|
97
|
+
<pre><code class="language-javascript"><div></div></code></pre>
|
|
98
|
+
<p class="padding:10px_0px">
|
|
99
|
+
This is sitemap reference content
|
|
100
|
+
</p>
|
|
101
|
+
|
|
102
|
+
<h2
|
|
103
|
+
class="border-bottom:1px_solid_lightgrey margin-top:20px padding:5px_0px">
|
|
104
|
+
Attributes
|
|
105
|
+
</h2>
|
|
106
|
+
<ul class="list-style-type:none">
|
|
107
|
+
<li
|
|
108
|
+
class="padding:15px_0px border-bottom:1px_solid_lightgrey">
|
|
109
|
+
<h4>
|
|
110
|
+
<span>sitemap</span>
|
|
111
|
+
<span class="cocreate-badge success"
|
|
112
|
+
>string</span
|
|
113
|
+
>
|
|
114
|
+
<span class="cocreate-badge warning"
|
|
115
|
+
>optional</span
|
|
116
|
+
>
|
|
117
|
+
</h4>
|
|
118
|
+
<p>sitemap-attribute</p>
|
|
119
|
+
</li>
|
|
120
|
+
<li
|
|
121
|
+
class="padding:15px_0px border-bottom:1px_solid_lightgrey">
|
|
122
|
+
<h4>
|
|
123
|
+
<span>sitemap</span>
|
|
124
|
+
<span class="cocreate-badge success"
|
|
125
|
+
>string</span
|
|
126
|
+
>
|
|
127
|
+
<span class="cocreate-badge warning"
|
|
128
|
+
>optional</span
|
|
129
|
+
>
|
|
130
|
+
</h4>
|
|
131
|
+
<p>sitemap-attribute</p>
|
|
132
|
+
</li>
|
|
133
|
+
</ul>
|
|
134
|
+
</div>
|
|
135
|
+
|
|
136
|
+
<div
|
|
137
|
+
class="flex-grow:1 width:300px padding:0px_10px margin:20px_0px border-bottom:1px_solid_lightgrey">
|
|
138
|
+
<!-- SandBox -->
|
|
139
|
+
<h2
|
|
140
|
+
class="border-bottom:1px_solid_lightgrey padding:5px_0px">
|
|
141
|
+
Demo
|
|
142
|
+
</h2>
|
|
143
|
+
<div
|
|
144
|
+
class="position:sticky top:0 padding:10px_0px height:100vh">
|
|
145
|
+
<!-- SandBox -->
|
|
146
|
+
<div
|
|
147
|
+
class="display:flex flex-direction:column position:relative overflow:hidden card border-radius:2px width:auto height:600px margin-top:20px"
|
|
148
|
+
id="playground">
|
|
149
|
+
<div
|
|
150
|
+
id="demo-code"
|
|
151
|
+
resizable
|
|
152
|
+
class="position:relative height:50%">
|
|
153
|
+
<textarea
|
|
154
|
+
type="code"
|
|
155
|
+
lang="html"
|
|
156
|
+
array="demos"
|
|
157
|
+
object=""
|
|
158
|
+
key="demo"
|
|
159
|
+
save="false"
|
|
160
|
+
id="demo"
|
|
161
|
+
class="height:100% width:100% outline:none border:none resize:none padding:5px"></textarea>
|
|
162
|
+
<div
|
|
163
|
+
resize="bottom"
|
|
164
|
+
class="background:lightgrey"></div>
|
|
165
|
+
</div>
|
|
166
|
+
|
|
167
|
+
<div
|
|
168
|
+
id="demo-preview"
|
|
169
|
+
class="position:relative overflow:auto background-color:white">
|
|
170
|
+
<div
|
|
171
|
+
get-value="#demo"
|
|
172
|
+
class="padding:20px"></div>
|
|
173
|
+
</div>
|
|
174
|
+
|
|
175
|
+
<div
|
|
176
|
+
class="font-size:20px position:absolute top:10px right:10px opacity:0.6">
|
|
177
|
+
<a
|
|
178
|
+
class="margin-right:10px"
|
|
179
|
+
id="eye"
|
|
180
|
+
show="#eye-slash"
|
|
181
|
+
hide="#eye, #demo-preview"
|
|
182
|
+
toggle="code-height"
|
|
183
|
+
toggle-selector="#demo-code"
|
|
184
|
+
><i class="far fa-eye"></i
|
|
185
|
+
></a>
|
|
186
|
+
<a
|
|
187
|
+
class="margin-right:10px"
|
|
188
|
+
hidden
|
|
189
|
+
id="eye-slash"
|
|
190
|
+
show="#eye, #demo-preview"
|
|
191
|
+
hide="#eye-slash"
|
|
192
|
+
toggle="code-height"
|
|
193
|
+
toggle-selector="#demo-code"
|
|
194
|
+
><i class="fas fa-eye-slash"></i
|
|
195
|
+
></a>
|
|
196
|
+
<a
|
|
197
|
+
class="margin-right:10px"
|
|
198
|
+
id="code"
|
|
199
|
+
show="#code-slash"
|
|
200
|
+
hide="#code, #demo-code"
|
|
201
|
+
><i class="fa fa-code"></i
|
|
202
|
+
></a>
|
|
203
|
+
<a
|
|
204
|
+
class="margin-right:10px"
|
|
205
|
+
hidden
|
|
206
|
+
id="code-slash"
|
|
207
|
+
show="#code, #demo-code"
|
|
208
|
+
hide="#code-slash"
|
|
209
|
+
><i class="fas fa-code"></i
|
|
210
|
+
></a>
|
|
211
|
+
<a
|
|
212
|
+
class="margin-right:5px"
|
|
213
|
+
fullscreen
|
|
214
|
+
target="#playground"
|
|
215
|
+
><i class="fas fa-expand"></i
|
|
216
|
+
></a>
|
|
217
|
+
</div>
|
|
218
|
+
</div>
|
|
219
|
+
<!-- End SandBox -->
|
|
220
|
+
</div>
|
|
221
|
+
</div>
|
|
222
|
+
</div>
|
|
223
|
+
</div>
|
|
224
|
+
|
|
225
|
+
<!--CoCreateJS-->
|
|
226
|
+
<script src="https://CoCreate.app/dist/CoCreate.js"></script>
|
|
227
|
+
</body>
|
|
228
|
+
</html>
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cocreate/sitemap",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A simple sitemap component in vanilla javascript. Easily configured using HTML5 data-attributes and/or JavaScript API.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"sitemap",
|
|
7
|
+
"cocreate",
|
|
8
|
+
"low-code-framework",
|
|
9
|
+
"no-code-framework",
|
|
10
|
+
"cocreatejs",
|
|
11
|
+
"cocreatejs-component",
|
|
12
|
+
"cocreate-framework",
|
|
13
|
+
"no-code",
|
|
14
|
+
"low-code",
|
|
15
|
+
"collaborative-framework",
|
|
16
|
+
"realtime",
|
|
17
|
+
"realtime-framework",
|
|
18
|
+
"collaboration",
|
|
19
|
+
"shared-editing",
|
|
20
|
+
"html5-framework",
|
|
21
|
+
"javascript-framework"
|
|
22
|
+
],
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"start": "npx webpack --config webpack.config.js",
|
|
28
|
+
"build": "npx webpack --mode=production --config webpack.config.js",
|
|
29
|
+
"dev": "npx webpack --config webpack.config.js --watch",
|
|
30
|
+
"postinstall": "node -e \"const { execSync } = require('child_process'); try { execSync('coc --version', { stdio: 'ignore' }); } catch (error) { try { execSync('npm install -g @cocreate/cli', { stdio: 'inherit' }); console.log('Installed \"@cocreate/cli\" globally.'); } catch (error) { console.error('Failed to install \"@cocreate/cli\" globally:', error); } }\""
|
|
31
|
+
},
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "git+https://github.com/CoCreate-app/CoCreate-sitemap.git"
|
|
35
|
+
},
|
|
36
|
+
"author": "CoCreate LLC",
|
|
37
|
+
"license": "AGPL-3.0",
|
|
38
|
+
"bugs": {
|
|
39
|
+
"url": "https://github.com/CoCreate-app/CoCreate-sitemap/issues"
|
|
40
|
+
},
|
|
41
|
+
"homepage": "https://cocreate.app/docs/sitemap",
|
|
42
|
+
"funding": {
|
|
43
|
+
"type": "GitHub Sponsors ❤",
|
|
44
|
+
"url": "https://github.com/sponsors/CoCreate-app"
|
|
45
|
+
},
|
|
46
|
+
"main": "./src/index.js"
|
|
47
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
dryRun: false,
|
|
3
|
+
branches: ["master"],
|
|
4
|
+
plugins: [
|
|
5
|
+
"@semantic-release/commit-analyzer",
|
|
6
|
+
"@semantic-release/release-notes-generator",
|
|
7
|
+
[
|
|
8
|
+
"@semantic-release/changelog",
|
|
9
|
+
{
|
|
10
|
+
changelogFile: "CHANGELOG.md",
|
|
11
|
+
},
|
|
12
|
+
],
|
|
13
|
+
"@semantic-release/npm",
|
|
14
|
+
"@semantic-release/github",
|
|
15
|
+
[
|
|
16
|
+
"@semantic-release/git",
|
|
17
|
+
{
|
|
18
|
+
assets: ["CHANGELOG.md", "package.json"],
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
],
|
|
22
|
+
};
|
package/src/index.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (C) 2023 CoCreate and Contributors.
|
|
3
|
+
*
|
|
4
|
+
* This program is free software: you can redistribute it and/or modify
|
|
5
|
+
* it under the terms of the GNU Affero General Public License as published
|
|
6
|
+
* by the Free Software Foundation, either version 3 of the License, or
|
|
7
|
+
* (at your option) any later version.
|
|
8
|
+
*
|
|
9
|
+
* This program is distributed in the hope that it will be useful,
|
|
10
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
* GNU Affero General Public License for more details.
|
|
13
|
+
*
|
|
14
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
+
********************************************************************************/
|
|
17
|
+
|
|
18
|
+
// Commercial Licensing Information:
|
|
19
|
+
// For commercial use of this software without the copyleft provisions of the AGPLv3,
|
|
20
|
+
// you must obtain a commercial license from CoCreate LLC.
|
|
21
|
+
// For details, visit <https://cocreate.app/licenses/> or contact us at sales@cocreate.app.
|
|
22
|
+
|
|
23
|
+
const fs = require('fs');
|
|
24
|
+
|
|
25
|
+
class CoCreateSitemap {
|
|
26
|
+
constructor(render) {
|
|
27
|
+
this.render = render;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async updateUrlInSitemap(urlToFind) {
|
|
31
|
+
try {
|
|
32
|
+
// Path to your sitemap file
|
|
33
|
+
const sitemapPath = '/path/to/your/sitemap.xml';
|
|
34
|
+
|
|
35
|
+
// Read and parse the sitemap XML
|
|
36
|
+
let sitemapXml = fs.readFileSync(sitemapPath, 'utf8');
|
|
37
|
+
|
|
38
|
+
// Regex pattern to find the entire <url>...</url> block containing the URL
|
|
39
|
+
const regexPattern = `<url>\\s*<loc>${urlToFind}</loc>[\\s\\S]*?</url>`;
|
|
40
|
+
|
|
41
|
+
// Perform regex search
|
|
42
|
+
const match = sitemapXml.match(regexPattern);
|
|
43
|
+
|
|
44
|
+
if (match) {
|
|
45
|
+
const position = match.index; // Start position of the <url> block
|
|
46
|
+
const endPosition = match.index + match[0].length; // End position of the <url> block
|
|
47
|
+
console.log(`URL ${urlToFind} found in sitemap at position ${position}-${endPosition}.`);
|
|
48
|
+
|
|
49
|
+
// Replace the matched <url> block with a modified version (example)
|
|
50
|
+
const modifiedUrlBlock = `<url>
|
|
51
|
+
<loc>${urlToFind}</loc>
|
|
52
|
+
<lastmod>${new Date().toISOString()}</lastmod>
|
|
53
|
+
<priority>1.0</priority>
|
|
54
|
+
</url>`;
|
|
55
|
+
|
|
56
|
+
// Replace the original <url> block with the modified one
|
|
57
|
+
sitemapXml = sitemapXml.slice(0, position) + modifiedUrlBlock + sitemapXml.slice(endPosition);
|
|
58
|
+
|
|
59
|
+
// Write back the modified sitemap XML to the file (optional)
|
|
60
|
+
fs.writeFileSync(sitemapPath, sitemapXml);
|
|
61
|
+
|
|
62
|
+
console.log('Sitemap updated successfully.');
|
|
63
|
+
} else {
|
|
64
|
+
console.log(`URL ${urlToFind} not found in sitemap.`);
|
|
65
|
+
}
|
|
66
|
+
} catch (err) {
|
|
67
|
+
console.error('Error updating sitemap:', err);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
module.exports = CoCreateSitemap;
|