Skip to content

Commit

Permalink
Make number of <LinkPreview> description lines configurable (deluci…
Browse files Browse the repository at this point in the history
…s#119)

Co-authored-by: Chris Swithinbank <[email protected]>
  • Loading branch information
jasikpark and delucis authored May 4, 2024
1 parent 2fddf59 commit 732a6cf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/wet-chairs-cry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astro-community/astro-embed-link-preview': minor
---

Make the number of lines displayed in the `<LinkPreview>` description configurable.
2 changes: 2 additions & 0 deletions docs/src/content/docs/components/link-preview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ The `<LinkPreview>` component supports the following API for controlling its sty
--link-preview-padding-block: 0.5em;
/** Round the corners of the link preview card. */
--link-preview-corners: 0.5em;
/** Set the maximum number of lines in the description to display. */
--link-preview-description-lines: 3;
}
```

Expand Down
5 changes: 4 additions & 1 deletion packages/astro-embed-link-preview/LinkPreview.astro
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const domain = meta?.url ? new URL(meta.url).hostname.replace('www.', '') : '';
--lp-pad-x: var(--link-preview-padding-inline, 0);
--lp-pad-y: var(--link-preview-padding-block, 0.5em);
--lp-corners: var(--link-preview-corners, 0);
--lp-desc-lines: var(--link-preview-description-lines, 1);

position: relative;
width: var(--lp-width);
Expand All @@ -86,7 +87,9 @@ const domain = meta?.url ? new URL(meta.url).hostname.replace('www.', '') : '';
}

.link-preview__description {
white-space: nowrap;
display: -webkit-box;
-webkit-line-clamp: var(--lp-desc-lines);
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
}
Expand Down

0 comments on commit 732a6cf

Please sign in to comment.