it-tools/components/Memo.vue

139 lines
2.6 KiB
Vue
Raw Normal View History

2021-03-14 23:37:57 +01:00
<template>
<div class="memo">
2021-08-02 21:35:12 +02:00
<v-row justify="center">
<v-col lg="6" md="9" sm="9" cols="12" class="mb-16">
<ToolHeader :config="$toolConfig" />
<v-card>
<v-card-text class="pa-10">
<div class="memo-content" v-html="content" />
2021-03-14 23:37:57 +01:00
</v-card-text>
</v-card>
</v-col>
2021-08-02 21:35:12 +02:00
<v-col lg="2" md="3" sm="3" cols="12">
<div class="toc">
<div class="toc-title">
On this page
</div>
<div class="toc-content" v-html="toc" />
</div>
</v-col>
2021-03-14 23:37:57 +01:00
</v-row>
</div>
</template>
<script lang="ts">
import {Component} from 'nuxt-property-decorator'
import Tool from './Tool.vue'
import {CopyableMixin} from '~/mixins/copyable.mixin'
import ToolHeader from '~/components/ToolHeader.vue'
2021-08-02 21:35:12 +02:00
import {toc} from '~/utils/md-toc'
2021-03-14 23:37:57 +01:00
@Component({
mixins: [CopyableMixin],
components: {ToolHeader}
})
export default class Memo extends Tool {
2021-08-02 21:35:12 +02:00
fetchOnServer = true
content: string = ''
toc: string = ''
fetch() {
// @ts-ignore
const content: string = this.$options.__memo.trim()
this.toc = this.$md.render(toc(content).join('\n'))
this.content = this.$md.render(content)
}
2021-03-14 23:37:57 +01:00
}
</script>
2021-08-02 21:35:12 +02:00
<style lang="less" scoped>
2021-03-14 23:37:57 +01:00
.memo {
2021-08-02 21:35:12 +02:00
::v-deep {
.memo-content {
text-align: justify;
2021-03-14 23:37:57 +01:00
2021-08-02 21:35:12 +02:00
h2 {
font-weight: 400;
font-size: 25px;
margin: 0 0 20px 0;
padding-bottom: 10px;
border-bottom: 1px solid rgba(255, 255, 255, 0.26);
color: #ffffff;
2021-03-14 23:37:57 +01:00
2021-08-02 21:35:12 +02:00
&:not(:first-child){
margin-top: 50px;
}
}
2021-03-14 23:37:57 +01:00
2021-08-02 21:35:12 +02:00
h3 {
font-weight: 400;
margin-top: 20px;
margin-bottom: 10px;
}
2021-03-14 23:37:57 +01:00
pre {
2021-08-02 21:35:12 +02:00
width: 100%;
2021-03-14 23:37:57 +01:00
overflow-x: auto;
2021-08-02 21:35:12 +02:00
code {
display: block;
padding: 15px;
}
2021-03-14 23:37:57 +01:00
}
2021-08-02 21:35:12 +02:00
}
}
.toc {
margin-top: 140px;
.toc-title {
font-weight: 600;
margin-bottom: 10px;
}
::v-deep {
.toc-content {
a {
color: #ffffff;
text-decoration: none;
opacity: 0.7;
transition: all 0.3s ease;
font-weight: 400;
&:hover {
opacity: 1;
color: var(--v-primary-base);
}
}
ul {
list-style-type: none;
padding-left: 10px;
li {
padding: 5px 0;
}
}
&>ul {
padding-left: 0;
&>li {
border-top: 1px dashed rgba(238, 238, 238, 0.38);
padding: 5px 0 5px 10px;
2021-03-14 23:37:57 +01:00
2021-08-02 21:35:12 +02:00
&>a {
font-weight: 600 !important;
}
}
2021-03-14 23:37:57 +01:00
}
}
}
}
}
</style>