forked from simwrapper/simwrapper
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Dashboards learned "text" block type, for including readme content
type: text props: file: my-readme.md Will now display a rendered markdown text file.
- Loading branch information
Showing
3 changed files
with
76 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<template lang="pug"> | ||
.curate-content.markdown( | ||
v-if="readmeContent" | ||
v-html="readmeContent" | ||
) | ||
|
||
</template> | ||
|
||
<script lang="ts"> | ||
import { Vue, Component, Watch, Prop } from 'vue-property-decorator' | ||
import markdown from 'markdown-it' | ||
import { FileSystemConfig } from '@/Globals' | ||
import HTTPFileSystem from '@/js/HTTPFileSystem' | ||
const mdRenderer = new markdown({ | ||
html: true, | ||
linkify: true, | ||
typographer: true, | ||
}) | ||
@Component({}) | ||
export default class VueComponent extends Vue { | ||
@Prop({ required: true }) fileSystemConfig!: FileSystemConfig | ||
@Prop({ required: true }) subfolder!: string | ||
@Prop({ required: true }) files!: string[] | ||
@Prop({ required: true }) config!: any | ||
private readmeContent = '' | ||
private async mounted() { | ||
try { | ||
const fileApi = new HTTPFileSystem(this.fileSystemConfig) | ||
const filename = `${this.subfolder}/${this.config.file}` | ||
const text = await fileApi.getFileText(filename) | ||
this.readmeContent = mdRenderer.render(text) | ||
} catch (e: any) { | ||
console.log({ e }) | ||
let error = '' + e | ||
if (e.statusText) error = e.statusText | ||
this.readmeContent = `${this.config.file}: ${error}` | ||
} | ||
this.$emit('isLoaded') | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped lang="scss"> | ||
@import '@/styles.scss'; | ||
.dash-element { | ||
position: absolute; | ||
top: 0; | ||
bottom: 0; | ||
left: 0; | ||
right: 0; | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
@media only screen and (max-width: 640px) { | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters