This commit is contained in:
syuilo 2020-02-07 02:38:02 +09:00
parent e994233620
commit a696ccb0b4
5 changed files with 83 additions and 32 deletions

View file

@ -74,9 +74,17 @@ gulp.task('copy:client', () =>
.pipe(gulp.dest('./built/client/assets/')) .pipe(gulp.dest('./built/client/assets/'))
); );
gulp.task('copy:docs', () =>
gulp.src([
'./src/docs/**/*',
])
.pipe(gulp.dest('./built/client/assets/docs/'))
);
gulp.task('build:client', gulp.parallel( gulp.task('build:client', gulp.parallel(
'build:client:styles', 'build:client:styles',
'copy:client' 'copy:client',
'copy:docs'
)); ));
gulp.task('build', gulp.parallel( gulp.task('build', gulp.parallel(

View file

@ -179,6 +179,7 @@ export default Vue.extend({
return { return {
'p': this.post, 'p': this.post,
'n': this.post, 'n': this.post,
'h|/': this.help
}; };
}, },
@ -254,6 +255,10 @@ export default Vue.extend({
}, },
methods: { methods: {
help() {
this.$router.push('/docs/keyboard-shortcut');
},
back() { back() {
if (this.canBack) window.history.back(); if (this.canBack) window.history.back();
}, },

View file

@ -4,7 +4,7 @@
<portal to="title">{{ title }}</portal> <portal to="title">{{ title }}</portal>
<main class="_card"> <main class="_card">
<div class="_content"> <div class="_content">
<div v-html="body"/> <div v-html="body" class="qyqbqfal"></div>
</div> </div>
</main> </main>
</div> </div>
@ -14,8 +14,11 @@
import Vue from 'vue'; import Vue from 'vue';
import { faFileAlt } from '@fortawesome/free-solid-svg-icons' import { faFileAlt } from '@fortawesome/free-solid-svg-icons'
import MarkdownIt from 'markdown-it'; import MarkdownIt from 'markdown-it';
import { url, lang } from '../config';
const markdown = MarkdownIt(); const markdown = MarkdownIt({
html: true
});
export default Vue.extend({ export default Vue.extend({
metaInfo() { metaInfo() {
@ -24,12 +27,19 @@ export default Vue.extend({
}; };
}, },
components: { props: {
doc: {
type: String,
required: true
}
}, },
watch: { watch: {
markdown() { doc: {
this.updateText(); handler() {
this.fetchDoc();
},
immediate: true,
} }
}, },
@ -38,32 +48,23 @@ export default Vue.extend({
faFileAlt, faFileAlt,
title: '', title: '',
body: '', body: '',
markdown: `# ぽぺ markdown: '',
ぽぺ **ぽぺ** _ぽぺーーーーーっ_ \`ぽぺ\`
\`\`\`
export default class Pope extends PopeBase
{
public Pope() {
return 'ぽぺ';
}
}
\`\`\``,
} }
}, },
created() {
this.updateText()
},
methods: { methods: {
updateText() { fetchDoc() {
// markdown fetch(`${url}/assets/docs/${this.doc}.${lang}.md`).then(res => res.text()).then(md => {
const parsed = markdown.parse(this.markdown, {}); this.parse(md);
if (parsed.length === 0) });
return; },
const buf = [ ...parsed ] parse(md: string) {
// markdown
const parsed = markdown.parse(md, {});
if (parsed.length === 0) return;
const buf = [...parsed];
const headingTokens = []; const headingTokens = [];
let headingStart = 0; let headingStart = 0;
@ -81,7 +82,7 @@ export default class Pope extends PopeBase
} }
// body // body
const bodyTokens = [ ...parsed ] const bodyTokens = [...parsed];
bodyTokens.splice(headingStart, headingTokens.length + 2); bodyTokens.splice(headingStart, headingTokens.length + 2);
// //
@ -91,3 +92,43 @@ export default class Pope extends PopeBase
} }
}); });
</script> </script>
<style lang="scss" scoped>
.qyqbqfal {
> *:first-child {
margin-top: 0;
}
> *:last-child {
margin-bottom: 0;
}
::v-deep h2 {
font-size: 1.25em;
padding: 0 0 0.5em 0;
border-bottom: solid 1px var(--divider);
}
::v-deep table {
width: 100%;
max-width: 100%;
overflow: auto;
}
::v-deep kbd.group {
display: inline-block;
padding: 2px;
border: 1px solid var(--divider);
border-radius: 4px;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}
::v-deep kbd.key {
display: inline-block;
padding: 6px 8px;
border: solid 1px var(--divider);
border-radius: 4px;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}
}
</style>

View file

@ -21,7 +21,7 @@ export const router = new VueRouter({
{ path: '/announcements', component: page('announcements') }, { path: '/announcements', component: page('announcements') },
{ path: '/about', component: page('about') }, { path: '/about', component: page('about') },
{ path: '/featured', component: page('featured') }, { path: '/featured', component: page('featured') },
{ path: '/document', component: page('document') }, { path: '/docs/:doc', component: page('doc'), props: true },
{ path: '/explore', component: page('explore') }, { path: '/explore', component: page('explore') },
{ path: '/explore/tags/:tag', props: true, component: page('explore') }, { path: '/explore/tags/:tag', props: true, component: page('explore') },
{ path: '/search', component: page('search') }, { path: '/search', component: page('search') },

View file

@ -1,3 +0,0 @@
# About Misskey
Misskey is a mini blog SNS.