From 17d86a28325b9b841668f52a011e15f485bdf054 Mon Sep 17 00:00:00 2001 From: Eliot Berriot Date: Thu, 20 Dec 2018 00:47:05 +0100 Subject: [PATCH] Lazy-load markdown renderer on about page for smaller bundle size --- front/src/components/About.vue | 15 ++- front/src/components/Sidebar.vue | 2 - front/src/components/discussion/Comment.vue | 53 -------- front/src/components/requests/Card.vue | 61 --------- front/src/components/requests/Form.vue | 127 ------------------ front/src/filters.js | 8 -- .../tests/unit/specs/filters/filters.spec.js | 9 +- 7 files changed, 13 insertions(+), 262 deletions(-) delete mode 100644 front/src/components/discussion/Comment.vue delete mode 100644 front/src/components/requests/Card.vue delete mode 100644 front/src/components/requests/Form.vue diff --git a/front/src/components/About.vue b/front/src/components/About.vue index 16c58b173..90cfb7682 100644 --- a/front/src/components/About.vue +++ b/front/src/components/About.vue @@ -27,9 +27,9 @@

{{ instance.short_description.value }}

+ v-html="markdown.makeHtml(instance.long_description.value)">
@@ -43,8 +43,17 @@ export default { components: { Stats }, - created() { + data () { + return { + markdown: null + } + }, + created () { this.$store.dispatch("instance/fetchSettings") + let self = this + import('showdown').then(module => { + self.markdown = new module.default.Converter() + }) }, computed: { ...mapState({ diff --git a/front/src/components/Sidebar.vue b/front/src/components/Sidebar.vue index d8029b1bd..5fc0458c9 100644 --- a/front/src/components/Sidebar.vue +++ b/front/src/components/Sidebar.vue @@ -206,10 +206,8 @@ export default { labels() { let mainMenu = this.$gettext("Main menu") let selectTrack = this.$gettext("Play this track") - let pendingRequests = this.$gettext("Pending import requests") let pendingFollows = this.$gettext("Pending follow requests") return { - pendingRequests, pendingFollows, mainMenu, selectTrack diff --git a/front/src/components/discussion/Comment.vue b/front/src/components/discussion/Comment.vue deleted file mode 100644 index ee9ce9b1f..000000000 --- a/front/src/components/discussion/Comment.vue +++ /dev/null @@ -1,53 +0,0 @@ - - diff --git a/front/src/components/requests/Card.vue b/front/src/components/requests/Card.vue deleted file mode 100644 index 36bbc944e..000000000 --- a/front/src/components/requests/Card.vue +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - diff --git a/front/src/components/requests/Form.vue b/front/src/components/requests/Form.vue deleted file mode 100644 index 667bd5f5a..000000000 --- a/front/src/components/requests/Form.vue +++ /dev/null @@ -1,127 +0,0 @@ - - - - - diff --git a/front/src/filters.js b/front/src/filters.js index 878b3c9f2..97dd2d5ee 100644 --- a/front/src/filters.js +++ b/front/src/filters.js @@ -1,7 +1,6 @@ import Vue from 'vue' import moment from 'moment' -import showdown from 'showdown' export function truncate (str, max, ellipsis) { max = max || 100 @@ -14,13 +13,6 @@ export function truncate (str, max, ellipsis) { Vue.filter('truncate', truncate) -export function markdown (str) { - const converter = new showdown.Converter() - return converter.makeHtml(str) -} - -Vue.filter('markdown', markdown) - export function ago (date) { const m = moment(date) return m.fromNow() diff --git a/front/tests/unit/specs/filters/filters.spec.js b/front/tests/unit/specs/filters/filters.spec.js index 8ee6b4b71..1464e5c97 100644 --- a/front/tests/unit/specs/filters/filters.spec.js +++ b/front/tests/unit/specs/filters/filters.spec.js @@ -1,6 +1,6 @@ import {expect} from 'chai' -import {truncate, markdown, ago, capitalize, year} from '@/filters' +import {truncate, ago, capitalize, year} from '@/filters' describe('filters', () => { describe('truncate', () => { @@ -20,13 +20,6 @@ describe('filters', () => { expect(output).to.equal('Hello pouet') }) }) - describe('markdown', () => { - it('renders markdown', () => { - const input = 'Hello world' - let output = markdown(input) - expect(output).to.equal('

Hello world

') - }) - }) describe('ago', () => { it('works', () => { const input = new Date()