Skip to content

Commit

Permalink
fix(v-font): add argument for additional head
Browse files Browse the repository at this point in the history
  • Loading branch information
ThornWalli committed Mar 14, 2022
1 parent 1488847 commit 6e620bd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
9 changes: 7 additions & 2 deletions lib/plugins/vFont/head.js
@@ -1,5 +1,8 @@
import Vue from 'vue';
import merge from 'deepmerge';

const pageStyles = { prev: new Map(), current: new Map() };
const arrayConcatMerge = (destinationArray, sourceArray, options) => [].concat(destinationArray, sourceArray);

export default {
install (Vue) {
Expand All @@ -17,7 +20,7 @@ export default {
}
};

const head = function () {
const head = function (headAddition) {
const head = this.fontCollection.getHeadDescription ? this.fontCollection.getHeadDescription(this.isCritical, this.$speedkit.crossorigin) : {};
let style = head.style || [];

Expand All @@ -44,7 +47,9 @@ const head = function () {

style = style.concat(Array.from(pageStyles.prev.values()), Array.from(pageStyles.current.values()));

return { ...head, style };
return merge({ ...head, style }, headAddition || {}, {
arrayMerge: arrayConcatMerge
});
};

!('$speedkitHead' in Vue.prototype) && Object.defineProperty(Vue.prototype, '$speedkitHead', {
Expand Down
5 changes: 2 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -40,6 +40,7 @@
"bowser": "2.11.0",
"browserslist-useragent-regexp": "3.0.2",
"buffer-image-size": "0.6.4",
"deepmerge": "^4.2.2",
"defu": "5.0.1",
"dynamic-class-list": "2.0.1",
"serialize-to-js": "3.1.1",
Expand Down

0 comments on commit 6e620bd

Please sign in to comment.