Skip to content

Commit 163da1d

Browse files
authored
Merge pull request #55 from zoobestik/gif-player
feat; add gif player
2 parents c85f2d0 + 0b12426 commit 163da1d

File tree

5 files changed

+53
-1
lines changed

5 files changed

+53
-1
lines changed

gatsby-config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export default {
2828
],
2929
},
3030
gatsbyRemarkPlugins: [
31+
"gatsby-remark-copy-linked-files",
3132
{
3233
resolve: `gatsby-remark-images`,
3334
options: {

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@
2424
"@rescui/typography": "^0.8.3",
2525
"@rescui/ui-contexts": "^0.3.5",
2626
"classnames": "^2.3.2",
27+
"gatsby-remark-copy-linked-files": "^6.13.0",
2728
"gatsby-remark-images": "^7.8.0",
2829
"postcss-each": "^1.1.0",
2930
"postcss-mixins": "^9.0.4",
3031
"postcss-preset-env": "^8.1.0",
3132
"react": "^18.2.0",
3233
"react-dom": "^18.2.0",
34+
"react-gif-player": "^0.4.2",
3335
"react-helmet": "^6.1.0",
3436
"react-modal": "^3.16.1",
3537
"react-outside-click-handler": "^1.3.0",
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@import '~react-gif-player/dist/gifplayer.min.css';
2+
3+
.gif_player, .gif_player .play_button {
4+
font-family: inherit;
5+
}

src/components/Markdown/index.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ import {createContext, ReactNode, useContext} from "react";
22
import cn from "classnames";
33
import {MDXProvider} from "@mdx-js/react";
44
import {LinkIcon} from "@rescui/icons";
5+
import GifPlayer from "react-gif-player";
56
import {useTextStyles} from "@jetbrains/kotlin-web-site-ui/out/components/typography";
67

78
import {useSiteMeta} from "../../utlis/hooks";
89
import {Link} from "../Link";
910

1011
import * as CUSTOM_MARKDOWN_TAGS from "./CustomTags";
1112

13+
import "./gif-player.css";
1214
import * as styles from "./modern.module.css";
1315
import {cls} from "../../utlis";
1416

@@ -98,6 +100,13 @@ const MODERN_SHORT_CODES = {
98100

99101
blockquote: props => <blockquote {...cls(props, styles.quote)}/>,
100102
pre: props => <div><pre {...cls(props, 'ktl-text-2', styles.codeBlock)}/></div>,
103+
img: ({src, ...props}) => {
104+
const { pathname } = new URL(src, window.location.href);
105+
106+
return pathname.endsWith('.gif') ?
107+
<GifPlayer {...props} gif={src}/> :
108+
<img src={src} {...props}/>
109+
},
101110

102111
// strong: props => <strong {...cls(props, 'ktl-')}/>,
103112
// hr: props => <hr {...cls(props, 'ktl-')}/>,

yarn.lock

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6223,6 +6223,15 @@ fs-extra@^11.1.0:
62236223
jsonfile "^6.0.1"
62246224
universalify "^2.0.0"
62256225

6226+
fs-extra@^11.1.1:
6227+
version "11.2.0"
6228+
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-11.2.0.tgz#e70e17dfad64232287d01929399e0ea7c86b0e5b"
6229+
integrity sha512-PmDi3uwK5nFuXh7XDTlVnS17xJS7vW36is2+w3xcv8SVxiB4NyATf4ctkVY5bkSjX0Y4nbvZCq1/EjtEyr9ktw==
6230+
dependencies:
6231+
graceful-fs "^4.2.0"
6232+
jsonfile "^6.0.1"
6233+
universalify "^2.0.0"
6234+
62266235
fs-extra@^9.0.0:
62276236
version "9.1.0"
62286237
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-9.1.0.tgz#5954460c764a8da2094ba3554bf839e6b9a7c86d"
@@ -6578,6 +6587,20 @@ gatsby-react-router-scroll@^6.7.0:
65786587
"@babel/runtime" "^7.20.13"
65796588
prop-types "^15.8.1"
65806589

6590+
gatsby-remark-copy-linked-files@^6.13.0:
6591+
version "6.13.0"
6592+
resolved "https://registry.yarnpkg.com/gatsby-remark-copy-linked-files/-/gatsby-remark-copy-linked-files-6.13.0.tgz#673ea3d3002ddba9f962cc0ee43051d0325c583c"
6593+
integrity sha512-hdWgIjCnvfixKIGRpWQwW8kxkMJg/7zD5bRjZH7Dsm2vHn/mv+g58pV3xGCA4CQGF4e+ZgSJk5mYkXciOFaxkA==
6594+
dependencies:
6595+
"@babel/runtime" "^7.20.13"
6596+
cheerio "^1.0.0-rc.10"
6597+
fs-extra "^11.1.1"
6598+
is-relative-url "^3.0.0"
6599+
lodash "^4.17.21"
6600+
path-is-inside "^1.0.2"
6601+
probe-image-size "^7.2.3"
6602+
unist-util-visit "^2.0.3"
6603+
65816604
gatsby-remark-images@^7.8.0:
65826605
version "7.8.0"
65836606
resolved "https://registry.yarnpkg.com/gatsby-remark-images/-/gatsby-remark-images-7.8.0.tgz#bd2d31f909dfe2886eeee53413a0275b9b224a0d"
@@ -10128,6 +10151,11 @@ path-is-absolute@^1.0.0:
1012810151
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
1012910152
integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==
1013010153

10154+
path-is-inside@^1.0.2:
10155+
version "1.0.2"
10156+
resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53"
10157+
integrity sha512-DUWJr3+ULp4zXmol/SZkFf3JGsS9/SIv+Y3Rt93/UjPpDpklB5f1er4O3POIbUuUJ3FXgqte2Q7SrU6zAqwk8w==
10158+
1013110159
path-key@^2.0.0, path-key@^2.0.1:
1013210160
version "2.0.1"
1013310161
resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40"
@@ -10883,7 +10911,7 @@ prop-types-exact@^1.2.0:
1088310911
object.assign "^4.1.0"
1088410912
reflect.ownkeys "^0.2.0"
1088510913

10886-
prop-types@^15.7.2, prop-types@^15.8.1:
10914+
prop-types@^15.6.0, prop-types@^15.7.2, prop-types@^15.8.1:
1088710915
version "15.8.1"
1088810916
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.8.1.tgz#67d87bf1a694f48435cf332c24af10214a3140b5"
1088910917
integrity sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==
@@ -11074,6 +11102,13 @@ react-fast-compare@^3.0.1, react-fast-compare@^3.1.1:
1107411102
resolved "https://registry.yarnpkg.com/react-fast-compare/-/react-fast-compare-3.2.0.tgz#641a9da81b6a6320f270e89724fb45a0b39e43bb"
1107511103
integrity sha512-rtGImPZ0YyLrscKI9xTpV8psd6I8VAtjKCzQDlzyDvqJA8XOW78TXYQwNRNd8g8JZnDu8q9Fu/1v4HPAVwVdHA==
1107611104

11105+
react-gif-player@^0.4.2:
11106+
version "0.4.2"
11107+
resolved "https://registry.yarnpkg.com/react-gif-player/-/react-gif-player-0.4.2.tgz#7f7675625bb264a3cfac8956edd5a18b8c196af3"
11108+
integrity sha512-ub++AT0PgbVxw1S0ahV3Q/4m67772r3vrnE6VqYed0Wi0cB9iremID8UnkFhZJCge77lwumsFOYsk1ShmouAgA==
11109+
dependencies:
11110+
prop-types "^15.6.0"
11111+
1107711112
react-helmet@^6.1.0:
1107811113
version "6.1.0"
1107911114
resolved "https://registry.yarnpkg.com/react-helmet/-/react-helmet-6.1.0.tgz#a750d5165cb13cf213e44747502652e794468726"

0 commit comments

Comments
 (0)