Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: create markdown util library #2358

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions packages/portal/src/components/DS4CH/DS4CHLandingHero.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<!-- eslint-disable vue/no-v-html -->
<div
class="hero-content-text-block"
v-html="parseMarkdownHtml(`# ${headline}\n${text}`)"
v-html="parseMarkdown(`# ${headline}\n${text}`)"
/>
<!-- eslint-enable vue/no-v-html -->
<SmartLink
Expand Down Expand Up @@ -42,7 +42,7 @@

<script>
import SmartLink from '@/components/generic/SmartLink';
import parseMarkdownHtmlMixin from '@/mixins/parseMarkdownHtml';
import parseMarkdown from '@/utils/markdown/parse.js';

const CSS_VARS_PRESETS = {
small: { w: 576, h: 896, fit: 'fill', q: 100, f: 'right' },
Expand All @@ -63,8 +63,6 @@
SmartLink
},

mixins: [parseMarkdownHtmlMixin],

props: {
/**
* H1 title to display in the hero.
Expand Down Expand Up @@ -106,6 +104,10 @@
CSS_VARS_PRESETS
)
};
},

methods: {
parseMarkdown
}
};
</script>
Expand Down
5 changes: 2 additions & 3 deletions packages/portal/src/components/content/ContentCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
import ClientOnly from 'vue-client-only';
import SmartLink from '../generic/SmartLink';
import langAttributeMixin from '@/mixins/langAttribute';
import stripMarkdownMixin from '@/mixins/stripMarkdown';
import stripMarkdown from '@/utils/markdown/strip.js';
import truncateMixin from '@/mixins/truncate';
import { langMapValueForLocale } from '@europeana/i18n';

Expand All @@ -139,7 +139,6 @@

mixins: [
langAttributeMixin,
stripMarkdownMixin,
truncateMixin
],

Expand Down Expand Up @@ -426,7 +425,7 @@
limited.push('…');
}
const joined = limited.join('; ');
const stripped = this.stripMarkdown(joined);
const stripped = stripMarkdown(joined);
return this.truncate(stripped, 255);
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<!-- eslint-disable vue/no-v-html -->
<div
class="primary-cta-rich-text text-left"
v-html="parseMarkdownHtml(text)"
v-html="parseMarkdown(text)"
/>
<!-- eslint-enable vue/no-v-html -->
<SmartLink
Expand All @@ -26,7 +26,7 @@

<script>
import SmartLink from '../generic/SmartLink';
import parseMarkdownHtmlMixin from '@/mixins/parseMarkdownHtml';
import parseMarkdown from '@/utils/markdown/parse.js';

export default {
name: 'ContentPrimaryCallToAction',
Expand All @@ -35,8 +35,6 @@
SmartLink
},

mixins: [parseMarkdownHtmlMixin],

props: {
title: {
type: String,
Expand All @@ -54,6 +52,10 @@
type: String,
default: 'btn-primary'
}
},

methods: {
parseMarkdown
}
};
</script>
Expand Down
10 changes: 6 additions & 4 deletions packages/portal/src/components/landing/LandingEmbed.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<div
v-if="text"
class="text mb-3"
v-html="parseMarkdownHtml(text)"
v-html="parseMarkdown(text)"
/>
<!-- eslint-enable vue/no-v-html -->
</b-col>
Expand All @@ -46,7 +46,7 @@
</template>

<script>
import parseMarkdownHtmlMixin from '@/mixins/parseMarkdownHtml';
import parseMarkdown from '@/utils/markdown/parse.js';
import EmbedHTML from '@/components/embed/EmbedHTML';

export default {
Expand All @@ -57,8 +57,6 @@
SmartLink: () => import('@/components/generic/SmartLink')
},

mixins: [parseMarkdownHtmlMixin],

props: {
/**
* Title
Expand Down Expand Up @@ -103,6 +101,10 @@
'bg-color-highlight': this.backgroundImage?.profile?.background === 'highlight'
}
};
},

methods: {
parseMarkdown
}
};
</script>
Expand Down
10 changes: 6 additions & 4 deletions packages/portal/src/components/landing/LandingHero.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<header class="hero-content">
<!-- eslint-disable vue/no-v-html -->
<div
v-html="parseMarkdownHtml(`# ${headline}\n${text}`)"
v-html="parseMarkdown(`# ${headline}\n${text}`)"
/>
<!-- eslint-enable vue/no-v-html -->
<SmartLink
Expand Down Expand Up @@ -40,7 +40,7 @@
<script>
import ImageWithAttribution from '@/components/image/ImageWithAttribution';
import SmartLink from '@/components/generic/SmartLink';
import parseMarkdownHtmlMixin from '@/mixins/parseMarkdownHtml';
import parseMarkdown from '@/utils/markdown/parse.js';

export default {
name: 'LandingHero',
Expand All @@ -50,8 +50,6 @@
SmartLink
},

mixins: [parseMarkdownHtmlMixin],

props: {
/**
* H1 title to display in the hero.
Expand Down Expand Up @@ -109,6 +107,10 @@
isSVG() {
return this.heroImage?.image?.contentType === 'image/svg+xml';
}
},

methods: {
parseMarkdown
}
};
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<div
v-if="text"
class="text mb-3"
v-html="parseMarkdownHtml(text)"
v-html="parseMarkdown(text)"
/>
<!-- eslint-enable vue/no-v-html -->
</b-col>
Expand Down Expand Up @@ -66,7 +66,7 @@

<script>
import ImageOptimised from '@/components/image/ImageOptimised';
import parseMarkdownHtmlMixin from '@/mixins/parseMarkdownHtml';
import parseMarkdown from '@/utils/markdown/parse.js';
import swiperMixin from '@/mixins/swiper';
import { Grid, Keyboard, Lazy, Navigation, Pagination } from 'swiper';

Expand All @@ -78,7 +78,7 @@
SmartLink: () => import('@/components/generic/SmartLink')
},

mixins: [parseMarkdownHtmlMixin, swiperMixin],
mixins: [swiperMixin],

props: {
/**
Expand Down Expand Up @@ -167,6 +167,10 @@
}
}
};
},

methods: {
parseMarkdown
}
};
</script>
Expand Down
11 changes: 7 additions & 4 deletions packages/portal/src/components/landing/LandingImageCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<!-- eslint-disable vue/no-v-html -->
<div
class="text"
v-html="parseMarkdownHtml(card.text)"
v-html="parseMarkdown(card.text)"
/>
<!-- eslint-enable vue/no-v-html -->
<SmartLink
Expand All @@ -54,7 +54,7 @@

<script>
import parityMixin from '@/mixins/parity.js';
import parseMarkdownHtmlMixin from '@/mixins/parseMarkdownHtml';
import parseMarkdown from '@/utils/markdown/parse.js';

const SRCSET_PRESETS = {
small: { w: 512, h: 342, fit: 'fill' },
Expand Down Expand Up @@ -102,8 +102,7 @@
},

mixins: [
parityMixin,
parseMarkdownHtmlMixin
parityMixin
],

props: {
Expand Down Expand Up @@ -143,6 +142,10 @@

mounted() {
this.$nextTick(() => this.markParity('image-card', 'imagecard'));
},

methods: {
parseMarkdown
}
};
</script>
Expand Down
10 changes: 6 additions & 4 deletions packages/portal/src/components/landing/LandingImageCardGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<div
v-if="text"
class="mb-3"
v-html="parseMarkdownHtml(text)"
v-html="parseMarkdown(text)"
/>
<!-- eslint-enable vue/no-v-html -->
</b-col>
Expand All @@ -35,16 +35,14 @@
</template>

<script>
import parseMarkdownHtmlMixin from '@/mixins/parseMarkdownHtml';
import parseMarkdown from '@/utils/markdown/parse.js';

export default {
name: 'LandingImageCardGroup',
components: {
LandingImageCard: () => import('@/components/landing/LandingImageCard')
},

mixins: [parseMarkdownHtmlMixin],

props: {
/**
* H2 title to display above the image cards
Expand Down Expand Up @@ -82,6 +80,10 @@
'bg-color-highlight': this.backgroundImage?.profile?.background === 'highlight'
}
};
},

methods: {
parseMarkdown
}
};
</script>
Expand Down
10 changes: 6 additions & 4 deletions packages/portal/src/components/landing/LandingInfoCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
class="text"
:class="{ 'mb-3': card.link }"
data-qa="landing info card text"
v-html="parseMarkdownHtml(card.text)"
v-html="parseMarkdown(card.text)"
/>
<!-- eslint-enable vue/no-v-html -->
<SmartLink
Expand All @@ -55,7 +55,7 @@
</template>

<script>
import parseMarkdownHtmlMixin from '@/mixins/parseMarkdownHtml';
import parseMarkdown from '@/utils/markdown/parse.js';

export default {
name: 'LandingInfoCard',
Expand All @@ -65,8 +65,6 @@
SmartLink: () => import('@/components/generic/SmartLink')
},

mixins: [parseMarkdownHtmlMixin],

props: {
/**
* Info card data
Expand All @@ -82,6 +80,10 @@
type: Boolean,
default: false
}
},

methods: {
parseMarkdown
}
};
</script>
Expand Down
10 changes: 6 additions & 4 deletions packages/portal/src/components/landing/LandingInfoCardGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<div
v-if="text"
class="text mb-3"
v-html="parseMarkdownHtml(text)"
v-html="parseMarkdown(text)"
/>
<!-- eslint-enable vue/no-v-html -->
</b-col>
Expand Down Expand Up @@ -44,7 +44,7 @@
</template>

<script>
import parseMarkdownHtmlMixin from '@/mixins/parseMarkdownHtml';
import parseMarkdown from '@/utils/markdown/parse.js';

export default {
name: 'LandingInfoCardGroup',
Expand All @@ -54,8 +54,6 @@
SmartLink: () => import('@/components/generic/SmartLink')
},

mixins: [parseMarkdownHtmlMixin],

props: {
/**
* Heading title to display above the info cards
Expand Down Expand Up @@ -104,6 +102,10 @@
threeColCardsLayout: this.infoCards.length % 3 === 0,
twoColCardsLayout: this.infoCards.length % 3 !== 0
};
},

methods: {
parseMarkdown
}
};
</script>
Expand Down
Loading
Loading