Skip to content

Commit

Permalink
Pass articletext to metadescription
Browse files Browse the repository at this point in the history
  • Loading branch information
rauboti committed Oct 16, 2024
1 parent 6527a03 commit d446804
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ interface Props {
contexts?: TaxonomyContext[];
}

const getTextFromHTML = (html: string) => {
const parser = new DOMParser();
const doc = parser.parseFromString(html, "text/html");
return doc.body.textContent || "";
};

const LearningResourcePanels = ({
article,
articleHistory,
Expand All @@ -58,6 +64,11 @@ const LearningResourcePanels = ({
);
const copyrightFields = useMemo<FlatArticleKeys[]>(() => ["copyright"], []);

const articleText = useMemo(() => {
if (!article?.content) return " ";
return getTextFromHTML(article.content.content);
}, [article?.content]);

return (
<FormAccordionsWithComments
defaultOpen={defaultOpen}
Expand Down Expand Up @@ -116,7 +127,7 @@ const LearningResourcePanels = ({
title={t("form.metadataSection")}
hasError={!!(errors.metaDescription || errors.metaImageAlt || errors.tags)}
>
<MetaDataField articleLanguage={articleLanguage} />
<MetaDataField articleContent={articleText} articleLanguage={articleLanguage} />

Check failure on line 130 in src/containers/ArticlePage/LearningResourcePage/components/LearningResourcePanels.tsx

View workflow job for this annotation

GitHub Actions / Unit tests

Type '{ articleContent: string; articleLanguage: string; }' is not assignable to type 'IntrinsicAttributes & Props'.

Check failure on line 130 in src/containers/ArticlePage/LearningResourcePage/components/LearningResourcePanels.tsx

View workflow job for this annotation

GitHub Actions / Unit tests

Type '{ articleContent: string; articleLanguage: string; }' is not assignable to type 'IntrinsicAttributes & Props'.
</FormAccordion>
<FormAccordion id={"learning-resource-grepCodes"} title={t("form.name.grepCodes")} hasError={!!errors.grepCodes}>
<GrepCodesField />
Expand Down

0 comments on commit d446804

Please sign in to comment.