Skip to content

Commit bf66e41

Browse files
committed
deploy: 2097935
1 parent 9b3bfdf commit bf66e41

File tree

96 files changed

+8063
-625
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+8063
-625
lines changed

_ga.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// @deno-types="https://deno.land/x/types/react/v16.13.1/react.d.ts"
2+
3+
const Ga = ({ id }) => {
4+
React.useEffect(() => {
5+
window.addEventListener('rerender', () => {
6+
// @ts-ignore
7+
window.ga('set', 'page', location.pathname);
8+
window.ga('send', 'pageview');
9+
});
10+
}, []);
11+
return (React.createElement(React.Fragment, null,
12+
React.createElement("script", { async: true, src: "https://www.google-analytics.com/analytics.js" }),
13+
React.createElement("script", { dangerouslySetInnerHTML: {
14+
__html: `window.dataLayer = window.dataLayer || []; function gtag() { dataLayer.push(arguments); } gtag('js', new Date()); gtag('config', '${id}');`
15+
} })));
16+
};
17+
export default Ga;

_layout.js

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,45 @@
11
// @deno-types="https://deno.land/x/types/react/v16.13.1/react.d.ts"
22

33
import Sidebar from './_sidebar.js';
4-
import Gitalk from './_gitalk.js';
5-
const Layout = ({ config, title, content, script, sidebar, outputPath }) => {
4+
const Layout = ({ config, title, content, ga, gitalk, script, sidebar, outputPath }) => {
65
const [isDark, setIsDark] = React.useState(
76
// @ts-ignore
87
window.Deno ? false : document.documentElement.classList.contains('is_dark'));
98
return (React.createElement("html", { className: isDark ? 'is_dark' : '' },
109
React.createElement("head", null,
11-
React.createElement("script", { async: true, src: "https://www.google-analytics.com/analytics.js" }),
12-
React.createElement("script", { dangerouslySetInnerHTML: {
13-
__html: `window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-45256157-14');`
14-
} }),
10+
ga,
1511
React.createElement("title", null, outputPath !== 'index.html' ? `${title} · ${config.title}` : title),
1612
React.createElement("meta", { charSet: "utf-8" }),
17-
React.createElement("link", { rel: "shortcut icon", type: "image/png", href: "//xcatliu.github.io/favicon.ico" }),
18-
React.createElement("link", { id: "prismTheme", rel: "stylesheet", href: isDark ? '/assets/prism_tomorrow.css' : '/assets/prism.css' }),
19-
React.createElement("link", { rel: "stylesheet", href: "/assets/index.css" }),
13+
React.createElement("link", { id: "prismTheme", rel: "stylesheet", href: isDark ? `${config.base}assets/prism_tomorrow.css` : `${config.base}assets/prism.css` }),
2014
React.createElement("script", { dangerouslySetInnerHTML: {
2115
__html: `
2216
let shouldSetIsDark = document.cookie.includes('is_dark=1') ? true : document.cookie.includes('is_dark=0') ? false : window.matchMedia('(prefers-color-scheme: dark)').matches
2317
if (shouldSetIsDark) {
2418
document.documentElement.classList.add('is_dark');
25-
document.getElementById('prismTheme').href = "/assets/prism_tomorrow.css";
19+
document.getElementById('prismTheme').href = "${config.base}assets/prism_tomorrow.css";
2620
}
2721
`
28-
} })),
22+
} }),
23+
React.createElement("link", { rel: "stylesheet", href: `${config.base}assets/index.css` })),
2924
React.createElement("body", null,
3025
React.createElement("header", null,
3126
React.createElement("h1", null,
32-
React.createElement("a", { href: "/" }, config.title)),
27+
React.createElement("a", { href: config.base }, config.title)),
3328
React.createElement("nav", null,
3429
React.createElement("ul", null,
35-
React.createElement("li", null,
36-
React.createElement("a", { href: "https://github.com/xcatliu/typescript-tutorial" }, "GitHub")),
37-
React.createElement("li", null,
38-
React.createElement("a", { href: "https://github.com/xcatliu/buy-me-a-coffee" }, "\u8D5E\u52A9\u4F5C\u8005")),
39-
React.createElement("li", null,
40-
React.createElement("a", { href: "https://github.com/xcatliu/pagic" }, "\u672C\u7F51\u7AD9\u4F7F\u7528 Pagic \u6784\u5EFA")),
30+
config.nav.map(({ text, link }) => (React.createElement("li", { key: link },
31+
React.createElement("a", { href: link }, text)))),
4132
React.createElement("li", null,
4233
React.createElement("a", { href: "#", onClick: (e) => {
4334
e.preventDefault();
4435
setIsDark(!isDark);
4536
// @ts-ignore
4637
document.cookie = `is_dark=${!isDark ? '1' : '0'}; expires=Tue, 19 Jun 2038 03:14:07 UTC; path=/`;
4738
} }, isDark ? '关闭黑暗模式' : '开启黑暗模式'))))),
48-
React.createElement(Sidebar, { sidebar: sidebar, outputPath: outputPath }),
39+
React.createElement(Sidebar, { sidebar: sidebar, outputPath: outputPath, config: config }),
4940
React.createElement("section", { className: "main" },
5041
content,
51-
React.createElement(Gitalk, { clientID: "29aa4941759fc887ed4f", clientSecret: "33e355efdf3a1959624506a5d88311145208471b", repo: "typescript-tutorial", owner: "xcatliu", admin: ['xcatliu'], id: outputPath, title: title })),
42+
gitalk),
5243
script)));
5344
};
5445
export default Layout;

