vuepress-theme-uniapp-official 1.4.39 → 1.4.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,63 @@
1
+ <script>
2
+ import { defineComponent, h, onMounted, getCurrentInstance } from 'vue';
3
+
4
+ function vnode2h(vnode) {
5
+ if (typeof vnode.tag === 'undefined') {
6
+ return vnode.text
7
+ }
8
+ return h(vnode.tag, vnode.data, vnode.children ? vnode.children.map(vnode2h) : [])
9
+ }
10
+
11
+ export default defineComponent({
12
+ setup(props, { slots }) {
13
+ const { proxy } = getCurrentInstance()
14
+ const sources = {}
15
+ const renderVNodes = []
16
+ slots.default()
17
+ .forEach(vnode => {
18
+ if (typeof vnode.tag !== 'undefined' || (typeof vnode.text !== 'undefined' && vnode.text.trim().length > 0)) {
19
+ if (vnode.tag === 'blockquote') {
20
+ if (vnode.children && vnode.children.length > 0) {
21
+ const p = vnode.children[0]
22
+ const text = p.children[0].text && p.children[0].text.trim()
23
+ if (typeof text === 'string') {
24
+ const [_, git, url] = text.match(/\s*(\w+):\s*(https?:\/\/\S+)$/) || []
25
+ sources[git] = url
26
+ }
27
+ }
28
+ } else {
29
+ renderVNodes.push(vnode)
30
+ }
31
+ }
32
+ })
33
+
34
+ const H = renderVNodes[0]
35
+ if (!H.data.style) H.data.style = {}
36
+ Object.assign(H.data.style, { display: 'flex', justifyContent: 'space-between' })
37
+ onMounted(() => {
38
+ try {
39
+ if (!(proxy.$title && proxy.$page.title)) {
40
+ document.title = proxy.$page.title = `${H.children[1].text} | ${proxy.$siteTitle || ''}`.trim()
41
+ }
42
+ } catch (error) { }
43
+ })
44
+ return () => h(
45
+ H.tag,
46
+ H.data,
47
+ [
48
+ h('span', null, H.children.map(vnode2h)),
49
+ h('span', { style: { marginLeft: '10px', alignSelf: 'center', fontSize: 'initial' } },
50
+ Object.keys(sources).map(git => h('a', {
51
+ attrs: {
52
+ href: sources[git],
53
+ target: '_blank',
54
+ rel: 'noopener noreferrer',
55
+ },
56
+ style: { marginLeft: '5px' }
57
+ }, git))
58
+ )
59
+ ]
60
+ )
61
+ }
62
+ });
63
+ </script>
package/index.js CHANGED
@@ -1,16 +1,16 @@
1
1
  function getFormattedDate() {
2
- const now = new Date();
2
+ const now = new Date();
3
3
 
4
- const year = now.getFullYear();
5
- const month = (now.getMonth() + 1).toString().padStart(2, '0');
6
- const day = now.getDate().toString().padStart(2, '0');
7
- const hours = now.getHours().toString().padStart(2, '0');
8
- const minutes = now.getMinutes().toString().padStart(2, '0');
9
- const seconds = now.getSeconds().toString().padStart(2, '0');
4
+ const year = now.getFullYear();
5
+ const month = (now.getMonth() + 1).toString().padStart(2, '0');
6
+ const day = now.getDate().toString().padStart(2, '0');
7
+ const hours = now.getHours().toString().padStart(2, '0');
8
+ const minutes = now.getMinutes().toString().padStart(2, '0');
9
+ const seconds = now.getSeconds().toString().padStart(2, '0');
10
10
 
11
- const formattedDate = `${year}-${month}-${day}_${hours}-${minutes}-${seconds}`;
11
+ const formattedDate = `${year}-${month}-${day}_${hours}-${minutes}-${seconds}`;
12
12
 
13
- return formattedDate;
13
+ return formattedDate;
14
14
  }
15
15
 
16
16
  const nowString = getFormattedDate();
@@ -40,7 +40,7 @@ module.exports = (themeConfig, ctx, pluginAPI) => {
40
40
  }
41
41
  })
42
42
 
