vitepress
Advanced tools
Comparing version 0.15.2 to 0.15.3
@@ -0,1 +1,9 @@ | ||
## [0.15.3](https://github.com/vuejs/vitepress/compare/v0.15.2...v0.15.3) (2021-06-15) | ||
### Bug Fixes | ||
- avoid error when theme does not have .nav-bar class ([a9d5800](https://github.com/vuejs/vitepress/commit/a9d580069fff90298b197808379cd0c4b756d463)) | ||
- avoid resetting head tags on hmr/page switch ([f52f20e](https://github.com/vuejs/vitepress/commit/f52f20e02f6908411ad9cddb341583456a3c2a8c)) | ||
- watch config file when using srcDir ([348f19a](https://github.com/vuejs/vitepress/commit/348f19a537930b1d4c7272e05e91edcb72219f34)) | ||
## [0.15.2](https://github.com/vuejs/vitepress/compare/v0.15.1...v0.15.2) (2021-06-15) | ||
@@ -2,0 +10,0 @@ |
import { watchEffect } from 'vue'; | ||
export function useUpdateHead(route, siteDataByRouteRef) { | ||
const metaTags = Array.from(document.querySelectorAll('meta')); | ||
let metaTagEls = Array.from(document.querySelectorAll('meta')); | ||
let isFirstUpdate = true; | ||
@@ -12,11 +12,36 @@ const updateHeadTags = (newTags) => { | ||
} | ||
metaTags.forEach((el) => document.head.removeChild(el)); | ||
metaTags.length = 0; | ||
if (newTags && newTags.length) { | ||
newTags.forEach((headConfig) => { | ||
const el = createHeadElement(headConfig); | ||
document.head.appendChild(el); | ||
metaTags.push(el); | ||
}); | ||
const newEls = []; | ||
const commonLength = Math.min(metaTagEls.length, newTags.length); | ||
for (let i = 0; i < commonLength; i++) { | ||
let el = metaTagEls[i]; | ||
const [tag, attrs] = newTags[i]; | ||
if (el.tagName.toLocaleLowerCase() === tag) { | ||
for (const key in attrs) { | ||
if (el.getAttribute(key) !== attrs[key]) { | ||
el.setAttribute(key, attrs[key]); | ||
} | ||
} | ||
for (let i = 0; i < el.attributes.length; i++) { | ||
const name = el.attributes[i].name; | ||
if (!(name in attrs)) { | ||
el.removeAttribute(name); | ||
} | ||
} | ||
} | ||
else { | ||
document.head.removeChild(el); | ||
el = createHeadElement(newTags[i]); | ||
document.head.append(el); | ||
} | ||
newEls.push(el); | ||
} | ||
metaTagEls | ||
.slice(commonLength) | ||
.forEach((el) => document.head.removeChild(el)); | ||
newTags.slice(commonLength).forEach((headConfig) => { | ||
const el = createHeadElement(headConfig); | ||
document.head.appendChild(el); | ||
newEls.push(el); | ||
}); | ||
metaTagEls = newEls; | ||
}; | ||
@@ -23,0 +48,0 @@ watchEffect(() => { |
@@ -131,4 +131,4 @@ import { reactive, inject, markRaw, nextTick, readonly } from 'vue'; | ||
function scrollTo(el, hash, smooth = false) { | ||
const pageOffset = document.querySelector('.nav-bar') | ||
.offsetHeight; | ||
const nav = document.querySelector('.nav-bar'); | ||
const pageOffset = nav ? nav.offsetHeight : 0; | ||
const target = el.classList.contains('.header-anchor') | ||
@@ -135,0 +135,0 @@ ? el |
@@ -83,2 +83,4 @@ "use strict"; | ||
configureServer(server) { | ||
console.log(configPath); | ||
server.watcher.add(configPath); | ||
// serve our index.html after vite history fallback | ||
@@ -85,0 +87,0 @@ return () => { |
{ | ||
"name": "vitepress", | ||
"version": "0.15.2", | ||
"version": "0.15.3", | ||
"description": "Vite & Vue powered static site generator", | ||
@@ -5,0 +5,0 @@ "main": "dist/node/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
261127
3852