_sidebar.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// @deno-types="https://deno.land/x/types/react/v16.13.1/react.d.ts"
22

3-
const Sidebar = ({ sidebar, outputPath }) => (React.createElement("aside", null,
4-
React.createElement("ul", null, sidebar.map(({ title, link, children }) => (React.createElement("li", { key: link },
5-
React.createElement("a", { href: link, className: link === `/${outputPath}` ? 'active' : '' }, title),
6-
children && (React.createElement("ul", null, children.map(({ title, link }) => (React.createElement("li", { key: link },
7-
React.createElement("a", { href: link, className: link === `/${outputPath}` ? 'active' : '' }, title))))))))))));
3+
const Sidebar = ({ sidebar, outputPath, config }) => (React.createElement("aside", null,
4+
React.createElement("ul", null, sidebar.map(({ text, link, children }) => (React.createElement("li", { key: link },
5+
React.createElement("a", { href: `${config.base}${link}`, className: link === outputPath ? 'active' : '' }, text),
6+
children && (React.createElement("ul", null, children.map(({ text, link }) => (React.createElement("li", { key: link },
7+
React.createElement("a", { href: `${config.base}${link}`, className: link === outputPath ? 'active' : '' }, text))))))))))));
88
export default Sidebar;

advanced/class-and-interfaces.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
<html class="" data-reactroot=""><head><script async="" src="https://www.google-analytics.com/analytics.js"></script><script>window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-45256157-14');</script><title>类与接口 · TypeScript 入门教程</title><meta charSet="utf-8"/><link rel="shortcut icon" type="image/png" href="//xcatliu.github.io/favicon.ico"/><link id="prismTheme" rel="stylesheet" href="/assets/prism.css"/><link rel="stylesheet" href="/assets/index.css"/><script>
1+
<html class="" data-reactroot=""><head><script async="" src="https://www.google-analytics.com/analytics.js"></script><script>window.dataLayer = window.dataLayer || []; function gtag() { dataLayer.push(arguments); } gtag('js', new Date()); gtag('config', 'UA-45256157-14');</script><title>类与接口 · TypeScript 入门教程</title><meta charSet="utf-8"/><link id="prismTheme" rel="stylesheet" href="/assets/prism.css"/><script>
22
let shouldSetIsDark = document.cookie.includes('is_dark=1') ? true : document.cookie.includes('is_dark=0') ? false : window.matchMedia('(prefers-color-scheme: dark)').matches
33
if (shouldSetIsDark) {
44
document.documentElement.classList.add('is_dark');
55
document.getElementById('prismTheme').href = "/assets/prism_tomorrow.css";
66
}
7-
</script></head><body><header><h1><a href="/">TypeScript 入门教程</a></h1><nav><ul><li><a href="https://github.com/xcatliu/typescript-tutorial">GitHub</a></li><li><a href="https://github.com/xcatliu/buy-me-a-coffee">赞助作者</a></li><li><a href="https://github.com/xcatliu/pagic">本网站使用 Pagic 构建</a></li><li><a href="#">开启黑暗模式</a></li></ul></nav></header><aside><ul><li><a href="/index.html" class="">TypeScript 入门教程</a></li><li><a href="/introduction/index.html" class="">简介</a><ul><li><a href="/introduction/what-is-typescript.html" class="">什么是 TypeScript</a></li><li><a href="/introduction/get-typescript.html" class="">安装 TypeScript</a></li><li><a href="/introduction/hello-typescript.html" class="">Hello TypeScript</a></li></ul></li><li><a href="/basics/index.html" class="">基础</a><ul><li><a href="/basics/primitive-data-types.html" class="">原始数据类型</a></li><li><a href="/basics/any.html" class="">任意值</a></li><li><a href="/basics/type-inference.html" class="">类型推论</a></li><li><a href="/basics/union-types.html" class="">联合类型</a></li><li><a href="/basics/type-of-object-interfaces.html" class="">对象的类型——接口</a></li><li><a href="/basics/type-of-array.html" class="">数组的类型</a></li><li><a href="/basics/type-of-function.html" class="">函数的类型</a></li><li><a href="/basics/type-assertion.html" class="">类型断言</a></li><li><a href="/basics/declaration-files.html" class="">声明文件</a></li><li><a href="/basics/built-in-objects.html" class="">内置对象</a></li></ul></li><li><a href="/advanced/index.html" class="">进阶</a><ul><li><a href="/advanced/type-aliases.html" class="">类型别名</a></li><li><a href="/advanced/string-literal-types.html" class="">字符串字面量类型</a></li><li><a href="/advanced/tuple.html" class="">元组</a></li><li><a href="/advanced/enum.html" class="">枚举</a></li><li><a href="/advanced/class.html" class=""></a></li><li><a href="/advanced/class-and-interfaces.html" class="active">类与接口</a></li><li><a href="/advanced/generics.html" class="">泛型</a></li><li><a href="/advanced/declaration-merging.html" class="">声明合并</a></li><li><a href="/advanced/further-reading.html" class="">扩展阅读</a></li></ul></li><li><a href="/engineering/index.html" class="">工程</a><ul><li><a href="/engineering/lint.html" class="">代码检查</a></li><li><a href="/engineering/compiler-options.html" class="">编译选项</a></li></ul></li><li><a href="/thanks/index.html" class="">感谢</a></li></ul></aside><section class="main"><article><h1 id="%E7%B1%BB%E4%B8%8E%E6%8E%A5%E5%8F%A3">类与接口 <a class="header-anchor" href="#%E7%B1%BB%E4%B8%8E%E6%8E%A5%E5%8F%A3">§</a></h1>
7+
</script><link rel="stylesheet" href="/assets/index.css"/></head><body><header><h1><a href="/">TypeScript 入门教程</a></h1><nav><ul><li><a href="https://github.com/xcatliu/typescript-tutorial">GitHub</a></li><li><a href="https://github.com/xcatliu/typescript-tutorial">赞助作者</a></li><li><a href="https://github.com/xcatliu/pagic">本网站使用 Pagic 构建</a></li><li><a href="#">开启黑暗模式</a></li></ul></nav></header><aside><ul><li><a href="/index.html" class="">TypeScript 入门教程</a></li><li><a href="/introduction/index.html" class="">简介</a><ul><li><a href="/introduction/what-is-typescript.html" class="">什么是 TypeScript</a></li><li><a href="/introduction/get-typescript.html" class="">安装 TypeScript</a></li><li><a href="/introduction/hello-typescript.html" class="">Hello TypeScript</a></li></ul></li><li><a href="/basics/index.html" class="">基础</a><ul><li><a href="/basics/primitive-data-types.html" class="">原始数据类型</a></li><li><a href="/basics/any.html" class="">任意值</a></li><li><a href="/basics/type-inference.html" class="">类型推论</a></li><li><a href="/basics/union-types.html" class="">联合类型</a></li><li><a href="/basics/type-of-object-interfaces.html" class="">对象的类型——接口</a></li><li><a href="/basics/type-of-array.html" class="">数组的类型</a></li><li><a href="/basics/type-of-function.html" class="">函数的类型</a></li><li><a href="/basics/type-assertion.html" class="">类型断言</a></li><li><a href="/basics/declaration-files.html" class="">声明文件</a></li><li><a href="/basics/built-in-objects.html" class="">内置对象</a></li></ul></li><li><a href="/advanced/index.html" class="">进阶</a><ul><li><a href="/advanced/type-aliases.html" class="">类型别名</a></li><li><a href="/advanced/string-literal-types.html" class="">字符串字面量类型</a></li><li><a href="/advanced/tuple.html" class="">元组</a></li><li><a href="/advanced/enum.html" class="">枚举</a></li><li><a href="/advanced/class.html" class=""></a></li><li><a href="/advanced/class-and-interfaces.html" class="active">类与接口</a></li><li><a href="/advanced/generics.html" class="">泛型</a></li><li><a href="/advanced/declaration-merging.html" class="">声明合并</a></li><li><a href="/advanced/further-reading.html" class="">扩展阅读</a></li></ul></li><li><a href="/engineering/index.html" class="">工程</a><ul><li><a href="/engineering/lint.html" class="">代码检查</a></li><li><a href="/engineering/compiler-options.html" class="">编译选项</a></li></ul></li><li><a href="/thanks/index.html" class="">感谢</a></li></ul></aside><section class="main"><article><h1 id="%E7%B1%BB%E4%B8%8E%E6%8E%A5%E5%8F%A3">类与接口 <a class="header-anchor" href="#%E7%B1%BB%E4%B8%8E%E6%8E%A5%E5%8F%A3">§</a></h1>
88
<p><a href="../basics/type-of-object-interfaces.html">之前学习过</a>,接口(Interfaces)可以用于对「对象的形状(Shape)」进行描述。</p>
99
<p>这一章主要介绍接口的另一个用途,对类的一部分行为进行抽象。</p>
1010
<h2 id="%E7%B1%BB%E5%AE%9E%E7%8E%B0%E6%8E%A5%E5%8F%A3">类实现接口 <a class="header-anchor" href="#%E7%B1%BB%E5%AE%9E%E7%8E%B0%E6%8E%A5%E5%8F%A3">§</a></h2>

advanced/class-and-interfaces_content.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)