core-maugli 1.0.2 → 1.0.4
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/astro.config.mjs +91 -0
- package/bin/init.js +33 -25
- package/package.json +5 -2
- package/tsconfig.json +8 -0
- package/vite.config.js +11 -0
package/astro.config.mjs
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
import mdx from '@astrojs/mdx';
|
2
|
+
import sitemap from '@astrojs/sitemap';
|
3
|
+
import tailwindcss from '@tailwindcss/vite';
|
4
|
+
import { defineConfig } from 'astro/config';
|
5
|
+
import { imagetools } from 'vite-imagetools';
|
6
|
+
import { VitePWA } from 'vite-plugin-pwa';
|
7
|
+
import siteConfig from './src/data/site-config';
|
8
|
+
import remarkSlug from 'remark-slug';
|
9
|
+
import customSlugify from './src/utils/remark-slugify';
|
10
|
+
|
11
|
+
export const pwaOptions = {
|
12
|
+
registerType: 'autoUpdate',
|
13
|
+
includeAssets: ['favicon.svg', 'favicon.ico', 'robots.txt', 'apple-touch-icon.png'],
|
14
|
+
manifest: {
|
15
|
+
name: "Maugli Blog",
|
16
|
+
short_name: "Maugli",
|
17
|
+
start_url: "/",
|
18
|
+
display: "standalone",
|
19
|
+
background_color: "#ffffff",
|
20
|
+
theme_color: "#0cbf11",
|
21
|
+
icons: [
|
22
|
+
{
|
23
|
+
src: "/icon-192.png",
|
24
|
+
sizes: "192x192",
|
25
|
+
type: "image/png",
|
26
|
+
purpose: "any maskable"
|
27
|
+
},
|
28
|
+
{
|
29
|
+
src: "/icon-512.png",
|
30
|
+
sizes: "512x512",
|
31
|
+
type: "image/png"
|
32
|
+
}
|
33
|
+
]
|
34
|
+
},
|
35
|
+
workbox: {
|
36
|
+
navigateFallback: '/index.html',
|
37
|
+
cleanupOutdatedCaches: true,
|
38
|
+
navigateFallbackDenylist: [/^\/api\//],
|
39
|
+
clientsClaim: true,
|
40
|
+
globPatterns: ['**/*.{js,css,html,png,jpg,jpeg,webp,svg}'],
|
41
|
+
runtimeCaching: [
|
42
|
+
{
|
43
|
+
urlPattern: ({ request }) => request.destination === 'image',
|
44
|
+
handler: 'CacheFirst',
|
45
|
+
options: {
|
46
|
+
cacheName: 'images-cache',
|
47
|
+
expiration: {
|
48
|
+
maxEntries: 50,
|
49
|
+
maxAgeSeconds: 30 * 24 * 60 * 60 // 30 дней
|
50
|
+
}
|
51
|
+
}
|
52
|
+
},
|
53
|
+
{
|
54
|
+
urlPattern: ({ request }) => request.destination === 'font',
|
55
|
+
handler: 'CacheFirst',
|
56
|
+
options: {
|
57
|
+
cacheName: 'fonts-cache',
|
58
|
+
expiration: {
|
59
|
+
maxEntries: 20,
|
60
|
+
maxAgeSeconds: 365 * 24 * 60 * 60 // 1 год
|
61
|
+
}
|
62
|
+
}
|
63
|
+
}
|
64
|
+
]
|
65
|
+
},
|
66
|
+
devOptions: {
|
67
|
+
enabled: true, // чтобы работал в деве
|
68
|
+
type: 'module',
|
69
|
+
}
|
70
|
+
};
|
71
|
+
|
72
|
+
// https://astro.build/config
|
73
|
+
export default defineConfig({
|
74
|
+
site: siteConfig.website,
|
75
|
+
integrations: [
|
76
|
+
mdx(),
|
77
|
+
sitemap()
|
78
|
+
],
|
79
|
+
vite: {
|
80
|
+
plugins: [
|
81
|
+
tailwindcss(),
|
82
|
+
imagetools(),
|
83
|
+
VitePWA(pwaOptions)
|
84
|
+
]
|
85
|
+
},
|
86
|
+
markdown: {
|
87
|
+
remarkPlugins: [
|
88
|
+
[remarkSlug, { slug: customSlugify }]
|
89
|
+
]
|
90
|
+
}
|
91
|
+
});
|
package/bin/init.js
CHANGED
@@ -8,31 +8,39 @@ import { execSync } from 'child_process';
|
|
8
8
|
const __filename = fileURLToPath(import.meta.url);
|
9
9
|
const __dirname = path.dirname(__filename);
|
10
10
|
const templateRoot = path.join(__dirname, '..');
|
11
|
-
const targetDir = process.argv[2] ? path.resolve(process.argv[2]) : process.cwd();
|
12
11
|
|
13
|
-
function
|
14
|
-
const
|
15
|
-
const dest = path.join(targetDir, item);
|
16
|
-
cpSync(src, dest, { recursive: true });
|
17
|
-
console.log(`Copied ${item}`);
|
18
|
-
}
|
12
|
+
export default function init(targetName) {
|
13
|
+
const targetDir = targetName ? path.resolve(targetName) : process.cwd();
|
19
14
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
15
|
+
function copyItem(item) {
|
16
|
+
const src = path.join(templateRoot, item);
|
17
|
+
const dest = path.join(targetDir, item);
|
18
|
+
cpSync(src, dest, { recursive: true });
|
19
|
+
console.log(`Copied ${item}`);
|
24
20
|
}
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
21
|
+
|
22
|
+
// Copy package files first so npm install works correctly
|
23
|
+
['package.json', 'package-lock.json'].forEach(file => {
|
24
|
+
if (existsSync(path.join(templateRoot, file))) {
|
25
|
+
copyItem(file);
|
26
|
+
}
|
27
|
+
});
|
28
|
+
|
29
|
+
const items = [
|
30
|
+
'astro.config.mjs',
|
31
|
+
'tsconfig.json',
|
32
|
+
'public',
|
33
|
+
'src',
|
34
|
+
'scripts',
|
35
|
+
'typograf-batch.js',
|
36
|
+
'resize-all.cjs'
|
37
|
+
];
|
38
|
+
items.forEach(copyItem);
|
39
|
+
|
40
|
+
execSync('npm install', { cwd: targetDir, stdio: 'inherit' });
|
41
|
+
}
|
42
|
+
|
43
|
+
// Если скрипт запускается напрямую
|
44
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
45
|
+
init(process.argv[2]);
|
46
|
+
}
|
package/package.json
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
"name": "core-maugli",
|
3
3
|
"description": "Astro & Tailwind CSS blog theme for Maugli.",
|
4
4
|
"type": "module",
|
5
|
-
"version": "1.0.
|
5
|
+
"version": "1.0.4",
|
6
6
|
"license": "GPL-3.0-or-later OR Commercial",
|
7
7
|
"repository": {
|
8
8
|
"type": "git",
|
@@ -64,7 +64,10 @@
|
|
64
64
|
"scripts",
|
65
65
|
"typograf-batch.js",
|
66
66
|
"resize-all.cjs",
|
67
|
-
"bin"
|
67
|
+
"bin",
|
68
|
+
"astro.config.mjs",
|
69
|
+
"tsconfig.json",
|
70
|
+
"vite.config.js"
|
68
71
|
],
|
69
72
|
"main": "bin/index.js",
|
70
73
|
"bin": {
|
package/tsconfig.json
ADDED
package/vite.config.js
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
import { defineConfig } from 'vite';
|
2
|
+
import { imagetools } from 'vite-imagetools';
|
3
|
+
import { VitePWA } from 'vite-plugin-pwa';
|
4
|
+
import { pwaOptions } from './astro.config.mjs';
|
5
|
+
|
6
|
+
export default defineConfig({
|
7
|
+
plugins: [
|
8
|
+
imagetools(),
|
9
|
+
VitePWA(pwaOptions)
|
10
|
+
]
|
11
|
+
});
|