|
1 | 1 | <% |
2 | 2 | var isEn = page.type == 'book-en-us' || page.type == 'about-en'; |
3 | 3 | var isIndex = page.layout === 'index' || page.path === 'index.html'; |
| 4 | +
|
| 5 | + // Absolute URLs for this page and its other-language twin. Book chapters and |
| 6 | + // About pages have a same-path twin; everything else maps to the landing. |
| 7 | + // Shared with the visible language switcher so the two never drift. |
| 8 | + var SITE = 'https://changkun.de'; |
| 9 | + var ROOT = '/modern-cpp/'; |
| 10 | + var _p = page.path || ''; |
| 11 | + var zhUrl, enUrl; |
| 12 | + if (_p.indexOf('zh-cn/') !== -1) { |
| 13 | + zhUrl = SITE + '/' + _p.replace(/index\.html$/, ''); |
| 14 | + enUrl = SITE + '/' + _p.replace('zh-cn/', 'en-us/').replace(/index\.html$/, ''); |
| 15 | + } else if (_p.indexOf('en-us/') !== -1) { |
| 16 | + enUrl = SITE + '/' + _p.replace(/index\.html$/, ''); |
| 17 | + zhUrl = SITE + '/' + _p.replace('en-us/', 'zh-cn/').replace(/index\.html$/, ''); |
| 18 | + } else if (_p.indexOf('/about/en/') !== -1) { |
| 19 | + enUrl = SITE + '/' + _p.replace(/index\.html$/, ''); |
| 20 | + zhUrl = SITE + '/' + _p.replace('/about/en/', '/about/'); |
| 21 | + } else if (_p.indexOf('/about/') !== -1) { |
| 22 | + zhUrl = SITE + '/' + _p.replace(/index\.html$/, ''); |
| 23 | + enUrl = SITE + '/' + _p.replace('/about/', '/about/en/'); |
| 24 | + } else { |
| 25 | + zhUrl = SITE + ROOT; |
| 26 | + enUrl = SITE + ROOT + 'en/'; |
| 27 | + } |
| 28 | + var canonicalUrl = isEn ? enUrl : zhUrl; |
| 29 | +
|
| 30 | + var siteName = isEn ? 'Modern C++ Tutorial' : '现代 C++ 教程'; |
| 31 | + var siteTagline = isEn ? 'Modern C++ Tutorial: C++11 to C++26 On the Fly' : '现代 C++ 教程: 高速上手 C++11 到 C++26'; |
| 32 | + var pageTitle = (page.title ? page.title + ' - ' : '') + siteTagline; |
| 33 | + var pageDesc = page.description ? page.description : (isEn |
| 34 | + ? 'A fast, comprehensive guide to the features of modern C++, from C++11 through C++26.' |
| 35 | + : '高速上手现代 C++ 特性的全面教程,覆盖 C++11 到 C++26。'); |
| 36 | + var ogImage = SITE + ROOT + 'assets/' + (isEn ? 'cover-2nd-en.png' : 'cover-2nd.png'); |
4 | 37 | %> |
5 | 38 | <!DOCTYPE html> |
6 | 39 | <html lang="<%- isEn ? 'en' : 'zh-CN' %>"> |
|
22 | 55 | })(); |
23 | 56 | </script> |
24 | 57 | <% } %> |
25 | | - <title><%- page.title ? page.title + ' - ' : '' %><%- isEn ? 'Modern C++ Tutorial: C++11 to C++26 On the Fly' : '现代 C++ 教程: 高速上手 C++11 到 C++26' %></title> |
26 | | - <meta name="description" content="<%- theme.site_description %>"> |
27 | | - <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> |
28 | | - <link rel="shortcut icon" type="image/x-icon" href="/modern-cpp/assets/cover-2nd.png"> |
| 58 | + <title><%- pageTitle %></title> |
| 59 | + <meta name="description" content="<%- pageDesc %>"> |
| 60 | + <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 61 | + |
| 62 | + <link rel="canonical" href="<%- canonicalUrl %>"> |
| 63 | + <link rel="alternate" hreflang="zh-CN" href="<%- zhUrl %>"> |
| 64 | + <link rel="alternate" hreflang="en" href="<%- enUrl %>"> |
| 65 | + <link rel="alternate" hreflang="x-default" href="<%- SITE + ROOT %>"> |
| 66 | + |
| 67 | + <link rel="icon" type="image/png" sizes="32x32" href="/modern-cpp/assets/favicon.png"> |
| 68 | + <link rel="apple-touch-icon" sizes="180x180" href="/modern-cpp/assets/apple-touch-icon.png"> |
29 | 69 | <meta name="msapplication-TileColor" content="#7e2d36"> |
30 | 70 | <meta name="theme-color" content="#7e2d36"> |
31 | 71 |
|
| 72 | + <meta property="og:type" content="<%- isIndex ? 'website' : 'article' %>"> |
| 73 | + <meta property="og:site_name" content="<%- siteName %>"> |
| 74 | + <meta property="og:title" content="<%- pageTitle %>"> |
| 75 | + <meta property="og:description" content="<%- pageDesc %>"> |
| 76 | + <meta property="og:url" content="<%- canonicalUrl %>"> |
| 77 | + <meta property="og:image" content="<%- ogImage %>"> |
| 78 | + <meta property="og:locale" content="<%- isEn ? 'en_US' : 'zh_CN' %>"> |
| 79 | + <meta property="og:locale:alternate" content="<%- isEn ? 'zh_CN' : 'en_US' %>"> |
| 80 | + <meta name="twitter:card" content="summary_large_image"> |
| 81 | + <meta name="twitter:title" content="<%- pageTitle %>"> |
| 82 | + <meta name="twitter:description" content="<%- pageDesc %>"> |
| 83 | + <meta name="twitter:image" content="<%- ogImage %>"> |
| 84 | + |
32 | 85 | <link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600|Roboto Mono' rel='stylesheet' type='text/css'> |
33 | 86 | <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" type="text/css"> |
34 | 87 |
|
|
0 commit comments