Skip to content

Commit a003029

Browse files
author
elonz
committed
deploy: typora build and release
Change-Id: I49f17aa25c76fd20f64e5b6ce9b41eff1281a0c9
1 parent a4d931a commit a003029

File tree

3 files changed

+19
-15
lines changed

3 files changed

+19
-15
lines changed

.github/workflows/release.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,19 @@ jobs:
1616
run: |
1717
npm install
1818
npm run compile
19+
npm run compile -- --platform typora --distDir dist/typora-themes
1920
- name: Pack
2021
run: |
2122
cd dist/themes
2223
zip -r mweb-themes.zip ./
24+
cd ../typora-themes
25+
zip -r typora-themes.zip ./
2326
- name: Release
2427
uses: softprops/action-gh-release@v1
2528
if: startsWith(github.ref, 'refs/tags/') # 先执行 git tag -a {tag} 再执行 git push origin {tag} 以触发更新
2629
with:
27-
files: dist/themes/mweb-themes.zip
30+
files: |
31+
dist/themes/mweb-themes.zip
32+
dist/typora-themes/typora-themes.zip
2833
env:
2934
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

scripts/compile.js

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,13 @@ const args = minimist(process.argv.slice(2), {
1717

1818
const platformConfig = {
1919
mweb: {
20+
filter: (filename) => /^mweb-/.test(filename),
2021
namer: (filename) => `${path.parse(filename).name}.css`,
21-
postcss: (css) => setContainerSelector({ css, selector: ".markdown-body" }),
22-
},
23-
juejin: {
24-
namer: (filename) =>
25-
`${path.parse(filename).name.replace(/^mweb/, "juejin")}.css`, // 替换 mweb- 前缀为 juejin-
2622
},
2723
typora: {
28-
namer: (filename) =>
29-
`${path.parse(filename).name.replace(/^mweb/, "typora")}.css`, // 替换 mweb- 前缀为 typora-
30-
postcss: async (css) =>
31-
wrapSelector({
32-
css: await setContainerSelector({ css, selector: "#write" }),
33-
prefix: "#write",
34-
}),
24+
filter: (filename) => /^typora-/.test(filename),
25+
namer: (filename) => `${path.parse(filename).name}.css`,
26+
postcss: async (css) => wrapSelector({ css, prefix: "#write" }),
3527
},
3628
};
3729

@@ -65,11 +57,14 @@ const writeFile = ({ filePath, css }) => {
6557

6658
fs.removeSync(args.distDir);
6759

60+
const cfg = platformConfig[args.platform];
61+
6862
const files = args.file
6963
? [args.file]
7064
: fs
7165
.readdirSync(args.themeDir)
7266
.filter((filename) => filename.match(/\.scss/))
67+
.filter(cfg.filter)
7368
.map((file) => `${args.themeDir}/${file}`);
7469

7570
files.forEach(async (filePath) => {

src/views/typora.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@
55
<meta charset="utf-8">
66
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
77
<title>Typora</title>
8-
<link rel="stylesheet" href="typora/font-awesome.min.css">
9-
<link rel="stylesheet" href="typora/bootstrap.css">
108
<link rel="stylesheet" href="typora/codemirror.css">
119
<link rel="stylesheet" href="typora/base.css">
1210
<link rel="stylesheet" href="typora/base-control.css">
1311

1412
<link rel="stylesheet" href="typora.css">
13+
<script src="/socket.io/socket.io.js"></script>
14+
<script defer>
15+
io('ws://localhost:3000').on('reload', () => {
16+
window.location.reload();
17+
});
18+
</script>
1519
</head>
1620

1721
<body>

0 commit comments

Comments
 (0)