@hkdigital/lib-core 0.5.94 → 0.5.96
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 +30 -16
- package/dist/assets/meta/favicon.png +0 -0
- package/dist/assets/meta/preview-landscape.png +0 -0
- package/dist/assets/meta/preview-square.png +0 -0
- package/dist/config/meta.d.ts +56 -0
- package/dist/config/meta.js +121 -0
- package/dist/meta/templates/README.md +150 -0
- package/dist/meta/templates/lib/assets/meta/favicon.png +0 -0
- package/dist/meta/templates/lib/assets/meta/preview-landscape.png +0 -0
- package/dist/meta/templates/lib/assets/meta/preview-square.png +0 -0
- package/dist/meta/templates/lib/config/meta.d.ts +63 -0
- package/dist/meta/templates/lib/config/meta.js +112 -0
- package/dist/meta/templates/lib/meta.d.ts +8 -0
- package/dist/meta/templates/lib/meta.js +23 -0
- package/dist/meta/templates/routes/(meta)/manifest.json/+server.d.ts +2 -0
- package/dist/meta/templates/routes/(meta)/manifest.json/+server.js +42 -0
- package/dist/meta/templates/routes/(meta)/robots.txt/+server.d.ts +2 -0
- package/dist/meta/templates/routes/(meta)/robots.txt/+server.js +9 -0
- package/dist/meta/templates/routes/(meta)/sitemap.xml/+server.d.ts +2 -0
- package/dist/meta/templates/routes/(meta)/sitemap.xml/+server.js +14 -0
- package/dist/meta/utils/sitemap/typedef.d.ts +1 -1
- package/dist/meta.d.ts +8 -0
- package/dist/meta.js +23 -0
- package/dist/ui/primitives/buttons/button/Button.svelte.d.ts +1 -1
- package/dist/ui/primitives/inputs/text-input/TextInput.svelte.d.ts +1 -1
- package/package.json +3 -3
- package/scripts/validate-imports.mjs +51 -0
package/README.md
CHANGED
|
@@ -204,19 +204,26 @@ This library includes a complete design system with Tailwind CSS integration. Ba
|
|
|
204
204
|
import heroResponsive from '$lib/assets/hero.jpg?preset=photo&responsive';
|
|
205
205
|
```
|
|
206
206
|
|
|
207
|
-
6. **
|
|
207
|
+
6. **Meta setup** - Configure SEO, PWA, and favicons:
|
|
208
208
|
|
|
209
|
-
The library includes
|
|
210
|
-
favicon generation, manifest.json, sitemap.xml, and robots.txt
|
|
209
|
+
The library includes templates for PWA configuration, SEO metadata,
|
|
210
|
+
favicon generation, manifest.json, sitemap.xml, and robots.txt.
|
|
211
211
|
|
|
212
|
-
**Copy
|
|
212
|
+
**Copy template files to your project:**
|
|
213
213
|
```bash
|
|
214
|
-
|
|
214
|
+
# Copy configuration and assets to src/lib/
|
|
215
|
+
cp -r node_modules/@hkdigital/lib-core/meta/templates/lib/* src/lib/
|
|
216
|
+
|
|
217
|
+
# Copy route endpoints to src/routes/
|
|
218
|
+
cp -r node_modules/@hkdigital/lib-core/meta/templates/routes/* src/routes/
|
|
215
219
|
```
|
|
216
220
|
|
|
217
221
|
**Customize for your app:**
|
|
218
|
-
- Replace `src/
|
|
219
|
-
|
|
222
|
+
- Replace images in `src/lib/assets/meta/` with your own:
|
|
223
|
+
- `favicon.png` (512×512px)
|
|
224
|
+
- `preview-landscape.png` (1200×630px for social media)
|
|
225
|
+
- `preview-square.png` (1200×1200px for social media)
|
|
226
|
+
- Edit `src/lib/config/meta.js`:
|
|
220
227
|
```javascript
|
|
221
228
|
export const name = 'Your App Name';
|
|
222
229
|
export const shortName = 'App';
|
|
@@ -226,11 +233,12 @@ This library includes a complete design system with Tailwind CSS integration. Ba
|
|
|
226
233
|
// Add your site routes for sitemap
|
|
227
234
|
export const siteRoutes = ['/', '/about', '/contact'];
|
|
228
235
|
|
|
229
|
-
// Configure robots.txt
|
|
236
|
+
// Configure robots.txt
|
|
230
237
|
export const robotsConfig = {
|
|
231
|
-
allowedHosts:
|
|
232
|
-
disallowedPaths: [
|
|
233
|
-
|
|
238
|
+
allowedHosts: '*', // '*' allows all hosts
|
|
239
|
+
disallowedPaths: [],
|
|
240
|
+
allowAiTraining: true,
|
|
241
|
+
allowAiReading: true
|
|
234
242
|
};
|
|
235
243
|
```
|
|
236
244
|
|
|
@@ -238,11 +246,14 @@ This library includes a complete design system with Tailwind CSS integration. Ba
|
|
|
238
246
|
```svelte
|
|
239
247
|
<!-- src/routes/+layout.svelte -->
|
|
240
248
|
<script>
|
|
241
|
-
import { Favicons, PWA } from '
|
|
249
|
+
import { Favicons, PWA, SEO, config } from '$lib/meta.js';
|
|
250
|
+
|
|
251
|
+
let { children, data } = $props();
|
|
242
252
|
</script>
|
|
243
253
|
|
|
244
|
-
<Favicons />
|
|
245
|
-
<PWA />
|
|
254
|
+
<Favicons {config} />
|
|
255
|
+
<PWA {config} />
|
|
256
|
+
<SEO {config} locale={data?.locale} />
|
|
246
257
|
|
|
247
258
|
{@render children()}
|
|
248
259
|
```
|
|
@@ -250,11 +261,14 @@ This library includes a complete design system with Tailwind CSS integration. Ba
|
|
|
250
261
|
**What you get:**
|
|
251
262
|
- Automatic favicon generation (16, 32, 192, 512px)
|
|
252
263
|
- Apple touch icons (120, 152, 167, 180px)
|
|
264
|
+
- SEO meta tags and Open Graph support
|
|
265
|
+
- Social media preview images
|
|
266
|
+
- Multi-language support with auto-detection
|
|
253
267
|
- Dynamic `/manifest.json` endpoint
|
|
254
268
|
- Dynamic `/sitemap.xml` endpoint
|
|
255
|
-
- Dynamic `/robots.txt` with
|
|
269
|
+
- Dynamic `/robots.txt` with AI bot control
|
|
256
270
|
|
|
257
|
-
See [
|
|
271
|
+
See the [meta template README](./src/lib/meta/templates/README.md) for
|
|
258
272
|
complete documentation.
|
|
259
273
|
|
|
260
274
|
### Logging System
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Meta data configuration
|
|
3
|
+
*/
|
|
4
|
+
export const name: "HKdigital Lib Core Test";
|
|
5
|
+
export const shortName: "HKlib Core";
|
|
6
|
+
export const description: "Base library that powers up Sveltekit projects";
|
|
7
|
+
/**
|
|
8
|
+
* Language and locale configuration
|
|
9
|
+
*
|
|
10
|
+
* Configure supported languages with their locale mappings.
|
|
11
|
+
* Short codes (e.g., 'en') are defaults, explicit variants optional.
|
|
12
|
+
*
|
|
13
|
+
* @type {Record<string, {lang: string, locale: string}>}
|
|
14
|
+
*/
|
|
15
|
+
export const languages: Record<string, {
|
|
16
|
+
lang: string;
|
|
17
|
+
locale: string;
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
* Default language code (fallback)
|
|
21
|
+
*
|
|
22
|
+
* @type {string}
|
|
23
|
+
*/
|
|
24
|
+
export const defaultLanguage: string;
|
|
25
|
+
/**
|
|
26
|
+
* Default locale (derived from defaultLanguage)
|
|
27
|
+
*
|
|
28
|
+
* @type {string}
|
|
29
|
+
*/
|
|
30
|
+
export const defaultLocale: string;
|
|
31
|
+
export const backgroundAndThemeColor: "#082962";
|
|
32
|
+
export const themeColor: "#082962";
|
|
33
|
+
export const backgroundColor: "#082962";
|
|
34
|
+
export const statusBarStyle: "black-translucent";
|
|
35
|
+
export const orientation: "any";
|
|
36
|
+
export const disablePageZoom: true;
|
|
37
|
+
export const SeoImageLandscape: string;
|
|
38
|
+
export const SeoImageSquare: string;
|
|
39
|
+
export const faviconImages: import("./typedef").ImageSource;
|
|
40
|
+
export const appleTouchIcons: import("./typedef").ImageSource;
|
|
41
|
+
/**
|
|
42
|
+
* Site routes for sitemap.xml
|
|
43
|
+
*
|
|
44
|
+
* @type {import('../meta/typedef.js').SitemapRoute[]}
|
|
45
|
+
*
|
|
46
|
+
* @see hkdigital/lib-core/meta/README.md for detailed configuration options
|
|
47
|
+
*/
|
|
48
|
+
export const siteRoutes: import("../meta/typedef.js").SitemapRoute[];
|
|
49
|
+
/**
|
|
50
|
+
* Robots.txt configuration
|
|
51
|
+
*
|
|
52
|
+
* @type {import('../meta/typedef.js').RobotsConfig}
|
|
53
|
+
*
|
|
54
|
+
* @see hkdigital/lib-core/meta/README.md for detailed configuration options
|
|
55
|
+
*/
|
|
56
|
+
export const robotsConfig: import("../meta/typedef.js").RobotsConfig;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Meta data configuration
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export const name = 'HKdigital Lib Core Test';
|
|
6
|
+
export const shortName = 'HKlib Core'; // max 12 characters
|
|
7
|
+
|
|
8
|
+
export const description = 'Base library that powers up Sveltekit projects';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Language and locale configuration
|
|
12
|
+
*
|
|
13
|
+
* Configure supported languages with their locale mappings.
|
|
14
|
+
* Short codes (e.g., 'en') are defaults, explicit variants optional.
|
|
15
|
+
*
|
|
16
|
+
* @type {Record<string, {lang: string, locale: string}>}
|
|
17
|
+
*/
|
|
18
|
+
export const languages = {
|
|
19
|
+
// Short codes (defaults)
|
|
20
|
+
'en': { lang: 'en-GB', locale: 'en_GB' },
|
|
21
|
+
'nl': { lang: 'nl-NL', locale: 'nl_NL' },
|
|
22
|
+
|
|
23
|
+
// Explicit variants (add as needed)
|
|
24
|
+
// 'en-us': { lang: 'en-US', locale: 'en_US' },
|
|
25
|
+
// 'es': { lang: 'es-ES', locale: 'es_ES' },
|
|
26
|
+
// 'es-mx': { lang: 'es-MX', locale: 'es_MX' }
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Default language code (fallback)
|
|
31
|
+
*
|
|
32
|
+
* @type {string}
|
|
33
|
+
*/
|
|
34
|
+
export const defaultLanguage = 'en';
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Default locale (derived from defaultLanguage)
|
|
38
|
+
*
|
|
39
|
+
* @type {string}
|
|
40
|
+
*/
|
|
41
|
+
export const defaultLocale = languages[defaultLanguage].locale;
|
|
42
|
+
|
|
43
|
+
export const backgroundAndThemeColor = '#082962';
|
|
44
|
+
|
|
45
|
+
export const themeColor = backgroundAndThemeColor;
|
|
46
|
+
export const backgroundColor = backgroundAndThemeColor;
|
|
47
|
+
|
|
48
|
+
export const statusBarStyle = 'black-translucent';
|
|
49
|
+
|
|
50
|
+
export const orientation = 'any'; // "landscape"
|
|
51
|
+
|
|
52
|
+
//
|
|
53
|
+
// Only disable zoom if:
|
|
54
|
+
// - You're building a game
|
|
55
|
+
// - Canvas-based app where zoom breaks functionality
|
|
56
|
+
// - You have a very specific (technical) reason...
|
|
57
|
+
//
|
|
58
|
+
export const disablePageZoom = true;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* SEO social media preview images
|
|
62
|
+
*
|
|
63
|
+
* To enable: Import the image and export it
|
|
64
|
+
* To disable: Comment out the import and export null instead
|
|
65
|
+
*
|
|
66
|
+
* Processed dimensions:
|
|
67
|
+
* - Landscape: 1200×630 (Facebook, LinkedIn, Discord)
|
|
68
|
+
* - Square: 1200×1200 (various platforms)
|
|
69
|
+
*/
|
|
70
|
+
|
|
71
|
+
// Import and export processed images
|
|
72
|
+
import SeoLandscapeImg from '../assets/meta/preview-landscape.png?seo-landscape';
|
|
73
|
+
import SeoSquareImg from '../assets/meta/preview-square.png?seo-square';
|
|
74
|
+
|
|
75
|
+
export const SeoImageLandscape = SeoLandscapeImg;
|
|
76
|
+
export const SeoImageSquare = SeoSquareImg;
|
|
77
|
+
|
|
78
|
+
// To disable, comment out imports above and uncomment below:
|
|
79
|
+
// export const SeoImageLandscape = null;
|
|
80
|
+
// export const SeoImageSquare = null;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Favicon images (processed by Vite imagetools)
|
|
84
|
+
*/
|
|
85
|
+
import FaviconImgs from '../assets/meta/favicon.png?favicons';
|
|
86
|
+
import AppleTouchImgs from '../assets/meta/favicon.png?apple-touch-icons';
|
|
87
|
+
|
|
88
|
+
export const faviconImages = FaviconImgs;
|
|
89
|
+
export const appleTouchIcons = AppleTouchImgs;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Site routes for sitemap.xml
|
|
93
|
+
*
|
|
94
|
+
* @type {import('../meta/typedef.js').SitemapRoute[]}
|
|
95
|
+
*
|
|
96
|
+
* @see hkdigital/lib-core/meta/README.md for detailed configuration options
|
|
97
|
+
*/
|
|
98
|
+
export const siteRoutes = [
|
|
99
|
+
'/'
|
|
100
|
+
// Add your routes:
|
|
101
|
+
// '/about',
|
|
102
|
+
// '/contact',
|
|
103
|
+
// { path: '/blog', priority: 0.9, changefreq: 'daily' }
|
|
104
|
+
];
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Robots.txt configuration
|
|
108
|
+
*
|
|
109
|
+
* @type {import('../meta/typedef.js').RobotsConfig}
|
|
110
|
+
*
|
|
111
|
+
* @see hkdigital/lib-core/meta/README.md for detailed configuration options
|
|
112
|
+
*/
|
|
113
|
+
export const robotsConfig = {
|
|
114
|
+
allowedHosts: '*', // '*' allows all hosts
|
|
115
|
+
disallowedPaths: [], // e.g., ['/admin', '/api']
|
|
116
|
+
|
|
117
|
+
// AI bot control (site-wide via robots.txt)
|
|
118
|
+
allowAiTraining: true, // GPTBot, Google-Extended, CCBot, anthropic-ai
|
|
119
|
+
allowAiReading: true // ChatGPT-User, Claude-Web, cohere-ai
|
|
120
|
+
};
|
|
121
|
+
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# Meta Configuration Template
|
|
2
|
+
|
|
3
|
+
This template provides a complete setup for SEO, PWA, and favicon configuration in your SvelteKit project.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
### 1. Copy template files to your project
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# From your project root
|
|
11
|
+
cp -r node_modules/@hkdigital/lib-core/meta/templates/lib/* src/lib/
|
|
12
|
+
cp -r node_modules/@hkdigital/lib-core/meta/templates/routes/* src/routes/
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
This copies:
|
|
16
|
+
- `src/lib/config/meta.js` - Your configuration file
|
|
17
|
+
- `src/lib/assets/meta/*.png` - Placeholder images
|
|
18
|
+
- `src/lib/meta.js` - Glue file connecting library and config
|
|
19
|
+
- `src/routes/(meta)/*.json/+server.js` - Route endpoints
|
|
20
|
+
|
|
21
|
+
### 2. Customize your configuration
|
|
22
|
+
|
|
23
|
+
Edit `src/lib/config/meta.js` with your app's information:
|
|
24
|
+
|
|
25
|
+
```javascript
|
|
26
|
+
export const name = 'Your App Name';
|
|
27
|
+
export const shortName = 'YourApp';
|
|
28
|
+
export const description = 'Your app description';
|
|
29
|
+
export const backgroundAndThemeColor = '#your-color';
|
|
30
|
+
// ... etc
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### 3. Replace placeholder images
|
|
34
|
+
|
|
35
|
+
Replace these files in `src/lib/assets/meta/` with your own:
|
|
36
|
+
- `favicon.png` - 512×512px or larger (PNG with transparency)
|
|
37
|
+
- `preview-landscape.png` - 1200×630px landscape preview (JPG or PNG)
|
|
38
|
+
- `preview-square.png` - 1200×1200px square preview (JPG or PNG)
|
|
39
|
+
|
|
40
|
+
### 4. Add to your root layout
|
|
41
|
+
|
|
42
|
+
In `src/routes/+layout.svelte`:
|
|
43
|
+
|
|
44
|
+
```svelte
|
|
45
|
+
<script>
|
|
46
|
+
import { Favicons, PWA, SEO, config } from '$lib/meta.js';
|
|
47
|
+
|
|
48
|
+
let { children, data } = $props();
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<Favicons {config} />
|
|
52
|
+
<PWA {config} />
|
|
53
|
+
<SEO {config} locale={data?.locale} />
|
|
54
|
+
|
|
55
|
+
{@render children()}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### 5. Update app.html
|
|
59
|
+
|
|
60
|
+
Add placeholders to `src/app.html`:
|
|
61
|
+
|
|
62
|
+
```html
|
|
63
|
+
<!doctype html>
|
|
64
|
+
<html lang="%lang%">
|
|
65
|
+
<head>
|
|
66
|
+
<meta charset="utf-8" />
|
|
67
|
+
<title>%title%</title>
|
|
68
|
+
<meta name="description" content="%description%">
|
|
69
|
+
%sveltekit.head%
|
|
70
|
+
</head>
|
|
71
|
+
<body>
|
|
72
|
+
%sveltekit.body%
|
|
73
|
+
</body>
|
|
74
|
+
</html>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### 6. Configure hooks (optional)
|
|
78
|
+
|
|
79
|
+
For language detection, add to `src/hooks.server.js`:
|
|
80
|
+
|
|
81
|
+
```javascript
|
|
82
|
+
import { handleLang } from '$lib/meta.js';
|
|
83
|
+
|
|
84
|
+
export async function handle({ event, resolve }) {
|
|
85
|
+
return handleLang(event, resolve);
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## File Structure
|
|
90
|
+
|
|
91
|
+
After copying the template, your project will have:
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
src/
|
|
95
|
+
lib/
|
|
96
|
+
config/
|
|
97
|
+
meta.js # Your configuration (customize this)
|
|
98
|
+
assets/
|
|
99
|
+
meta/
|
|
100
|
+
favicon.png # Your favicon image
|
|
101
|
+
preview-landscape.png
|
|
102
|
+
preview-square.png
|
|
103
|
+
meta.js # Glue file (imports library + config)
|
|
104
|
+
routes/
|
|
105
|
+
(meta)/ # Route group (not in URL)
|
|
106
|
+
manifest.json/
|
|
107
|
+
+server.js # PWA manifest endpoint
|
|
108
|
+
robots.txt/
|
|
109
|
+
+server.js # Robots.txt endpoint
|
|
110
|
+
sitemap.xml/
|
|
111
|
+
+server.js # Sitemap endpoint
|
|
112
|
+
+layout.svelte # Import from $lib/meta.js
|
|
113
|
+
hooks.server.js # Optional: language detection
|
|
114
|
+
app.html # Add %lang%, %title%, %description%
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## How It Works
|
|
118
|
+
|
|
119
|
+
**Library code** (automatically updated):
|
|
120
|
+
- Components imported from `@hkdigital/lib-core/meta/components`
|
|
121
|
+
- Utilities imported from `@hkdigital/lib-core/meta/utils`
|
|
122
|
+
- When you update the library, components get bug fixes automatically
|
|
123
|
+
|
|
124
|
+
**Your code** (you customize):
|
|
125
|
+
- `src/lib/config/meta.js` - Your app's configuration
|
|
126
|
+
- `src/lib/assets/meta/*.png` - Your images
|
|
127
|
+
- `src/lib/meta.js` - Connects library components with your config
|
|
128
|
+
- `src/routes/(meta)/` - Route endpoints that use your config
|
|
129
|
+
|
|
130
|
+
## Configuration Not in Routes
|
|
131
|
+
|
|
132
|
+
Note that `config/meta.js` is in `src/lib/`, NOT in `src/routes/`. This is intentional:
|
|
133
|
+
|
|
134
|
+
- Files in `src/routes/` can be served via HTTP
|
|
135
|
+
- Route groups like `(meta)` only affect layout grouping, not HTTP access
|
|
136
|
+
- Keeping config in `src/lib/` prevents accidental HTTP exposure
|
|
137
|
+
- Images in `src/lib/assets/` are processed by Vite imagetools at build time
|
|
138
|
+
|
|
139
|
+
## Updating
|
|
140
|
+
|
|
141
|
+
When you update `@hkdigital/lib-core`:
|
|
142
|
+
1. Library components are automatically updated
|
|
143
|
+
2. Your config and images remain untouched
|
|
144
|
+
3. Check changelog for breaking config changes
|
|
145
|
+
|
|
146
|
+
## Documentation
|
|
147
|
+
|
|
148
|
+
For complete documentation, see:
|
|
149
|
+
- Main docs: `node_modules/@hkdigital/lib-core/meta/README.md`
|
|
150
|
+
- Component API: Check library source in `node_modules/@hkdigital/lib-core/meta/`
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Meta configuration
|
|
3
|
+
*
|
|
4
|
+
* Customize this file with your app's information.
|
|
5
|
+
* After copying to your project, update all values below.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* App identity
|
|
9
|
+
*/
|
|
10
|
+
export const name: "Your App Name";
|
|
11
|
+
export const shortName: "YourApp";
|
|
12
|
+
export const description: "Your app description for search engines";
|
|
13
|
+
/**
|
|
14
|
+
* Language and locale configuration
|
|
15
|
+
*
|
|
16
|
+
* @type {Record<string, {lang: string, locale: string}>}
|
|
17
|
+
*/
|
|
18
|
+
export const languages: Record<string, {
|
|
19
|
+
lang: string;
|
|
20
|
+
locale: string;
|
|
21
|
+
}>;
|
|
22
|
+
export const defaultLanguage: "en";
|
|
23
|
+
export const defaultLocale: string;
|
|
24
|
+
/**
|
|
25
|
+
* PWA theme and colors
|
|
26
|
+
*/
|
|
27
|
+
export const backgroundAndThemeColor: "#082962";
|
|
28
|
+
export const themeColor: "#082962";
|
|
29
|
+
export const backgroundColor: "#082962";
|
|
30
|
+
/**
|
|
31
|
+
* iOS PWA configuration
|
|
32
|
+
*/
|
|
33
|
+
export const statusBarStyle: "black-translucent";
|
|
34
|
+
/**
|
|
35
|
+
* Screen orientation
|
|
36
|
+
*/
|
|
37
|
+
export const orientation: "any";
|
|
38
|
+
/**
|
|
39
|
+
* Disable pinch-to-zoom
|
|
40
|
+
*
|
|
41
|
+
* Only enable for games or canvas apps where zoom breaks functionality
|
|
42
|
+
*/
|
|
43
|
+
export const disablePageZoom: false;
|
|
44
|
+
export const SeoImageLandscape: string;
|
|
45
|
+
export const SeoImageSquare: string;
|
|
46
|
+
export const faviconImages: import("../../../../config/typedef").ImageSource;
|
|
47
|
+
export const appleTouchIcons: import("../../../../config/typedef").ImageSource;
|
|
48
|
+
/**
|
|
49
|
+
* Site routes for sitemap.xml
|
|
50
|
+
*
|
|
51
|
+
* @type {import('../../../typedef.js').SitemapRoute[]}
|
|
52
|
+
*
|
|
53
|
+
* @see @hkdigital/lib-core/meta/README.md for configuration options
|
|
54
|
+
*/
|
|
55
|
+
export const siteRoutes: import("../../../typedef.js").SitemapRoute[];
|
|
56
|
+
/**
|
|
57
|
+
* Robots.txt configuration
|
|
58
|
+
*
|
|
59
|
+
* @type {import('../../../typedef.js').RobotsConfig}
|
|
60
|
+
*
|
|
61
|
+
* @see @hkdigital/lib-core/meta/README.md for configuration options
|
|
62
|
+
*/
|
|
63
|
+
export const robotsConfig: import("../../../typedef.js").RobotsConfig;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Meta configuration
|
|
3
|
+
*
|
|
4
|
+
* Customize this file with your app's information.
|
|
5
|
+
* After copying to your project, update all values below.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* App identity
|
|
10
|
+
*/
|
|
11
|
+
export const name = 'Your App Name';
|
|
12
|
+
export const shortName = 'YourApp'; // max 12 characters
|
|
13
|
+
export const description = 'Your app description for search engines';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Language and locale configuration
|
|
17
|
+
*
|
|
18
|
+
* @type {Record<string, {lang: string, locale: string}>}
|
|
19
|
+
*/
|
|
20
|
+
export const languages = {
|
|
21
|
+
'en': { lang: 'en-GB', locale: 'en_GB' },
|
|
22
|
+
'nl': { lang: 'nl-NL', locale: 'nl_NL' }
|
|
23
|
+
|
|
24
|
+
// Add more languages as needed:
|
|
25
|
+
// 'es': { lang: 'es-ES', locale: 'es_ES' },
|
|
26
|
+
// 'en-us': { lang: 'en-US', locale: 'en_US' }
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const defaultLanguage = 'en';
|
|
30
|
+
export const defaultLocale = languages[defaultLanguage].locale;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* PWA theme and colors
|
|
34
|
+
*/
|
|
35
|
+
export const backgroundAndThemeColor = '#082962';
|
|
36
|
+
export const themeColor = backgroundAndThemeColor;
|
|
37
|
+
export const backgroundColor = backgroundAndThemeColor;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* iOS PWA configuration
|
|
41
|
+
*/
|
|
42
|
+
export const statusBarStyle = 'black-translucent'; // 'default' | 'black' | 'black-translucent'
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Screen orientation
|
|
46
|
+
*/
|
|
47
|
+
export const orientation = 'any'; // 'any' | 'landscape' | 'portrait'
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Disable pinch-to-zoom
|
|
51
|
+
*
|
|
52
|
+
* Only enable for games or canvas apps where zoom breaks functionality
|
|
53
|
+
*/
|
|
54
|
+
export const disablePageZoom = false;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* SEO social media preview images
|
|
58
|
+
*
|
|
59
|
+
* Replace the image files with your own designs.
|
|
60
|
+
* The images are processed by Vite imagetools to correct dimensions.
|
|
61
|
+
*
|
|
62
|
+
* To disable: comment out imports and set to null
|
|
63
|
+
*/
|
|
64
|
+
import SeoLandscapeImg from '../../../../assets/meta/preview-landscape.png?seo-landscape';
|
|
65
|
+
import SeoSquareImg from '../../../../assets/meta/preview-square.png?seo-square';
|
|
66
|
+
|
|
67
|
+
export const SeoImageLandscape = SeoLandscapeImg; // 1200×630
|
|
68
|
+
export const SeoImageSquare = SeoSquareImg; // 1200×1200
|
|
69
|
+
|
|
70
|
+
// To disable SEO images:
|
|
71
|
+
// export const SeoImageLandscape = null;
|
|
72
|
+
// export const SeoImageSquare = null;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Favicon images (processed by Vite imagetools)
|
|
76
|
+
*/
|
|
77
|
+
import FaviconImgs from '../../../../assets/meta/favicon.png?favicons';
|
|
78
|
+
import AppleTouchImgs from '../../../../assets/meta/favicon.png?apple-touch-icons';
|
|
79
|
+
|
|
80
|
+
export const faviconImages = FaviconImgs;
|
|
81
|
+
export const appleTouchIcons = AppleTouchImgs;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Site routes for sitemap.xml
|
|
85
|
+
*
|
|
86
|
+
* @type {import('../../../typedef.js').SitemapRoute[]}
|
|
87
|
+
*
|
|
88
|
+
* @see @hkdigital/lib-core/meta/README.md for configuration options
|
|
89
|
+
*/
|
|
90
|
+
export const siteRoutes = [
|
|
91
|
+
'/'
|
|
92
|
+
// Add your routes:
|
|
93
|
+
// '/about',
|
|
94
|
+
// '/contact',
|
|
95
|
+
// { path: '/blog', priority: 0.9, changefreq: 'daily' }
|
|
96
|
+
];
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Robots.txt configuration
|
|
100
|
+
*
|
|
101
|
+
* @type {import('../../../typedef.js').RobotsConfig}
|
|
102
|
+
*
|
|
103
|
+
* @see @hkdigital/lib-core/meta/README.md for configuration options
|
|
104
|
+
*/
|
|
105
|
+
export const robotsConfig = {
|
|
106
|
+
allowedHosts: '*', // '*' allows all hosts
|
|
107
|
+
disallowedPaths: [], // e.g., ['/admin', '/api']
|
|
108
|
+
|
|
109
|
+
// AI bot control (site-wide via robots.txt)
|
|
110
|
+
allowAiTraining: true, // GPTBot, Google-Extended, CCBot, anthropic-ai
|
|
111
|
+
allowAiReading: true // ChatGPT-User, Claude-Web, cohere-ai
|
|
112
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Favicons } from '../../components.js';
|
|
2
|
+
import { PWA } from '../../components.js';
|
|
3
|
+
import { SEO } from '../../components.js';
|
|
4
|
+
export const getLangFromPath: Function;
|
|
5
|
+
export const injectLang: Function;
|
|
6
|
+
export const handleLang: Function;
|
|
7
|
+
import * as config from '../../../config/meta.js';
|
|
8
|
+
export { Favicons, PWA, SEO, config };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Meta components configured for your app
|
|
3
|
+
*
|
|
4
|
+
* This file imports the library components and configures them with your
|
|
5
|
+
* app's config. Components are automatically updated when you update the
|
|
6
|
+
* @hkdigital/lib-core library.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { Favicons, PWA, SEO } from '../../components.js';
|
|
10
|
+
import { createLangUtils } from '../../utils.js';
|
|
11
|
+
import * as config from '../../../config/meta.js';
|
|
12
|
+
|
|
13
|
+
// Create configured language utilities
|
|
14
|
+
const { getLangFromPath, injectLang, handleLang } = createLangUtils(config);
|
|
15
|
+
|
|
16
|
+
// Re-export components (they'll receive config as a prop in your layout)
|
|
17
|
+
export { Favicons, PWA, SEO };
|
|
18
|
+
|
|
19
|
+
// Export language utilities
|
|
20
|
+
export { getLangFromPath, injectLang, handleLang };
|
|
21
|
+
|
|
22
|
+
// Export config for convenience
|
|
23
|
+
export { config };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// @see https://developer.mozilla.org/en-US/docs/
|
|
2
|
+
// Web/Progressive_web_apps/Manifest/Reference
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
name,
|
|
6
|
+
shortName,
|
|
7
|
+
description,
|
|
8
|
+
backgroundAndThemeColor,
|
|
9
|
+
orientation
|
|
10
|
+
} from '../../../../../config/meta.js';
|
|
11
|
+
|
|
12
|
+
import faviconImages from '../../../../../assets/meta/favicon.png?favicons';
|
|
13
|
+
|
|
14
|
+
/* Generate manifest data */
|
|
15
|
+
|
|
16
|
+
const manifest = {
|
|
17
|
+
name,
|
|
18
|
+
short_name: shortName,
|
|
19
|
+
description,
|
|
20
|
+
|
|
21
|
+
start_url: '/',
|
|
22
|
+
scope: '/',
|
|
23
|
+
|
|
24
|
+
icons: faviconImages.map((item) => {
|
|
25
|
+
return {
|
|
26
|
+
src: item.src,
|
|
27
|
+
sizes: `${item.width}x${item.width}`,
|
|
28
|
+
type: 'image/png'
|
|
29
|
+
};
|
|
30
|
+
}),
|
|
31
|
+
|
|
32
|
+
theme_color: backgroundAndThemeColor,
|
|
33
|
+
background_color: backgroundAndThemeColor,
|
|
34
|
+
|
|
35
|
+
display: 'fullscreen',
|
|
36
|
+
orientation
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/** @type {import('@sveltejs/kit').RequestHandler} */
|
|
40
|
+
export const GET = async () => {
|
|
41
|
+
return new Response(JSON.stringify(manifest));
|
|
42
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { text } from '@sveltejs/kit';
|
|
2
|
+
import { generateRobotsTxt } from '../../../../utils.js';
|
|
3
|
+
import { robotsConfig } from '../../../../../config/meta.js';
|
|
4
|
+
|
|
5
|
+
/** @type {import('@sveltejs/kit').RequestHandler} */
|
|
6
|
+
export const GET = async ({ url }) => {
|
|
7
|
+
const robotsTxt = generateRobotsTxt(url, robotsConfig);
|
|
8
|
+
return text(robotsTxt);
|
|
9
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { generateSitemap } from '../../../../utils.js';
|
|
2
|
+
import { siteRoutes } from '../../../../../config/meta.js';
|
|
3
|
+
|
|
4
|
+
/** @type {import('@sveltejs/kit').RequestHandler} */
|
|
5
|
+
export const GET = async ({ url }) => {
|
|
6
|
+
const sitemap = generateSitemap(url.origin, siteRoutes);
|
|
7
|
+
|
|
8
|
+
return new Response(sitemap, {
|
|
9
|
+
headers: {
|
|
10
|
+
'Content-Type': 'application/xml',
|
|
11
|
+
'Cache-Control': 'max-age=0, s-maxage=3600'
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
};
|
|
@@ -12,7 +12,7 @@ export type SitemapRouteObject = {
|
|
|
12
12
|
/**
|
|
13
13
|
* - Change frequency
|
|
14
14
|
*/
|
|
15
|
-
changefreq?: "
|
|
15
|
+
changefreq?: "always" | "hourly" | "daily" | "weekly" | "monthly" | "yearly" | "never" | undefined;
|
|
16
16
|
};
|
|
17
17
|
/**
|
|
18
18
|
* Route can be a simple string path or an object with details
|
package/dist/meta.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Favicons } from './meta/components.js';
|
|
2
|
+
import { PWA } from './meta/components.js';
|
|
3
|
+
import { SEO } from './meta/components.js';
|
|
4
|
+
export const getLangFromPath: Function;
|
|
5
|
+
export const injectLang: Function;
|
|
6
|
+
export const handleLang: Function;
|
|
7
|
+
import * as config from './config/meta.js';
|
|
8
|
+
export { Favicons, PWA, SEO, config };
|
package/dist/meta.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Meta components configured for your app
|
|
3
|
+
*
|
|
4
|
+
* This file imports the library components and configures them with your
|
|
5
|
+
* app's config. Components are automatically updated when you update the
|
|
6
|
+
* @hkdigital/lib-core library.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { Favicons, PWA, SEO } from './meta/components.js';
|
|
10
|
+
import { createLangUtils } from './meta/utils.js';
|
|
11
|
+
import * as config from './config/meta.js';
|
|
12
|
+
|
|
13
|
+
// Create configured language utilities
|
|
14
|
+
const { getLangFromPath, injectLang, handleLang } = createLangUtils(config);
|
|
15
|
+
|
|
16
|
+
// Re-export components (they'll receive config as a prop in your layout)
|
|
17
|
+
export { Favicons, PWA, SEO };
|
|
18
|
+
|
|
19
|
+
// Export language utilities
|
|
20
|
+
export { getLangFromPath, injectLang, handleLang };
|
|
21
|
+
|
|
22
|
+
// Export config for convenience
|
|
23
|
+
export { config };
|
|
@@ -12,7 +12,7 @@ type Button = {
|
|
|
12
12
|
size?: "sm" | "md" | "lg" | undefined;
|
|
13
13
|
variant?: string | undefined;
|
|
14
14
|
mode?: "light" | "dark" | undefined;
|
|
15
|
-
buttonType?: "
|
|
15
|
+
buttonType?: "button" | "reset" | "submit" | undefined;
|
|
16
16
|
active?: boolean | undefined;
|
|
17
17
|
selected?: boolean | undefined;
|
|
18
18
|
loading?: boolean | undefined;
|
|
@@ -12,7 +12,7 @@ type TextInput = {
|
|
|
12
12
|
iconClasses?: string | undefined;
|
|
13
13
|
initialValue?: string | undefined;
|
|
14
14
|
value?: string | undefined;
|
|
15
|
-
type?: "number" | "
|
|
15
|
+
type?: "number" | "url" | "email" | "text" | undefined;
|
|
16
16
|
pattern?: string | undefined;
|
|
17
17
|
required?: boolean | undefined;
|
|
18
18
|
title?: string | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hkdigital/lib-core",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.96",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "HKdigital",
|
|
6
6
|
"url": "https://hkdigital.nl"
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
"cache:clear": "rm -rf node_modules/.cache/imagetools",
|
|
42
42
|
"lint:prettier": "prettier --check .",
|
|
43
43
|
"lint:eslint": "eslint .",
|
|
44
|
-
"lint:imports": "node scripts/validate-imports.mjs",
|
|
44
|
+
"lint:imports": "node scripts/validate-imports.mjs --exclude src/lib/meta/templates",
|
|
45
45
|
"test:unit": "vitest",
|
|
46
46
|
"test:unit-run": "pnpm run test:unit -- --run",
|
|
47
47
|
"prepack:sync": "svelte-kit sync",
|
|
48
48
|
"prepack:build": "svelte-package",
|
|
49
49
|
"prepack:lint": "publint",
|
|
50
|
-
"prepack:imports": "node scripts/validate-imports.mjs",
|
|
50
|
+
"prepack:imports": "node scripts/validate-imports.mjs --exclude src/lib/meta/templates",
|
|
51
51
|
"publish:npm:version": "npm version patch",
|
|
52
52
|
"publish:npm:publish": "npm publish --access public",
|
|
53
53
|
"upgrade:hk:update": "ncu --dep dev,optional,peer,prod '@hkdigital/*' -u",
|
|
@@ -9,6 +9,27 @@ const SRC_DIR = join(PROJECT_ROOT, 'src');
|
|
|
9
9
|
const SCRIPT_DIR = dirname(fileURLToPath(import.meta.url));
|
|
10
10
|
const LIB_ROOT = dirname(SCRIPT_DIR);
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Parse command line arguments for exclusion patterns
|
|
14
|
+
*
|
|
15
|
+
* @returns {string[]} Array of path patterns to exclude
|
|
16
|
+
*/
|
|
17
|
+
function parseExclusionArgs() {
|
|
18
|
+
const args = process.argv.slice(2);
|
|
19
|
+
const exclusions = [];
|
|
20
|
+
|
|
21
|
+
for (let i = 0; i < args.length; i++) {
|
|
22
|
+
if (args[i] === '--exclude' && i + 1 < args.length) {
|
|
23
|
+
exclusions.push(args[i + 1]);
|
|
24
|
+
i++; // Skip next arg since we consumed it
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return exclusions;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const EXCLUSION_PATTERNS = parseExclusionArgs();
|
|
32
|
+
|
|
12
33
|
/**
|
|
13
34
|
* Scopes to validate for barrel exports
|
|
14
35
|
* Any package under these scopes will be checked
|
|
@@ -555,6 +576,25 @@ async function findAliasBarrelExport(importPath, targetName) {
|
|
|
555
576
|
return null;
|
|
556
577
|
}
|
|
557
578
|
|
|
579
|
+
/**
|
|
580
|
+
* Check if file path matches any exclusion pattern
|
|
581
|
+
*
|
|
582
|
+
* @param {string} filePath - Path to check
|
|
583
|
+
*
|
|
584
|
+
* @returns {boolean} True if file should be excluded
|
|
585
|
+
*/
|
|
586
|
+
function isExcluded(filePath) {
|
|
587
|
+
const relativePath = relative(PROJECT_ROOT, filePath);
|
|
588
|
+
|
|
589
|
+
for (const pattern of EXCLUSION_PATTERNS) {
|
|
590
|
+
if (relativePath.includes(pattern)) {
|
|
591
|
+
return true;
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
return false;
|
|
596
|
+
}
|
|
597
|
+
|
|
558
598
|
/**
|
|
559
599
|
* Validate import paths in a file
|
|
560
600
|
*
|
|
@@ -563,6 +603,11 @@ async function findAliasBarrelExport(importPath, targetName) {
|
|
|
563
603
|
* @returns {Promise<string[]>} Array of error messages
|
|
564
604
|
*/
|
|
565
605
|
async function validateFile(filePath) {
|
|
606
|
+
// Skip excluded files
|
|
607
|
+
if (isExcluded(filePath)) {
|
|
608
|
+
return [];
|
|
609
|
+
}
|
|
610
|
+
|
|
566
611
|
const content = await readFile(filePath, 'utf-8');
|
|
567
612
|
const errors = [];
|
|
568
613
|
const relativePath = relative(PROJECT_ROOT, filePath);
|
|
@@ -1234,6 +1279,12 @@ async function main() {
|
|
|
1234
1279
|
console.log(`Using script from @hkdigital/lib-core v${pkgJson.version}`);
|
|
1235
1280
|
console.log(`Validating import paths...`);
|
|
1236
1281
|
|
|
1282
|
+
if (EXCLUSION_PATTERNS.length > 0) {
|
|
1283
|
+
console.log('Excluding patterns:');
|
|
1284
|
+
EXCLUSION_PATTERNS.forEach(pattern => console.log(` ${pattern}`));
|
|
1285
|
+
console.log();
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1237
1288
|
// Load project aliases from svelte.config.js
|
|
1238
1289
|
PROJECT_ALIASES = await loadAliases();
|
|
1239
1290
|
|