Explorar o código

Replace @username with link to username

sbkwgh %!s(int64=8) %!d(string=hai) anos
pai
achega
d06fe0ce22
Modificáronse 1 ficheiros con 5 adicións e 1 borrados
  1. 5 1
      src/components/InputEditorPreview.vue

+ 5 - 1
src/components/InputEditorPreview.vue

@@ -22,7 +22,11 @@
 		props: ['value'],
 		computed: {
 			HTML () {
-				return Marked(this.value);
+				let replacedMd = this.value.replace(/@[^\s]+/g, match => {
+					return `[${match}](/user/${match.slice(1)})`
+				})
+
+				return Marked(replacedMd);
 			}
 		}
 	}