@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 CHANGED
@@ -1,3 +1,9 @@
1
+ ### v1.1.7 / 2023-03-17
2
+
3
+ - [Twitterカード](https://developer.twitter.com/ja/docs/tweets/optimize-with-cards/guides/getting-started) に対応
4
+ - 外部リンクを別タブで開くよう修正
5
+ - 脆弱性警告に対処(json5 2.1.3 → 2.2.3)
6
+
1
7
  ### v1.1.6 / 2022-12-08
2
8
 
3
9
  - highlight() の deprecated な呼び出し方法を修正
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
- + `LiuLian/${cdata(this._req.version)}</a></address>\n`
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
 
@@ -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 `<a href="${cdata(href)}">${cdata(str)}</a>`;
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
- + `${cdata(str)}</a>`;
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))}">${inline(title)}</a>`;
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kobalab/liulian",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
4
4
  "description": "Node.jsで動作するWebサイト作成ツール",
5
5
  "publishConfig": {
6
6
  "access": "public"