43
- pluginAPI.options.extendMarkdown.add('vuepress-theme-uni-app-md-plugins', (md) =>{
43
+ pluginAPI.options.extendMarkdown.add('vuepress-theme-uni-app-md-plugins', (md) => {
44
44
  md.core.ruler.disable('emoji', true)
45
45
  md.use(require('markdown-it-attrs'), {
46
46
  leftDelimiter: '#{',
@@ -59,9 +59,9 @@ module.exports = (themeConfig, ctx, pluginAPI) => {
59
59
  */
60
60
  ctx.siteConfig.shouldPrefetch = function (path, type) {
61
61
  let themeShouldPrefetch = true
62
- if (type === 'script') themeShouldPrefetch = path.includes('vendors~') || path.includes('layout-') || path.includes('index.')
62
+ if (type === 'script') themeShouldPrefetch = path.includes('vendors~') || path.includes('layout-') || path.includes('index.')
63
63
  else { themeShouldPrefetch = false }
64
- return originalShouldPrefetch.call(this, path, type) || themeShouldPrefetch
64
+ return originalShouldPrefetch.call(this, path, type) || themeShouldPrefetch
65
65
  }
66
66
  ctx.siteConfig.patterns = ctx.siteConfig.patterns || ['**/!(_sidebar).md', '**/*.vue']
67
67
 
@@ -89,7 +89,24 @@ module.exports = (themeConfig, ctx, pluginAPI) => {
89
89
  }
90
90
  }
91
91
  }],
92
- ['container',{
92
+ ['container', {
93
+ type: 'sourceCode',
94
+ validate: (params) => {
95
+ return params.trim().match(/^sourceCode/);
96
+ },
97
+
98
+ render: (tokens, idx, opts, event) => {
99
+ var m = tokens[idx].info.trim().match(/^sourceCode\s+(.*)$/);
100
+ if (tokens[idx].nesting === 1) {
101
+ // opening tag
102
+ return `<SourceCode>`;
103
+ } else {
104
+ // closing tag
105
+ return `</SourceCode>`;
106
+ }
107
+ }
108
+ }],
109
+ ['container', {
93
110
  type: klass,
94
111
  render(tokens, idx, opts, env) {
95
112
  const token = tokens[idx]
@@ -106,7 +123,7 @@ module.exports = (themeConfig, ctx, pluginAPI) => {
106
123
  bgColor: 'rgba(0,0,0,0.6)'
107
124
  }
108
125
  }],
109
- ['named-chunks',{
126
+ ['named-chunks', {
110
127
  layoutChunkName: (layout) => 'layout-' + layout.componentName,
111
128
  pageChunkName: page => {
112
129
  const _context = page._context
@@ -123,8 +140,8 @@ module.exports = (themeConfig, ctx, pluginAPI) => {
123
140
  return curPath
124
141
  }
125
142
  }],
126
- ['check-md2',{
127
- filter({errMsg, fileUrl, fullText, matchUrl, col, line}){
143
+ ['check-md2', {
144
+ filter({ errMsg, fileUrl, fullText, matchUrl, col, line }) {
128
145
  /**
129
146
  * errMsg:"Should use .md instead of .html"、"File is not found"、"Hash should slugify"、"Hash is not found"
130
147
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vuepress-theme-uniapp-official",
3
- "version": "1.4.39",
3
+ "version": "1.4.41",
4
4
  "description": "uni-app official website theme for vuepress",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -43,8 +43,13 @@
43
43
  "vuepress-plugin-mermaidjs": "1.9.1",
44
44
  "vuepress-plugin-named-chunks": "^1.1.4",
45
45
  "vuepress-plugin-zooming": "^1.1.8",
46
- "vuepress-plugin-check-md2": "^1.0.5",
47
- "vuepress-plugin-expandable-row": "^1.0.10"
46
+ "vuepress-plugin-expandable-row": "^1.0.10",
47
+ "vuepress-plugin-check-md2": "^1.0.5"
48
+ },
49
+ "resolutions": {
50
+ "terser-webpack-plugin": "1.4.6",
51
+ "markdown-it": "< 14",
52
+ "vue": "2.7.16"
48
53
  },
49
54
  "scripts": {
50
55
  "publish:patch": "npm version patch && npm publish",