astro-accelerator 7.1.11 → 7.1.12
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/package.json +5 -4
- package/public/css/main.7.1.11.css +1101 -0
- package/public/css/main.7.1.12.css +1101 -0
- package/public/css/vars.7.1.11.css +118 -0
- package/public/css/vars.7.1.12.css +118 -0
- package/src/themes/accelerator/components/HtmlHead.astro +4 -3
- package/src/themes/accelerator/utilities/css-version.mjs +165 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
:root,
|
|
2
|
+
body.mode-light {
|
|
3
|
+
--fore: #233;
|
|
4
|
+
--aft: #DFF;
|
|
5
|
+
--aft-image: #DFF;
|
|
6
|
+
|
|
7
|
+
--fore-link: #355;
|
|
8
|
+
--fore-link-alt: #699;
|
|
9
|
+
--aft-link-alt: #e6e6eC;
|
|
10
|
+
|
|
11
|
+
--fore-input: var(--fore);
|
|
12
|
+
--aft-input: var(--aft);
|
|
13
|
+
|
|
14
|
+
--fore-block: #333;
|
|
15
|
+
--aft-block: #BEE;
|
|
16
|
+
--icon-block: #FF0;
|
|
17
|
+
--icon-block-alpha: rgba(from var(--icon-block) r g b / 0.4);
|
|
18
|
+
|
|
19
|
+
--fore-table-head: #DFF;
|
|
20
|
+
--aft-table-head: #233;
|
|
21
|
+
--fore-table-row-odd: #333;
|
|
22
|
+
--aft-table-row-odd: #DFF;
|
|
23
|
+
--fore-table-row-even: #333;
|
|
24
|
+
--aft-table-row-even: #CFF;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
body.mode-dark {
|
|
28
|
+
--fore: #DFF;
|
|
29
|
+
--aft: #233;
|
|
30
|
+
--aft-image: #DDD;
|
|
31
|
+
|
|
32
|
+
--fore-link: #AFF;
|
|
33
|
+
--fore-link-alt: #FF0;
|
|
34
|
+
--aft-link-alt: #232323;
|
|
35
|
+
|
|
36
|
+
--fore-input: var(--fore);
|
|
37
|
+
--aft-input: var(--aft);
|
|
38
|
+
|
|
39
|
+
--fore-block: #DFF;
|
|
40
|
+
--aft-block: #011;
|
|
41
|
+
--icon-block: #FF0;
|
|
42
|
+
--icon-block-alpha: rgba(from var(--icon-block) r g b / 0.4);
|
|
43
|
+
|
|
44
|
+
--fore-table-head: #DFF;
|
|
45
|
+
--aft-table-head: #244;
|
|
46
|
+
--fore-table-row-odd: #DFF;
|
|
47
|
+
--aft-table-row-odd: #355;
|
|
48
|
+
--fore-table-row-even: #DFF;
|
|
49
|
+
--aft-table-row-even: #466;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
@font-face {
|
|
54
|
+
font-family: "hyper-reg";
|
|
55
|
+
font-weight: normal;
|
|
56
|
+
font-style: normal;
|
|
57
|
+
src: url("AtkinsonHyperlegibleNext-Regular.otf");
|
|
58
|
+
font-display: block;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@font-face {
|
|
62
|
+
font-family: "hyper-bold";
|
|
63
|
+
font-weight: bold;
|
|
64
|
+
font-style: normal;
|
|
65
|
+
src: url("AtkinsonHyperlegibleNext-Bold.otf");
|
|
66
|
+
font-display: block;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@font-face {
|
|
70
|
+
font-family: "hyper-mono";
|
|
71
|
+
font-weight: bold;
|
|
72
|
+
font-style: normal;
|
|
73
|
+
src: url("AtkinsonHyperlegibleMono-Regular.otf");
|
|
74
|
+
font-display: block;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
:root {
|
|
78
|
+
--heading-font: 'hyper-bold', sans-serif;
|
|
79
|
+
--content-font: 'hyper-reg', Verdana, Geneva, sans-serif;
|
|
80
|
+
--code-font: 'hyper-mono', Consolas, 'Courier New', Courier, monospace;
|
|
81
|
+
--unicode-font: font-family: "Segoe UI Symbol", "Arial Unicode MS", "DejaVu Sans", "Meiryo UI", "MS UI Gothic", "Everson Mono Unicode", Meiryo, "MS Gothic", "MS Mincho", "MS PGothic", "MS PMincho", "Meslo LG L", "Meslo LG L DZ", "Meslo M L", "Meslo M L DZ", "Meslo S L", "Meslo S L DZ", "Symbola", "DejaVu Sans Condensed", "DejaVu Sans Mono", Code2000, "Everson Mono", Quivira, sans-serif;
|
|
82
|
+
|
|
83
|
+
--font-size-meta: 0.9rem;
|
|
84
|
+
--font-size-h1: 3rem;
|
|
85
|
+
--font-size-h2: 2.3rem;
|
|
86
|
+
--font-size-h3: 2rem;
|
|
87
|
+
--font-size-h4: 1.7rem;
|
|
88
|
+
--font-size-h5: 1.7rem;
|
|
89
|
+
--font-size-h6: 1.7rem;
|
|
90
|
+
|
|
91
|
+
--paragraph-margin: 1.2rem;
|
|
92
|
+
--block-gap: 2rem;
|
|
93
|
+
--block-gap-l: 3rem;
|
|
94
|
+
--block-radius: 0.3rem;
|
|
95
|
+
--block-radius-round: 20px;
|
|
96
|
+
|
|
97
|
+
--marker-size: 1.2rem;
|
|
98
|
+
|
|
99
|
+
--box-shadow: 0 12px 24px -12px rgb(0 0 0 / 50%);
|
|
100
|
+
--box-shadow-slight: 0 6px 12px -6px rgb(0 0 0 / 40%);
|
|
101
|
+
--box-glow: 0 0 12px 0 var(--icon-block-alpha);
|
|
102
|
+
|
|
103
|
+
--box-shadow-unselected: rgb(0 0 0 / 6%) 0px 2px 4px, rgb(0 0 0 / 5%) 0px 0.5px 1px;
|
|
104
|
+
--transform-selected: translate3d(0px, -1px, 0px);
|
|
105
|
+
|
|
106
|
+
--content-width: 50rem;
|
|
107
|
+
--navigation-width: 300px;
|
|
108
|
+
--grid-gap: 1rem;
|
|
109
|
+
--grid-gap-s: 0.4rem;
|
|
110
|
+
|
|
111
|
+
/* Calculate the mobile width by removing l/r columns */
|
|
112
|
+
--content-width-mobile: calc(100vw - 1rem);
|
|
113
|
+
|
|
114
|
+
/* Search variables */
|
|
115
|
+
--search-height: 2rem;
|
|
116
|
+
--search-dropdown-height: 65vh;
|
|
117
|
+
--search-dropdown-duration: 0.2s;
|
|
118
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
:root,
|
|
2
|
+
body.mode-light {
|
|
3
|
+
--fore: #233;
|
|
4
|
+
--aft: #DFF;
|
|
5
|
+
--aft-image: #DFF;
|
|
6
|
+
|
|
7
|
+
--fore-link: #355;
|
|
8
|
+
--fore-link-alt: #699;
|
|
9
|
+
--aft-link-alt: #e6e6eC;
|
|
10
|
+
|
|
11
|
+
--fore-input: var(--fore);
|
|
12
|
+
--aft-input: var(--aft);
|
|
13
|
+
|
|
14
|
+
--fore-block: #333;
|
|
15
|
+
--aft-block: #BEE;
|
|
16
|
+
--icon-block: #FF0;
|
|
17
|
+
--icon-block-alpha: rgba(from var(--icon-block) r g b / 0.4);
|
|
18
|
+
|
|
19
|
+
--fore-table-head: #DFF;
|
|
20
|
+
--aft-table-head: #233;
|
|
21
|
+
--fore-table-row-odd: #333;
|
|
22
|
+
--aft-table-row-odd: #DFF;
|
|
23
|
+
--fore-table-row-even: #333;
|
|
24
|
+
--aft-table-row-even: #CFF;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
body.mode-dark {
|
|
28
|
+
--fore: #DFF;
|
|
29
|
+
--aft: #233;
|
|
30
|
+
--aft-image: #DDD;
|
|
31
|
+
|
|
32
|
+
--fore-link: #AFF;
|
|
33
|
+
--fore-link-alt: #FF0;
|
|
34
|
+
--aft-link-alt: #232323;
|
|
35
|
+
|
|
36
|
+
--fore-input: var(--fore);
|
|
37
|
+
--aft-input: var(--aft);
|
|
38
|
+
|
|
39
|
+
--fore-block: #DFF;
|
|
40
|
+
--aft-block: #011;
|
|
41
|
+
--icon-block: #FF0;
|
|
42
|
+
--icon-block-alpha: rgba(from var(--icon-block) r g b / 0.4);
|
|
43
|
+
|
|
44
|
+
--fore-table-head: #DFF;
|
|
45
|
+
--aft-table-head: #244;
|
|
46
|
+
--fore-table-row-odd: #DFF;
|
|
47
|
+
--aft-table-row-odd: #355;
|
|
48
|
+
--fore-table-row-even: #DFF;
|
|
49
|
+
--aft-table-row-even: #466;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
@font-face {
|
|
54
|
+
font-family: "hyper-reg";
|
|
55
|
+
font-weight: normal;
|
|
56
|
+
font-style: normal;
|
|
57
|
+
src: url("AtkinsonHyperlegibleNext-Regular.otf");
|
|
58
|
+
font-display: block;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@font-face {
|
|
62
|
+
font-family: "hyper-bold";
|
|
63
|
+
font-weight: bold;
|
|
64
|
+
font-style: normal;
|
|
65
|
+
src: url("AtkinsonHyperlegibleNext-Bold.otf");
|
|
66
|
+
font-display: block;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@font-face {
|
|
70
|
+
font-family: "hyper-mono";
|
|
71
|
+
font-weight: bold;
|
|
72
|
+
font-style: normal;
|
|
73
|
+
src: url("AtkinsonHyperlegibleMono-Regular.otf");
|
|
74
|
+
font-display: block;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
:root {
|
|
78
|
+
--heading-font: 'hyper-bold', sans-serif;
|
|
79
|
+
--content-font: 'hyper-reg', Verdana, Geneva, sans-serif;
|
|
80
|
+
--code-font: 'hyper-mono', Consolas, 'Courier New', Courier, monospace;
|
|
81
|
+
--unicode-font: font-family: "Segoe UI Symbol", "Arial Unicode MS", "DejaVu Sans", "Meiryo UI", "MS UI Gothic", "Everson Mono Unicode", Meiryo, "MS Gothic", "MS Mincho", "MS PGothic", "MS PMincho", "Meslo LG L", "Meslo LG L DZ", "Meslo M L", "Meslo M L DZ", "Meslo S L", "Meslo S L DZ", "Symbola", "DejaVu Sans Condensed", "DejaVu Sans Mono", Code2000, "Everson Mono", Quivira, sans-serif;
|
|
82
|
+
|
|
83
|
+
--font-size-meta: 0.9rem;
|
|
84
|
+
--font-size-h1: 3rem;
|
|
85
|
+
--font-size-h2: 2.3rem;
|
|
86
|
+
--font-size-h3: 2rem;
|
|
87
|
+
--font-size-h4: 1.7rem;
|
|
88
|
+
--font-size-h5: 1.7rem;
|
|
89
|
+
--font-size-h6: 1.7rem;
|
|
90
|
+
|
|
91
|
+
--paragraph-margin: 1.2rem;
|
|
92
|
+
--block-gap: 2rem;
|
|
93
|
+
--block-gap-l: 3rem;
|
|
94
|
+
--block-radius: 0.3rem;
|
|
95
|
+
--block-radius-round: 20px;
|
|
96
|
+
|
|
97
|
+
--marker-size: 1.2rem;
|
|
98
|
+
|
|
99
|
+
--box-shadow: 0 12px 24px -12px rgb(0 0 0 / 50%);
|
|
100
|
+
--box-shadow-slight: 0 6px 12px -6px rgb(0 0 0 / 40%);
|
|
101
|
+
--box-glow: 0 0 12px 0 var(--icon-block-alpha);
|
|
102
|
+
|
|
103
|
+
--box-shadow-unselected: rgb(0 0 0 / 6%) 0px 2px 4px, rgb(0 0 0 / 5%) 0px 0.5px 1px;
|
|
104
|
+
--transform-selected: translate3d(0px, -1px, 0px);
|
|
105
|
+
|
|
106
|
+
--content-width: 50rem;
|
|
107
|
+
--navigation-width: 300px;
|
|
108
|
+
--grid-gap: 1rem;
|
|
109
|
+
--grid-gap-s: 0.4rem;
|
|
110
|
+
|
|
111
|
+
/* Calculate the mobile width by removing l/r columns */
|
|
112
|
+
--content-width-mobile: calc(100vw - 1rem);
|
|
113
|
+
|
|
114
|
+
/* Search variables */
|
|
115
|
+
--search-height: 2rem;
|
|
116
|
+
--search-dropdown-height: 65vh;
|
|
117
|
+
--search-dropdown-duration: 0.2s;
|
|
118
|
+
}
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
import { Accelerator } from "astro-accelerator-utils";
|
|
5
5
|
import type { Frontmatter } from "astro-accelerator-utils/types/Frontmatter";
|
|
6
6
|
import { SITE, OPEN_GRAPH, HEADER_SCRIPTS } from "@config";
|
|
7
|
-
import pkg from "package.json" with { type: "json" };
|
|
8
7
|
|
|
9
8
|
const accelerator = new Accelerator(SITE);
|
|
10
9
|
const stats = new accelerator.statistics(
|
|
@@ -55,11 +54,13 @@ stats.stop();
|
|
|
55
54
|
<meta name="description" content={frontmatter.description} />
|
|
56
55
|
<link
|
|
57
56
|
rel="stylesheet"
|
|
58
|
-
href={SITE.subfolder + `/css/vars.
|
|
57
|
+
href={SITE.subfolder + `/css/vars.7.1.12.css`}
|
|
58
|
+
data-versioned
|
|
59
59
|
/>
|
|
60
60
|
<link
|
|
61
61
|
rel="stylesheet"
|
|
62
|
-
href={SITE.subfolder + `/css/main.
|
|
62
|
+
href={SITE.subfolder + `/css/main.7.1.12.css`}
|
|
63
|
+
data-versioned
|
|
63
64
|
/>
|
|
64
65
|
{
|
|
65
66
|
autoMeta("viewport") && (
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This javascript file comes from Astro Accelerator
|
|
3
|
+
* Edits will be overwritten if you change the file locally
|
|
4
|
+
*
|
|
5
|
+
* Copies versioned CSS files and rewrites data-versioned links in HtmlHead.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import fs from 'fs';
|
|
11
|
+
import path from 'path';
|
|
12
|
+
|
|
13
|
+
const workingDirectory = process.cwd();
|
|
14
|
+
const defaultHtmlHead = path.join(
|
|
15
|
+
'src',
|
|
16
|
+
'themes',
|
|
17
|
+
'accelerator',
|
|
18
|
+
'components',
|
|
19
|
+
'HtmlHead.astro'
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
const htmlHeadArg = process.argv[2];
|
|
23
|
+
const htmlHeadPath = path.resolve(
|
|
24
|
+
workingDirectory,
|
|
25
|
+
htmlHeadArg ?? defaultHtmlHead
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
const packageJsonPath = path.join(workingDirectory, 'package.json');
|
|
29
|
+
const pkg = JSON.parse(await fs.promises.readFile(packageJsonPath, 'utf8'));
|
|
30
|
+
const version = pkg.version;
|
|
31
|
+
|
|
32
|
+
if (!version) {
|
|
33
|
+
console.error('No version found in package.json');
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const cssDir = path.join(workingDirectory, 'public', 'css');
|
|
38
|
+
const previousVersionLimit = 5;
|
|
39
|
+
const linkRegex = /<link\b[\s\S]*?\bdata-versioned\b[\s\S]*?\/>/g;
|
|
40
|
+
const hrefCssRegex = /`(\/css\/[^`]+)`/;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Derive the unversioned base filename from a CSS path in an href.
|
|
44
|
+
* e.g. /css/vars.7.1.11.css → vars.css
|
|
45
|
+
* /css/main.css → main.css
|
|
46
|
+
*/
|
|
47
|
+
function getBaseCssName(cssPath) {
|
|
48
|
+
const withoutQuery = cssPath.split('?')[0];
|
|
49
|
+
const fileName = path.basename(withoutQuery);
|
|
50
|
+
|
|
51
|
+
if (!fileName.endsWith('.css')) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const withoutExt = fileName.slice(0, -'.css'.length);
|
|
56
|
+
const versionSuffix = `.${version}`;
|
|
57
|
+
|
|
58
|
+
if (withoutExt.endsWith(versionSuffix)) {
|
|
59
|
+
return withoutExt.slice(0, -versionSuffix.length) + '.css';
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Strip a semver-like suffix if present (e.g. main.7.1.10.css)
|
|
63
|
+
const semverMatch = withoutExt.match(
|
|
64
|
+
/^(.+)\.(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)$/
|
|
65
|
+
);
|
|
66
|
+
if (semverMatch) {
|
|
67
|
+
return semverMatch[1] + '.css';
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return fileName;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async function cleanStaleVersions(baseName) {
|
|
74
|
+
const baseWithoutExt = baseName.slice(0, -'.css'.length);
|
|
75
|
+
const currentVersioned = `${baseWithoutExt}.${version}.css`;
|
|
76
|
+
const entries = await fs.promises.readdir(cssDir);
|
|
77
|
+
const escapedBase = baseWithoutExt.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
78
|
+
const versionedPattern = new RegExp(
|
|
79
|
+
`^${escapedBase}\\.(\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?)\\.css$`
|
|
80
|
+
);
|
|
81
|
+
const previousVersions = entries
|
|
82
|
+
.map((entry) => {
|
|
83
|
+
const match = entry.match(versionedPattern);
|
|
84
|
+
return match ? { entry, version: match[1] } : null;
|
|
85
|
+
})
|
|
86
|
+
.filter((item) => item !== null && item.entry !== currentVersioned)
|
|
87
|
+
.sort((a, b) =>
|
|
88
|
+
b.version.localeCompare(a.version, undefined, { numeric: true })
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
for (const { entry } of previousVersions.slice(previousVersionLimit)) {
|
|
92
|
+
await fs.promises.unlink(path.join(cssDir, entry));
|
|
93
|
+
console.log(`Removed stale ${entry}`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
async function copyVersionedCss(baseName) {
|
|
98
|
+
const sourcePath = path.join(cssDir, baseName);
|
|
99
|
+
const baseWithoutExt = baseName.slice(0, -'.css'.length);
|
|
100
|
+
const versionedName = `${baseWithoutExt}.${version}.css`;
|
|
101
|
+
const destPath = path.join(cssDir, versionedName);
|
|
102
|
+
|
|
103
|
+
try {
|
|
104
|
+
await fs.promises.access(sourcePath);
|
|
105
|
+
} catch {
|
|
106
|
+
console.error(`Source CSS not found: ${sourcePath}`);
|
|
107
|
+
process.exit(1);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
await fs.promises.copyFile(sourcePath, destPath);
|
|
111
|
+
console.log(`Copied ${baseName} → ${versionedName}`);
|
|
112
|
+
await cleanStaleVersions(baseName);
|
|
113
|
+
|
|
114
|
+
return versionedName;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function rewriteLinkHref(linkTag, versionedName) {
|
|
118
|
+
return linkTag.replace(hrefCssRegex, `\`/css/${versionedName}\``);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
let content = await fs.promises.readFile(htmlHeadPath, 'utf8');
|
|
122
|
+
const links = [...content.matchAll(linkRegex)];
|
|
123
|
+
|
|
124
|
+
if (links.length === 0) {
|
|
125
|
+
console.error(
|
|
126
|
+
`No data-versioned <link> tags found in ${htmlHeadPath}`
|
|
127
|
+
);
|
|
128
|
+
process.exit(1);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const processedBases = new Set();
|
|
132
|
+
|
|
133
|
+
for (const match of links) {
|
|
134
|
+
const linkTag = match[0];
|
|
135
|
+
const hrefMatch = linkTag.match(hrefCssRegex);
|
|
136
|
+
|
|
137
|
+
if (!hrefMatch) {
|
|
138
|
+
console.error(
|
|
139
|
+
'data-versioned link is missing a `/css/...` href template:',
|
|
140
|
+
linkTag
|
|
141
|
+
);
|
|
142
|
+
process.exit(1);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const baseName = getBaseCssName(hrefMatch[1]);
|
|
146
|
+
if (!baseName) {
|
|
147
|
+
console.error(`Could not derive base CSS name from ${hrefMatch[1]}`);
|
|
148
|
+
process.exit(1);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
let versionedName;
|
|
152
|
+
if (processedBases.has(baseName)) {
|
|
153
|
+
const baseWithoutExt = baseName.slice(0, -'.css'.length);
|
|
154
|
+
versionedName = `${baseWithoutExt}.${version}.css`;
|
|
155
|
+
} else {
|
|
156
|
+
versionedName = await copyVersionedCss(baseName);
|
|
157
|
+
processedBases.add(baseName);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const updatedLink = rewriteLinkHref(linkTag, versionedName);
|
|
161
|
+
content = content.replace(linkTag, updatedLink);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
await fs.promises.writeFile(htmlHeadPath, content, 'utf8');
|
|
165
|
+
console.log(`Updated ${htmlHeadPath}`);
|