fix: Legacy bugs (styles, site plugin error, and dev server error) (#1743)

* Add try/catch w/ error message to plugin calls

* Update lifecycle.js

* Update lifecycle.js

* Fix docsify-plugin-carbon error

* Fix ESLint errors

* Simplify conditional JS loading

* Fix styles in legacy browser w/o CSS var support

* Fix gitignore paths

* Fix BrowserSync IE error

* Fix search field presentation in IE11

- Removed fixed height and allow element to size naturally via font-size and padding
- Remove default "x" rendered on IE input fields

* Revert "Update lifecycle.js"

This reverts commit 2a58be69eb75a87b74d0408765e1d222282ac95b.

* Revert "Update lifecycle.js"

This reverts commit 67c5410b049237887811350f38e3f9bc8a2c78dc.

* Revert "Add try/catch w/ error message to plugin calls"

This reverts commit 631e9248786f87a5b2f7892fc73a53543744d288.

* Fix docsify-plugin-carbon error & ESLint errors

Co-authored-by: 沈唁 <52o@qq52o.cn>
This commit is contained in:
John Hildenbiddle 2022-02-05 03:21:50 -06:00 committed by GitHub
parent 8aee0744ec
commit fa6df6d584
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 75 additions and 35 deletions

View File

@ -55,7 +55,7 @@
<body>
<div id="app">Loading ...</div>
<script src="//cdn.jsdelivr.net/npm/docsify-plugin-carbon@1/index.js"></script>
<script src="//cdn.jsdelivr.net/npm/docsify-plugin-carbon@1"></script>
<script>
// Set html "lang" attribute based on URL
var lang = location.hash.match(/#\/(de-de|es|ru-ru|zh-cn)\//);
@ -118,13 +118,13 @@
'/zh-cn/': '搜索',
'/': 'Search',
},
pathNamespaces: ['/es', '/de-de', '/ru-ru', '/zh-cn']
pathNamespaces: ['/es', '/de-de', '/ru-ru', '/zh-cn'],
},
vueComponents: {
'button-counter': {
template:
'<button @click="count += 1">You clicked me {{ count }} times</button>',
data: function() {
data: function () {
return {
count: 0,
};
@ -132,7 +132,7 @@
},
},
vueGlobalOptions: {
data: function() {
data: function () {
return {
count: 0,
message: 'Hello, World!',
@ -145,7 +145,7 @@
};
},
computed: {
timeOfDay: function() {
timeOfDay: function () {
const date = new Date();
const hours = date.getHours();
@ -159,14 +159,14 @@
},
},
methods: {
hello: function() {
hello: function () {
alert(this.message);
},
},
},
vueMounts: {
'#counter': {
data: function() {
data: function () {
return {
count: 0,
};
@ -175,8 +175,8 @@
},
plugins: [
DocsifyCarbon.create('CEBI6KQE', 'docsifyjsorg'),
function(hook, vm) {
hook.beforeEach(function(html) {
function (hook, vm) {
hook.beforeEach(function (html) {
if (/githubusercontent\.com/.test(vm.route.file)) {
url = vm.route.file
.replace('raw.githubusercontent.com', 'github.com')
@ -198,7 +198,7 @@
'<a href="https://docsify.js.org" target="_blank" style="color: inherit; font-weight: normal; text-decoration: none;">Powered by docsify</a>'
);
}),
hook.afterEach(function(html) {
hook.afterEach(function (html) {
if (vm.route.path === '/') {
return html;
}
@ -218,19 +218,15 @@
<script src="//cdn.jsdelivr.net/npm/prismjs@1/components/prism-nginx.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/prismjs@1/components/prism-php.min.js"></script>
<script>
(function() {
function loadJS(src, attrs) {
document.write(
'<script src="' + src + '" ' + (attrs || '') + '><\/script>'
);
}
// Public site only
if (/docsify/.test(location.host)) {
loadJS('//cdn.jsdelivr.net/npm/docsify@4/lib/plugins/ga.min.js');
loadJS('//cdn.jsdelivr.net/npm/docsify@4/lib/plugins/matomo.min.js');
}
})();
// Public site only
if (/docsify/.test(location.host)) {
document.write(
'<script src="//cdn.jsdelivr.net/npm/docsify@4/lib/plugins/ga.min.js"><\/script>'
);
document.write(
'<script src="//cdn.jsdelivr.net/npm/docsify@4/lib/plugins/matomo.min.js"><\/script>'
);
}
</script>
<script src="//cdn.jsdelivr.net/npm/vue@2/dist/vue.min.js"></script>
<!-- <script src="//cdn.jsdelivr.net/npm/vue@3/dist/vue.global.prod.js"></script> -->

View File

@ -23,7 +23,7 @@
<body>
<div id="app"></div>
<script src="//cdn.jsdelivr.net/npm/docsify-plugin-carbon@1/index.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/docsify-plugin-carbon@1"></script>
<script>
// Set html "lang" attribute based on URL
var lang = location.hash.match(/#\/(de-de|es|ru-ru|zh-cn)\//);
@ -82,12 +82,12 @@
'/zh-cn/': '搜索',
'/': 'Search',
},
pathNamespaces: ['/es', '/de-de', '/ru-ru', '/zh-cn']
pathNamespaces: ['/es', '/de-de', '/ru-ru', '/zh-cn'],
},
plugins: [
DocsifyCarbon.create('CEBI6KQE', 'docsifyjsorg'),
function(hook, vm) {
hook.beforeEach(function(html) {
function (hook, vm) {
hook.beforeEach(function (html) {
if (/githubusercontent\.com/.test(vm.route.file)) {
url = vm.route.file
.replace('raw.githubusercontent.com', 'github.com')

View File

@ -33,9 +33,8 @@ function style() {
outline: none;
border: none;
width: 100%;
padding: 0 7px;
line-height: 36px;
font-size: 14px;
padding: 0.6em 7px;
font-size: inherit;
border: 1px solid transparent;
}
@ -51,6 +50,13 @@ function style() {
-moz-appearance: none;
appearance: none;
}
.search input::-ms-clear {
display: none;
height: 0;
width: 0;
}
.search .clear-button {
cursor: pointer;
width: 36px;

View File

@ -64,11 +64,13 @@ section.cover
padding 0
.cover-main > p:last-child a
border-color $color-primary
border-color var(--theme-color, $color-primary)
border-radius 2rem
border-style solid
border-width 1px
box-sizing border-box
color $color-primary
color var(--theme-color, $color-primary)
display inline-block
font-size 1.05rem
@ -79,6 +81,7 @@ section.cover
transition all 0.15s ease
&:last-child
background-color $color-primary
background-color var(--theme-color, $color-primary)
color #fff
@ -90,8 +93,10 @@ section.cover
color inherit
blockquote > p > a
border-bottom 2px solid $color-primary
border-bottom 2px solid var(--theme-color, $color-primary)
transition color 0.3s
&:hover
color $color-primary
color var(--theme-color, $color-primary)

View File

@ -26,6 +26,7 @@ div#app
vertical-align middle
.progress
background-color $color-primary
background-color var(--theme-color, $color-primary)
height 2px
left 0px
@ -37,9 +38,11 @@ div#app
z-index 999999
.search a:hover
color $color-primary
color var(--theme-color, $color-primary)
.search .search-keyword
color $color-primary
color var(--theme-color, $color-primary)
font-style normal
font-weight bold
@ -108,10 +111,13 @@ li input[type='checkbox']
transition color 0.3s
&:hover
color $color-primary
color var(--theme-color, $color-primary)
&.active
border-bottom 2px solid $color-primary
border-bottom 2px solid var(--theme-color, $color-primary)
color $color-primary
color var(--theme-color, $color-primary)
/* navbar dropdown */
@ -172,6 +178,7 @@ li input[type='checkbox']
svg
color $color-bg
fill $color-primary
fill var(--theme-color, $color-primary)
height 80px
width 80px
@ -284,6 +291,7 @@ main.hidden
opacity 0.4
span
background-color $color-primary
background-color var(--theme-color, $color-primary)
display block
margin-bottom 4px

View File

@ -40,6 +40,7 @@ $sidebar-width = 16rem
font-weight 600
.markdown-section a
color $color-primary
color var(--theme-color, $color-primary)
.markdown-section p, .markdown-section ul, .markdown-section ol
@ -83,6 +84,7 @@ $sidebar-width = 16rem
margin 0
.markdown-section blockquote
border-left 4px solid $color-primary
border-left 4px solid var(--theme-color, $color-primary)
color #858585
margin 2em 0

View File

@ -34,6 +34,7 @@ body
padding 0
ul li.active > a
color $color-primary
color var(--theme-color, $color-primary)
font-weight 600
@ -43,6 +44,7 @@ body
font-weight 600
.markdown-section a
color $color-primary
color var(--theme-color, $color-primary)
font-weight 600
@ -79,6 +81,7 @@ body
padding-left 1.5rem
.markdown-section blockquote
border-left 4px solid $color-primary
border-left 4px solid var(--theme-color, $color-primary)
color #858585
margin 2em 0
@ -138,6 +141,7 @@ body
color #2973b7
.token.string
color $color-primary
color var(--theme-color, $color-primary)
.token.selector
@ -150,6 +154,7 @@ body
color #22a2c9
.token.attr-value, .token.control, .token.directive, .token.unit
color $color-primary
color var(--theme-color, $color-primary)
.token.keyword

View File

@ -36,6 +36,7 @@ body
ul li.active > a
border-right 2px solid
color $color-primary
color var(--theme-color, $color-primary)
font-weight 600
@ -52,9 +53,10 @@ body
font-weight 600
.markdown-section a
color $color-primary
color var(--theme-color, $color-primary)
font-weight 600
&:hover
text-decoration underline
@ -91,6 +93,7 @@ body
padding-left 1.5rem
.markdown-section blockquote
border-left 4px solid $color-primary
border-left 4px solid var(--theme-color, $color-primary)
color #858585
margin 2em 0
@ -150,6 +153,7 @@ body
color #2973b7
.token.string
color $color-primary
color var(--theme-color, $color-primary)
.token.selector
@ -162,6 +166,7 @@ body
color #22a2c9
.token.attr-value, .token.control, .token.directive, .token.unit
color $color-primary
color var(--theme-color, $color-primary)
.token.keyword, .token.function

View File

@ -36,6 +36,7 @@ body
ul li.active > a
border-right 2px solid
color $color-primary
color var(--theme-color, $color-primary)
font-weight 600
@ -52,6 +53,7 @@ body
font-weight 600
.markdown-section a
color $color-primary
color var(--theme-color, $color-primary)
font-weight 600
@ -88,6 +90,7 @@ body
padding-left 1.5rem
.markdown-section blockquote
border-left 4px solid $color-primary
border-left 4px solid var(--theme-color, $color-primary)
color #858585
margin 2em 0
@ -204,6 +207,7 @@ body
color #2973b7
.token.string
color $color-primary
color var(--theme-color, $color-primary)
.token.selector
@ -216,6 +220,7 @@ body
color #22a2c9
.token.attr-value, .token.control, .token.directive, .token.unit
color $color-primary
color var(--theme-color, $color-primary)
.token.keyword, .token.function

View File

@ -44,18 +44,26 @@ function startServer(options = {}, cb = Function.prototype) {
match: /<\/body>/i,
fn: function (snippet, match) {
// Override changelog alias to load local changelog (see routes)
const injectJS = `
const newSnippet = `
${snippet.replace(/<script[^>]*/, '$& type="text/plain"')}
<script>
// Fix /docs site configuration during tests
(function() {
const aliasConfig = (window && window.$docsify && window.$docsify.alias) || {};
var aliasConfig = (window && window.$docsify && window.$docsify.alias) || {};
var isIE = /*@cc_on!@*/false || !!document.documentMode;
// Fix /docs site configuration during tests
aliasConfig['.*?/changelog'] = '/changelog.md';
// Enable BrowserSync snippet for non-IE browsers
if (!isIE) {
document.querySelector('#__bs_script__').removeAttribute('type');
}
})();
</script>
${match}
`;
return injectJS + snippet + match;
return newSnippet;
},
},
},