This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fetch = require('node-fetch') | |
| const fs = require('fs') | |
| const csvFilePath = "./data.csv" | |
| const API_TOKEN = "<SENDBIRD_API_TOKEN>" // Insert your API token here | |
| const APP_ID = "<SENDBIRD_APP_ID>" // Insert your App ID here | |
| const MESSAGE_LIMIT = 500 | |
| const REQUEST_THROTTLING_TIMEOUT = 10000 | |
| const dateRanges = [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const EMAIL_PARSE_REGEX = /(?:(?:[^<>()\[\]\\.,;:+\s@"]+(?:\.[^<>()\[\]\\.,;:+\s@"]+)*)|(?:".+"))@(?:(?:\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(?:(?:[a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/; | |
| const URL_PARSE_REGEX = /(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u00a1-\uffff][a-z0-9\u00a1-\uffff_-]{0,62})?[a-z0-9\u00a1-\uffff]\.)+(?:[a-z\u00a1-\uffff]{2,}\.?))(?::\d{2,5})?(?:[/?#]\S*)?/gi; | |
| const convertURLToLink = token => token.match(URL_PARSE_REGEX) | |
| ? `<a href='${token}' target="_blank" rel="noreferrer">${token}</a>` | |
| : token; | |
| const convertEmailToLink = token => token.match(EMAIL_PARSE_REGEX) ? `<a href="${`mailto:${token}`}">${token}</a>` : token; | |
| const convertURLsAndEmailsToLinks = message => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const VideoAnimation = props => { | |
| // ... | |
| useEffect(() => { | |
| const loadLozad = async () => { | |
| const lozad = require('lozad') | |
| const observer = lozad(); | |
| observer.observe(); | |
| } | |
| loadLozad() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import BaseBlockContent from '@sanity/block-content-to-react' | |
| import React from 'react' | |
| import VideoAnimation from './videoAnimation' | |
| const serializers = { | |
| // marks: { ... }, | |
| types: { | |
| block (props) { | |
| // ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useEffect } from 'react' | |
| import { getPaddingFromAspectRatio } from '../../lib/helpers'; | |
| import { videoAssetFor } from '../../lib/video-url' | |
| const VideoAnimation = ({ webm, fallback, aspectratio, alt, caption }) => { | |
| if (!webm || !fallback) { | |
| return null | |
| } | |
| const webmAsset = videoAssetFor(webm) | |
| const fallbackAsset = videoAssetFor(fallback) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export default { | |
| title: 'Block Content', | |
| name: 'blockContent', | |
| type: 'array', | |
| of: [ | |
| { | |
| title: 'Block', | |
| type: 'block', | |
| // ... | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import createSchema from 'part:@sanity/base/schema-creator' | |
| import schemaTypes from 'all:part:@sanity/base/schema-type' | |
| // import post from './post' | |
| // import postAuthor from './postAuthor' | |
| // ...other imports | |
| import videoAnimation from './videoAnimation' | |
| export default createSchema({ | |
| name: 'default', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from "react"; | |
| import { getFileAsset } from '@sanity/asset-utils'; | |
| import { Flex, Spinner } from "@sanity/ui"; | |
| const PROJECT_ID = process.env.SANITY_STUDIO_PROJECT_ID; | |
| const DATASET = process.env.SANITY_STUDIO_DATASET; | |
| const VideoPreview = props => { | |
| if (props.isLoading || !props.value.video || !props.value.video.asset) { | |
| return ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { MdVideoLibrary } from "react-icons/md"; | |
| export default { | |
| name: 'videoAnimation', | |
| title: 'Video animation', | |
| type: 'object', | |
| icon: MdVideoLibrary, | |
| fields: [ | |
| { | |
| name: 'webm', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require('dotenv').config({ path: './.env.development' }) | |
| console.log('API_KEY: ' + process.env.API_KEY) | |
| module.exports = function() { | |
| // ... | |
| } |