@vilio/media-seo-module 0.0.2
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/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +57 -0
- package/dist/index.js.map +1 -0
- package/manifest.json +11 -0
- package/package.json +34 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAG9C,QAAA,MAAM,SAAS,EAAE,OAwDhB,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import manifest from "../manifest.json";
|
|
2
|
+
const seoModule = {
|
|
3
|
+
manifest,
|
|
4
|
+
hooks: [
|
|
5
|
+
// --- MEDIA HOOK ---
|
|
6
|
+
{
|
|
7
|
+
point: "media:upload:before_db",
|
|
8
|
+
handler: async (data) => {
|
|
9
|
+
console.log("[MediaSEO] Sanitizing filename:", data.filename);
|
|
10
|
+
const parts = data.filename.split(".");
|
|
11
|
+
const ext = parts.pop();
|
|
12
|
+
const base = parts.join(".");
|
|
13
|
+
const cleanBase = base
|
|
14
|
+
.toLowerCase()
|
|
15
|
+
.replace(/\s+/g, "-")
|
|
16
|
+
.replace(/[^a-z0-9-]/g, "");
|
|
17
|
+
data.filename = `file--${cleanBase}.${ext}`;
|
|
18
|
+
return data;
|
|
19
|
+
},
|
|
20
|
+
priority: 10,
|
|
21
|
+
},
|
|
22
|
+
// --- BLOG HOOKS ---
|
|
23
|
+
{
|
|
24
|
+
point: "blog:post:before_create",
|
|
25
|
+
handler: async (data) => {
|
|
26
|
+
if (!data.slug && data.title) {
|
|
27
|
+
console.log("[MediaSEO] Generating slug for post:", data.title);
|
|
28
|
+
data.slug = data.title
|
|
29
|
+
.toLowerCase()
|
|
30
|
+
.replace(/\s+/g, "-")
|
|
31
|
+
.replace(/[^\w-]+/g, "");
|
|
32
|
+
}
|
|
33
|
+
return data;
|
|
34
|
+
},
|
|
35
|
+
priority: 10,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
point: "blog:post:before_update",
|
|
39
|
+
handler: async (data) => {
|
|
40
|
+
// We could also enforce slug updates or other logic here
|
|
41
|
+
if (data.title && !data.slug) {
|
|
42
|
+
data.slug = data.title
|
|
43
|
+
.toLowerCase()
|
|
44
|
+
.replace(/\s+/g, "-")
|
|
45
|
+
.replace(/[^\w-]+/g, "");
|
|
46
|
+
}
|
|
47
|
+
return data;
|
|
48
|
+
},
|
|
49
|
+
priority: 10,
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
onEnable: async () => {
|
|
53
|
+
console.log("[MediaSEO] enabled with Blog Support");
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
export default seoModule;
|
|
57
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,kBAAkB,CAAC;AAExC,MAAM,SAAS,GAAY;IACzB,QAAQ;IAER,KAAK,EAAE;QACL,qBAAqB;QACrB;YACE,KAAK,EAAE,wBAAwB;YAC/B,OAAO,EAAE,KAAK,EAAE,IAAS,EAAE,EAAE;gBAC3B,OAAO,CAAC,GAAG,CAAC,iCAAiC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;gBAC9D,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBACvC,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC;gBACxB,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAC7B,MAAM,SAAS,GAAG,IAA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ACtD,CAAC;CACF,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
package/manifest.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "media-seo-module",
|
|
3
|
+
"name": "Media SEO Sanitizer",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"description": "Automatically sanitizes filenames before saving to DB",
|
|
6
|
+
"enabled": true,
|
|
7
|
+
"system": false,
|
|
8
|
+
"dependencies": [],
|
|
9
|
+
"extends": ["media-module", "blog-module"],
|
|
10
|
+
"isNpm": true
|
|
11
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vilio/media-seo-module",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "SEO Sanitizer for Media and Blog",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"exports": {
|
|
7
|
+
"./package.json": "./package.json",
|
|
8
|
+
".": "./dist/index.js",
|
|
9
|
+
"./client": "./dist/client.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"locales",
|
|
14
|
+
"manifest.json"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"release": "npm publish --access public --no-git-checks",
|
|
18
|
+
"clean": "rm -rf ./dist",
|
|
19
|
+
"dev": "tsc --watch",
|
|
20
|
+
"build": "tsc"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/react": "^19",
|
|
25
|
+
"react": "^19.0.0",
|
|
26
|
+
"typescript": "5.9.2"
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"@vilio/core": "^0.0.9",
|
|
30
|
+
"@vilio/intl": "^0.0.7",
|
|
31
|
+
"@vilio/modules": "^0.0.6",
|
|
32
|
+
"react": "^19.0.0"
|
|
33
|
+
}
|
|
34
|
+
}
|