Skip to content

Commit c6403e9

Browse files
committed
fix: attachment store
1 parent 1cb3b09 commit c6403e9

6 files changed

Lines changed: 216 additions & 168 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"vue-tsc": "^2.2.0"
3434
},
3535
"config": {
36-
"base": "/data/",
36+
"base": "http://192.168.1.1/.www/blog/data/",
3737
"post_dir": "post/",
3838
"page_dir": "page/",
3939
"static_dir": "static/",

src/App.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@
4747
<div class="__header" :hide="hide_main">
4848
<div class="container">
4949
<RouterLink class="title" :to="{ name: 'home' }">
50-
<img v-if="CONFIG.favicon" :src="get_file(CONFIG.favicon).href" :alt="CONFIG.title">
51-
{{ CONFIG.title }}
50+
<img v-if="CONFIG.favicon" :src="get_file(CONFIG.favicon).href" :alt="CONFIG.title"
51+
@error="e => (e.target as HTMLImageElement).hidden = true"
52+
>{{ CONFIG.title }}
5253
</RouterLink>
5354
<nav>
5455
<router-link to="/">首页</router-link>

src/admin/driver.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
import { config } from '../../package.json';
55
import { CONFIG } from '../main';
6-
import { exportIndex, Post } from '../utils/post';
6+
import { exportIndex, parseMd, Post } from '../utils/post';
77

88
class RemoteFile {
99
static __check_enabled() {
@@ -91,7 +91,10 @@ export namespace driver {
9191

9292
export async function update_post(post: Post, contents: string) {
9393
// precheck
94-
post.save(contents.substring(100));
94+
const html = await parseMd(contents.replace(/<!--.+?-->/g, ''));
95+
const dom = new DOMParser().parseFromString(html, 'text/html');
96+
const info = dom.body.innerText.replace(/\s+/g,'').trim();
97+
post.save(info.substring(0, 150));
9598
// write to file
9699
const content = `title: ${post.info.title}
97100
created: ${new Date(post.info.created).toDateString()}

0 commit comments

Comments
 (0)