[head] add missing descriptions

This commit is contained in:
Andrea Vos 2021-12-23 22:02:27 +01:00
parent 36e9f87d41
commit 00b1447600
8 changed files with 20 additions and 1 deletions

View File

@ -34,6 +34,7 @@
head() {
return head({
title: this.title,
description: this.intro,
banner: this.img,
});
},

View File

@ -267,6 +267,7 @@
head() {
return head({
title: this.$t('census.headerLong'),
description: this.$t('census.description')[0],
});
},
};

View File

@ -221,6 +221,7 @@
head() {
return head({
title: `@${this.username}`,
description: this.profile ? this.profile.description : null,
banner: `api/banner/@${this.username}.png`,
});
},

View File

@ -139,6 +139,11 @@
head() {
return this.selectedPronoun ? head({
title: `${this.$t('pronouns.intro')}: ${this.selectedPronoun.name(this.glue)}`,
description: [
this.$t('pronouns.examples', {}, false),
this.$t('pronouns.grammarTable', {}, false),
this.$t('sources.headerLong', {}, false),
].filter(x => !!x).join(', '),
banner: `api/banner${this.$route.path.replace(/\/$/, '')}.png`,
}) : {};
},

View File

@ -175,6 +175,7 @@
head() {
return head({
title: this.$t('sources.headerLonger'),
description: this.$t('sources.subheader'),
});
},
methods: {

View File

@ -127,6 +127,7 @@
head() {
return head({
title: this.$t('contact.team.name'),
description: this.$t('contact.team.description'),
});
},
async asyncData({app}) {

View File

@ -32,6 +32,7 @@ export const head = ({title, description, banner}) => {
if (description) {
description = clearLinkedText(description);
description = description.split(' ').slice(0, 24).join(' ') + '…';
meta.meta.push({ hid: 'description', name: 'description', content: description });
meta.meta.push({ hid: 'og:description', property: 'og:description', content: description });
meta.meta.push({ hid: 'twitter:description', property: 'twitter:description', content: description });
@ -207,6 +208,8 @@ export const clearLinkedText = (text, quotes = true) => {
text = text.replace(/[„”"']/g, '');
}
text = text.replace(/\s+/g, ' ');
return text;
}

View File

@ -13,11 +13,17 @@ export default async function parseMarkdown(markdown) {
const title = titleMatch ? titleMatch[1] : null;
const imgMatch = content.match('<img src="([^"]+)"[^>]*>');
const img = imgMatch ? imgMatch[1] : null;
let intro = [];
for (let introMatch of content.matchAll('<p[^>]*>([^<]+)</p>')) {
const p = introMatch[1].replace(/(<([^>]+)>)/ig, '').replace(/\s+/g, ' ');
intro = [...intro, ...p.split(' ')];
}
return {
content,
title,
img,
intro: intro.length ? intro.slice(0, 24).join(' ') : null,
content,
}
} catch {
return {