Socket
Socket
Sign inDemoInstall

@vuepress/client

Package Overview
Dependencies
Maintainers
7
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vuepress/client - npm Package Compare versions

Comparing version 2.0.0-alpha.16 to 2.0.0-alpha.18

16

CHANGELOG.md

@@ -6,2 +6,18 @@ # Change Log

# [2.0.0-alpha.18](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.17...v2.0.0-alpha.18) (2021-01-17)
### Bug Fixes
* **client:** load existing head tags on mounted ([15722c5](https://github.com/vuepress/vuepress-next/commit/15722c5175e44a8d6363bfe5f138f2c2c8edeec3))
### Features
* **client:** make usePageFrontmatter generic ([2c5e5c1](https://github.com/vuepress/vuepress-next/commit/2c5e5c1400469a3cb4da2856104514a9413bff8a))
# [2.0.0-alpha.16](https://github.com/vuepress/vuepress-next/compare/v2.0.0-alpha.15...v2.0.0-alpha.16) (2021-01-11)

@@ -8,0 +24,0 @@

4

lib/injections/pageFrontmatter.d.ts
import type { ComputedRef, InjectionKey } from 'vue';
import type { PageData, PageFrontmatter } from '@vuepress/shared';
export type { PageFrontmatter };
export declare type PageFrontmatterRef = ComputedRef<PageFrontmatter>;
export declare type PageFrontmatterRef<T extends Record<any, any> = Record<string, unknown>> = ComputedRef<PageFrontmatter<T>>;
export declare const pageFrontmatterSymbol: InjectionKey<PageFrontmatterRef>;
export declare const usePageFrontmatter: () => PageFrontmatterRef;
export declare const usePageFrontmatter: <T extends Record<any, any> = Record<string, unknown>>() => PageFrontmatterRef<T>;
export declare const resolvePageFrontmatter: (pageData: PageData) => PageFrontmatter;
//# sourceMappingURL=pageFrontmatter.d.ts.map
import type { HeadConfig } from '@vuepress/shared';
/**
* Query the matched head tag of head config
*/
export declare const queryHeadTag: ([tagName, attrs, content,]: HeadConfig) => HTMLElement | null;
/**
* Create head tag from head config

@@ -4,0 +8,0 @@ */

@@ -6,2 +6,20 @@ import { onMounted, ref, useSSRContext, watch } from 'vue';

/**
* Query the matched head tag of head config
*/
export const queryHeadTag = ([tagName, attrs, content = '',]) => {
const attrsSelector = Object.entries(attrs).map(([key, value]) => {
if (isString(value)) {
return `[${key}="${value}"]`;
}
if (value === true) {
return `[${key}]`;
}
return '';
});
const selector = `head > ${tagName}${attrsSelector}`;
const tags = Array.from(document.querySelectorAll(selector));
const matchedTag = tags.find((item) => item.innerText === content);
return matchedTag || null;
};
/**
* Create head tag from head config

@@ -49,15 +67,21 @@ */

}
// current tag elements that generated by this function
const currentTags = ref([]);
const headTags = ref([]);
// load current head tags from DOM
const loadHead = () => {
head.value.forEach((item) => {
const tag = queryHeadTag(item);
if (tag) {
headTags.value.push(tag);
}
});
};
// update html lang attribute and head tags to DOM
const updateHead = () => {
if (!document) {
return;
}
document.documentElement.lang = lang.value;
currentTags.value.forEach((el) => {
if (el.parentNode === document.head) {
document.head.removeChild(el);
headTags.value.forEach((item) => {
if (item.parentNode === document.head) {
document.head.removeChild(item);
}
});
currentTags.value.splice(0, currentTags.value.length);
headTags.value.splice(0, headTags.value.length);
head.value.forEach((item) => {

@@ -67,9 +91,12 @@ const tag = createHeadTag(item);

document.head.appendChild(tag);
currentTags.value.push(tag);
headTags.value.push(tag);
}
});
};
onMounted(() => updateHead());
watch(head, () => updateHead());
onMounted(() => {
loadHead();
updateHead();
watch([head, lang], () => updateHead());
});
};
//# sourceMappingURL=updateHead.js.map
{
"name": "@vuepress/client",
"version": "2.0.0-alpha.16",
"version": "2.0.0-alpha.18",
"description": "Client package of VuePress",

@@ -31,3 +31,3 @@ "keywords": [

"dependencies": {
"@vuepress/shared": "2.0.0-alpha.15",
"@vuepress/shared": "2.0.0-alpha.18",
"vue": "^3.0.4",

@@ -39,3 +39,3 @@ "vue-router": "^4.0.2"

},
"gitHead": "ff9cfd6d8757210d9013258a94e6ecac32165526"
"gitHead": "8227d4387d402a9ac43c6bfbfb1e3b7574193fa9"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc