Skip to content

Commit

Permalink
fix(head): minify tags
Browse files Browse the repository at this point in the history
  • Loading branch information
ThornWalli committed Feb 10, 2024
1 parent a9caed5 commit 7f870f5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/runtime/utils/description.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import { minify } from './string';
import { toHashHex } from '#speedkit/utils/string';
import Source from '#speedkit/components/SpeedkitImage/classes/Source';

export function getImageStyleDescription(meta, className) {
return {
key: className,
type: 'text/css',
children: new Source(meta.value).style
children: minify(new Source(meta.value).style)
};
}

export function getPictureStyleDescription(metaSources, classNames) {
return {
key: classNames.picture,
type: 'text/css',
children: metaSources.style
children: minify(metaSources.style)
};
}

Expand Down Expand Up @@ -69,13 +70,13 @@ export function getStyleDescription(children, noScript = false) {
} else {
return {
type: 'text/css',
children
children: minify(children)
};
}
}

export function getNoScriptDescription(textContent) {
return {
innerHTML: textContent
innerHTML: minify(textContent)
};
}
7 changes: 7 additions & 0 deletions src/runtime/utils/string.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,10 @@ export function toHashCode(value) {
export function toHashHex(value) {
return toHashCode(value).toString(16);
}

export function minify(style) {
return style
.split('\n')
.map(line => line.trim())
.join(' ');
}

0 comments on commit 7f870f5

Please sign in to comment.