diff --git a/package.json b/package.json index 3f3b2f0a..9d8c444b 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,12 @@ "vercel-build": "astro build" }, "dependencies": { + "@aws-sdk/client-s3": "^3.216.0", + "@aws-sdk/lib-storage": "^3.223.0", "@connorskees/grass": "^0.12.0", + "@solid-primitives/share": "^2.0.1", + "astro-seo-meta": "^2.0.0", + "formidable": "^2.1.1", "mailgun.js": "^8.0.6" }, "devDependencies": { diff --git a/src/components/Article/FullArticle.tsx b/src/components/Article/FullArticle.tsx index cbf023f2..9b5093a2 100644 --- a/src/components/Article/FullArticle.tsx +++ b/src/components/Article/FullArticle.tsx @@ -6,7 +6,7 @@ import { createMemo, For, Match, onMount, Show, Switch } from 'solid-js' import type { Author, Shout } from '../../graphql/types.gen' import { t } from '../../utils/intl' import MD from './MD' -import { SharePopup } from './SharePopup' +import { getShareUrl, SharePopup } from './SharePopup' import { getDescription } from '../../utils/meta' import stylesHeader from '../Nav/Header.module.scss' import styles from '../../styles/Article.module.scss' @@ -174,7 +174,7 @@ export const FullArticle = (props: ArticleProps) => { title={props.article.title} description={getDescription(props.article.body)} imageUrl={props.article.cover} - shareUrl={location.href} + shareUrl={getShareUrl()} containerCssClass={stylesHeader.control} trigger={} /> diff --git a/src/components/Article/SharePopup.tsx b/src/components/Article/SharePopup.tsx index 7b6f6a81..155a6dbe 100644 --- a/src/components/Article/SharePopup.tsx +++ b/src/components/Article/SharePopup.tsx @@ -1,7 +1,6 @@ import { Icon } from '../_shared/Icon' import { t } from '../../utils/intl' import { createSocialShare, TWITTER, VK, FACEBOOK, TELEGRAM } from '@solid-primitives/share' - import styles from '../_shared/Popup/Popup.module.scss' import type { PopupProps } from '../_shared/Popup' import { Popup } from '../_shared/Popup' @@ -13,6 +12,12 @@ type SharePopupProps = { description: string } & Omit +export const getShareUrl = (params: { pathname?: string } = {}) => { + if (typeof location === 'undefined') return '' + const pathname = params.pathname ?? location.pathname + return location.origin + pathname +} + export const SharePopup = (props: SharePopupProps) => { const [share] = createSocialShare(() => ({ title: props.title, @@ -20,7 +25,7 @@ export const SharePopup = (props: SharePopupProps) => { description: props.description })) const copyLink = async () => { - await navigator.clipboard.writeText(window.location.href) + await navigator.clipboard.writeText(props.shareUrl) } return ( diff --git a/src/components/Feed/Card.tsx b/src/components/Feed/Card.tsx index 76745344..44d9d88a 100644 --- a/src/components/Feed/Card.tsx +++ b/src/components/Feed/Card.tsx @@ -9,7 +9,7 @@ import { locale } from '../../stores/ui' import { clsx } from 'clsx' import { CardTopic } from './CardTopic' import { RatingControl } from '../Article/RatingControl' -import { SharePopup } from '../Article/SharePopup' +import { getShareUrl, SharePopup } from '../Article/SharePopup' import stylesHeader from '../Nav/Header.module.scss' import { getDescription } from '../../utils/meta' @@ -73,12 +73,6 @@ export const ArticleCard = (props: ArticleCardProps) => { const { cover, layout, slug, authors, stat } = props.article - const [url, setUrl] = createSignal(null) - onMount(() => { - const composeUrl = new URL(location.href) - setUrl(composeUrl.origin) - }) - return (
{ title={props.article['title']} description={getDescription(props.article['body'])} imageUrl={props.article['cover']} - shareUrl={`${url()}/${slug}`} + shareUrl={getShareUrl({ pathname: `/${slug}` })} trigger={