@kobalab/liulian 1.1.6 → 1.1.7
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.
- package/ChangeLog.md +6 -0
- package/lib/html/index.js +14 -2
- package/lib/text/inline.js +11 -4
- package/package.json +1 -1
package/ChangeLog.md
CHANGED
package/lib/html/index.js
CHANGED
|
@@ -88,6 +88,13 @@ module.exports = class HTML {
|
|
|
88
88
|
`<script>\n${opt.code}</script>\n`
|
|
89
89
|
).join('');
|
|
90
90
|
|
|
91
|
+
const ogp = '<meta name="twitter:card" content="summary">\n'
|
|
92
|
+
+ '<meta property="og:title" '
|
|
93
|
+
+ `content="${cref(this.title())}">\n`
|
|
94
|
+
+ '<meta property="og:image" content="'
|
|
95
|
+
+ this._req.fullUrl(fixpath(this._.icon, req.baseUrl))
|
|
96
|
+
+ '>\n';
|
|
97
|
+
|
|
91
98
|
const meta = this._.meta.map(attr=>{
|
|
92
99
|
let attrs = Object.keys(attr).map(key=>
|
|
93
100
|
`${cdata(key)}="${cdata(attr[key])}"`).join(' ');
|
|
@@ -100,6 +107,7 @@ module.exports = class HTML {
|
|
|
100
107
|
+ 'content="width=device-width, initial-scale=1">\n'
|
|
101
108
|
+ meta
|
|
102
109
|
+ `<title>${cref(this.title())}</title>\n`
|
|
110
|
+
+ ogp
|
|
103
111
|
+ scriptRef
|
|
104
112
|
+ icon
|
|
105
113
|
+ stylesheet
|
|
@@ -142,10 +150,14 @@ module.exports = class HTML {
|
|
|
142
150
|
}
|
|
143
151
|
|
|
144
152
|
_footer() {
|
|
153
|
+
let original = this._req.scheme + '://' + this._req.host
|
|
154
|
+
+ this._req.baseUrl
|
|
155
|
+
== this._req.productUrl.replace(/\/$/,'');
|
|
145
156
|
return `<div id="l-footer">\n`
|
|
146
157
|
+ `<hr>\n`
|
|
147
|
-
+ `<address><a href="${cdata(this._req.productUrl)}"
|
|
148
|
-
+
|
|
158
|
+
+ `<address><a href="${cdata(this._req.productUrl)}"`
|
|
159
|
+
+ (original ? '' : ' target="_blank"')
|
|
160
|
+
+ `>LiuLian/${cdata(this._req.version)}</a></address>\n`
|
|
149
161
|
+ `</div>\n`;
|
|
150
162
|
}
|
|
151
163
|
|
package/lib/text/inline.js
CHANGED
|
@@ -43,7 +43,9 @@ const mark_pt = m3.replace(/\s+/g,'');
|
|
|
43
43
|
|
|
44
44
|
function link(str) {
|
|
45
45
|
let href = str.match(/:/) ? str : 'mailto:' + str;
|
|
46
|
-
return
|
|
46
|
+
return href.match(/^mailto:/)
|
|
47
|
+
? `<a href="${cdata(href)}">${cdata(str)}</a>`
|
|
48
|
+
: `<a href="${cdata(href)}" target="_blank">${cdata(str)}</a>`;
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
const text = replacer(link_pt, link, cref);
|
|
@@ -88,12 +90,17 @@ module.exports = function(parser) {
|
|
|
88
90
|
|
|
89
91
|
function bracket(str) {
|
|
90
92
|
if (str.match(/^[^|]*$/)) {
|
|
91
|
-
return `<a href="${cdata(fixlink(str))}"
|
|
92
|
-
+
|
|
93
|
+
return `<a href="${cdata(fixlink(str))}"`
|
|
94
|
+
+ (str.match(/^(?:https?:|ftp:|\/\/)/)
|
|
95
|
+
? ' target="_blank"' : '')
|
|
96
|
+
+ `>${cdata(str)}</a>`;
|
|
93
97
|
}
|
|
94
98
|
else {
|
|
95
99
|
let [ , title, href ] = str.match(/^(.*)\|(.*)$/);
|
|
96
|
-
return `<a href="${cdata(fixlink(href))}"
|
|
100
|
+
return `<a href="${cdata(fixlink(href))}"`
|
|
101
|
+
+ (href.match(/^(?:https?:|ftp:|\/\/)/)
|
|
102
|
+
? ' target="_blank"' : '')
|
|
103
|
+
+ `>${inline(title)}</a>`;
|
|
97
104
|
}
|
|
98
105
|
}
|
|
99
106
|
|