+
{config.logo !== '' ? (

) : (
@@ -52,28 +54,32 @@ const Card: React.FC
= config => {
)}
{languageIcon && (
<>
- +
+ +
>
)}
-
-
+
+
{config.owner?.state ? `${config.owner.value}/` : ''}
- {config.name}
+ {config.name}
{config.description?.state && (
- {config.description.value}
+
+ {config.description.value}
+
)}
{(config.stargazers?.state ||
config.forks?.state ||
config.issues?.state ||
config.pulls?.state) && (
-
+
{config.stargazers?.state && (
figure {
box-shadow: 0px 1px 5px 0px rgba(0, 0, 0, 0.25);
border-radius: 5px;
}
@@ -35,7 +35,7 @@
height: 240px;
}
- .card-wrapper {
+ .preview-card-wrapper > figure {
transform: scale(0.75);
transform-origin: top left;
}
@@ -47,7 +47,7 @@
height: 200px;
}
- .card-wrapper {
+ .preview-card-wrapper > figure {
transform: scale(0.625);
transform-origin: top left;
}
@@ -67,7 +67,7 @@
height: 160px;
}
- .card-wrapper {
+ .preview-card-wrapper > figure {
transform: scale(0.5);
transform-origin: top left;
}
diff --git a/src/components/preview/preview.tsx b/src/components/preview/preview.tsx
index 2cbe38a3..9cccd389 100644
--- a/src/components/preview/preview.tsx
+++ b/src/components/preview/preview.tsx
@@ -1,4 +1,5 @@
import React, { useContext } from 'react'
+import { useRouter } from 'next/router'
import { toClipboard } from 'copee'
import { Space, Button, notification } from 'antd'
import { DownloadOutlined, CopyOutlined } from '@ant-design/icons'
@@ -7,17 +8,24 @@ import ConfigContext from '../../contexts/ConfigContext'
import Card from './card'
-import './preview.css'
+import styles from './preview.module.css'
const Preview: React.FC = () => {
+ const router = useRouter() || {}
const { config } = useContext(ConfigContext)
const fileType = config.fileType.toLowerCase()
- const screenshotImageURL = new URL(window.location.href)
- screenshotImageURL.pathname += `/${fileType}`
- const screenshotImageUrl = screenshotImageURL.href
+ const relativeImageUrl = (router.asPath || '').replace(
+ /([?$])/,
+ `/${fileType}$1`
+ )
+
+ const getImageUrl = (): string => {
+ return `${window.location.protocol}//${window.location.host}${relativeImageUrl}`
+ }
const copyImageUrl = () => {
+ const screenshotImageUrl = getImageUrl()
const success = toClipboard(screenshotImageUrl)
if (success) {
notification.success({
@@ -30,6 +38,7 @@ const Preview: React.FC = () => {
}
const copyMarkdown = () => {
+ const screenshotImageUrl = getImageUrl()
const ogTag = ``
const success = toClipboard(ogTag)
if (success) {
@@ -41,6 +50,7 @@ const Preview: React.FC = () => {
}
const copyOpenGraphTag = () => {
+ const screenshotImageUrl = getImageUrl()
const ogTag = ``
const success = toClipboard(ogTag)
if (success) {
@@ -52,44 +62,44 @@ const Preview: React.FC = () => {
}
return (
-
-
+
+
-
+
}
type="primary"
- href={screenshotImageUrl}
- download={`${window.location.pathname
+ href={relativeImageUrl}
+ download={`${(router.pathname || '')
.replace(/\//g, ' ')
.trim()
.replace(/\s/g, '-')}.${fileType}`}>
Download
}
type="default"
onClick={copyImageUrl}>
Image url
}
type="default"
onClick={copyMarkdown}>
Markdown
}
type="default"
onClick={copyOpenGraphTag}>
diff --git a/src/components/repo/__snapshots__/repo.test.tsx.snap b/src/components/repo/__snapshots__/repo.test.tsx.snap
index 86978818..cd00df76 100644
--- a/src/components/repo/__snapshots__/repo.test.tsx.snap
+++ b/src/components/repo/__snapshots__/repo.test.tsx.snap
@@ -2,10 +2,10 @@
exports[`Repo renders 1`] = `