@clidey/dory 0.48.0 → 0.49.0
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/index.html +4 -4
- package/package.json +1 -1
- package/src/plugins/html-metadata-injector.ts +19 -0
package/index.html
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8" />
|
|
5
|
-
<link rel="icon" href="
|
|
5
|
+
<link rel="icon" href="" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
7
|
<meta name="theme-color" content="#000000" />
|
|
8
8
|
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
<!-- Open Graph / Facebook -->
|
|
13
13
|
<meta property="og:title" content="Documentation" />
|
|
14
14
|
<meta property="og:description" content="Documentation" />
|
|
15
|
-
<meta property="og:image" content="
|
|
15
|
+
<meta property="og:image" content="" />
|
|
16
16
|
<meta property="og:url" content="" />
|
|
17
17
|
<meta property="og:type" content="website" />
|
|
18
18
|
<meta property="og:site_name" content="Documentation" />
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
<meta name="twitter:card" content="summary_large_image" />
|
|
23
23
|
<meta name="twitter:title" content="Documentation" />
|
|
24
24
|
<meta name="twitter:description" content="Documentation" />
|
|
25
|
-
<meta name="twitter:image" content="
|
|
25
|
+
<meta name="twitter:image" content="" />
|
|
26
26
|
<meta name="twitter:site" content="" />
|
|
27
27
|
<meta name="twitter:creator" content="" />
|
|
28
28
|
|
|
29
29
|
<link rel="canonical" href="" />
|
|
30
|
-
<link rel="apple-touch-icon" href="
|
|
30
|
+
<link rel="apple-touch-icon" href="" />
|
|
31
31
|
<link rel="manifest" href="/manifest.json" />
|
|
32
32
|
|
|
33
33
|
<title>Documentation</title>
|
package/package.json
CHANGED
|
@@ -29,6 +29,12 @@ export function htmlMetadataInjector(): Plugin {
|
|
|
29
29
|
? `${siteUrl}${rawImage.startsWith('/') ? '' : '/'}${rawImage}`
|
|
30
30
|
: rawImage;
|
|
31
31
|
|
|
32
|
+
// Favicon: config.favicon (copied to dist root by docs-assets), else
|
|
33
|
+
// fall back to the logo so sites without a dedicated favicon still
|
|
34
|
+
// get an icon instead of a broken link.
|
|
35
|
+
const rawFavicon: string = config.favicon || config.logo?.light || config.logo?.dark || '';
|
|
36
|
+
const faviconHref = rawFavicon ? `/${rawFavicon.replace(/^\.?\/*/, '')}` : '';
|
|
37
|
+
|
|
32
38
|
// Function replacements everywhere so `$&` etc. in config values
|
|
33
39
|
// cannot corrupt the output.
|
|
34
40
|
const setTag = (re: RegExp, replacement: string) => {
|
|
@@ -44,6 +50,19 @@ export function htmlMetadataInjector(): Plugin {
|
|
|
44
50
|
// Title
|
|
45
51
|
setTag(/<title>.*?<\/title>/, `<title>${escapeHtml(defaultTitle)}</title>`);
|
|
46
52
|
|
|
53
|
+
// Favicon (icon + apple-touch-icon); left as empty attributes in
|
|
54
|
+
// index.html and removed entirely when there's nothing to point at.
|
|
55
|
+
if (faviconHref) {
|
|
56
|
+
setTag(/<link rel="icon" href=".*?" \/>/, `<link rel="icon" href="${escapeHtml(faviconHref)}" />`);
|
|
57
|
+
setTag(
|
|
58
|
+
/<link rel="apple-touch-icon" href=".*?" \/>/,
|
|
59
|
+
`<link rel="apple-touch-icon" href="${escapeHtml(faviconHref)}" />`
|
|
60
|
+
);
|
|
61
|
+
} else {
|
|
62
|
+
removeTag(/[ \t]*<link rel="icon" href=".*?" \/>\n?/);
|
|
63
|
+
removeTag(/[ \t]*<link rel="apple-touch-icon" href=".*?" \/>\n?/);
|
|
64
|
+
}
|
|
65
|
+
|
|
47
66
|
// Description
|
|
48
67
|
setTag(
|
|
49
68
|
/<meta name="description" content=".*?" \/>/,
|