Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Commit

Permalink
Merge pull request #58 from AudiusProject/jowlee-seo
Browse files Browse the repository at this point in the history
SEO friendly changes
  • Loading branch information
jowlee authored Oct 10, 2022
2 parents 75d87a4 + b38da9c commit df593a9
Show file tree
Hide file tree
Showing 14 changed files with 204 additions and 38 deletions.
21 changes: 21 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 23 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,31 @@
"build/*"
],
"devDependencies": {
"env-cmd": "^10.1.0",
"eslint": "^6.0.1",
"eslint-config-synacor": "^3.0.4",
"identity-obj-proxy": "^3.0.0",
"per-env": "^1.0.2",
"env-cmd": "10.1.0",
"eslint": "6.0.1",
"eslint-config-synacor": "3.0.4",
"identity-obj-proxy": "3.0.0",
"per-env": "1.0.2",
"preact-cli": "3.0.0-rc.7",
"preact-cli-plugin-env-vars": "^1.2.1",
"preact-cli-svg-loader": "^1.0.0",
"preact-render-spy": "^1.2.1",
"serve": "^11.1.0",
"webpack-cli": "^4.5.0"
"preact-cli-plugin-env-vars": "1.2.1",
"preact-cli-svg-loader": "1.0.0",
"preact-render-spy": "1.2.1",
"serve": "11.1.0",
"webpack-cli": "4.5.0"
},
"dependencies": {
"@audius/stems": "^0.3.9",
"amplitude-js": "^8.11.1",
"axios": "^0.19.2",
"classnames": "^2.2.6",
"copy-to-clipboard": "^3.2.1",
"hls.js": "^0.13.1",
"preact": "^10.0.1",
"preact-render-to-string": "^5.1.0",
"preact-router": "^3.0.0",
"react-transition-group": "^4.3.0",
"simplebar-react": "^2.1.0",
"web3-utils": "^1.3.4"
"@audius/stems": "0.3.9",
"amplitude-js": "8.11.1",
"axios": "0.19.2",
"classnames": "2.2.6",
"copy-to-clipboard": "3.2.1",
"hls.js": "0.13.1",
"preact": "10.0.1",
"preact-render-to-string": "5.1.0",
"preact-router": "3.0.0",
"react-helmet": "6.1.0",
"react-transition-group": "4.3.0",
"simplebar-react": "2.1.0",
"web3-utils": "1.3.4"
}
}
4 changes: 2 additions & 2 deletions src/components/collectibles/CollectibleDetailsView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ const CollectibleDetailsView = ({ collectible, user }) => {

<div className={styles.nftInfo}>
{collectible.name && (
<div className={styles.header}>
<h1 className={styles.header}>
{collectible.name}
</div>
</h1>
)}
{collectible.description && (
<div className={styles.desc}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
line-height: 36px;
letter-spacing: 0.02em;
color: #858199;
margin: 0;
}
.nftInfo .desc {
position: relative;
Expand Down
51 changes: 51 additions & 0 deletions src/components/collectibles/CollectibleHelmet.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { h } from "preact";
import { Helmet } from "react-helmet";
import { getAudiusHostname } from "../../util/getEnv";
import { getHash } from "./collectibleHelpers";

const CollectibleHelmet = ({ collectiblesInfo }) => {
if (!collectiblesInfo) {
return null
}
const { collectible, user } = collectiblesInfo
const title = `${collectible.name ? `${collectible.name} • ` : ''}NFT COLLECTIBLES • Audius`
const description = collectible.description || (collectible.name ? `Check out ${collectible.name} on Audius · NFT COLLECTIBLES` : 'Check out NFT collectibles on Audius')
const hostname = getAudiusHostname()
const url = `https://${hostname}/${user.handle}/collectibles/${getHash(collectible.id)}`
let type
switch (collectible.mediaType) {
case 'IMAGE':
case 'GIF':
type = 'ImageObject'
break
case 'VIDEO':
type = 'VideoObject'
break
case 'THREE_D':
type = '3DModel'
break
default:
type = 'MediaObject'
}
const structuredData = {
"@context": "http://schema.googleapis.com/",
"@type": type,
"@id": url,
url: url,
name: collectible.name || 'NFT Collectible',
description: description,
}

return (
<Helmet encodeSpecialCharacters={false}>
<title>{title}</title>
<meta name="description" content={description} />
<link rel="canonical" href={url} />
<script type="application/ld+json">
{JSON.stringify(structuredData)}
</script>
</Helmet>
)
}

export default CollectibleHelmet
4 changes: 4 additions & 0 deletions src/components/collectibles/CollectiblesPlayerContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import CollectibleGallery from './CollectibleGallery'
import Card from '../card/Card'
import CollectiblesHeader from './CollectiblesHeader'
import styles from './CollectiblesPlayerContainer.module.css'
import CollectibleHelmet from './CollectibleHelmet'

const CollectiblesPlayerContainer = ({
collectiblesInfo,
Expand All @@ -20,6 +21,9 @@ const CollectiblesPlayerContainer = ({

return (
<>
<CollectibleHelmet
collectiblesInfo={collectiblesInfo}
/>
{collectiblesInfo.type === 'gallery' && (
<CollectibleGallery
collectibles={getCollectiblesArray()}
Expand Down
37 changes: 37 additions & 0 deletions src/components/collection/CollectionHelmet.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { h } from "preact"
import { Helmet } from "react-helmet"
import { getAudiusHostname } from "../../util/getEnv"

const CollectionHelmet = ({ collection }) => {
if (!collection) {
return null
}

const title = `${collection.name} by ${collection.ownerName} • Audius`
const description = `Listen on Audius: ${collection.name}`
const hostname = getAudiusHostname()
const url = `https://${hostname}/${collection.collectionURLPath}`
const isAlbum = collectionURLPath.toLowerCase().includes('album')
let type = isAlbum ? 'MusicAlbum' : 'MusicPlaylist'
const structuredData = {
"@context": "http://schema.googleapis.com/",
"@type": type,
"@id": url,
url: url,
name: collection.name,
description: description,
}

return (
<Helmet encodeSpecialCharacters={false}>
<title>{title}</title>
<meta name="description" content={description} />
<link rel="canonical" href={url} />
<script type="application/ld+json">
{JSON.stringify(structuredData)}
</script>
</Helmet>
)
}

export default CollectionHelmet
6 changes: 6 additions & 0 deletions src/components/collection/CollectionPlayerContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { PlayingState } from '../playbutton/PlayButton'
import { isMobile } from '../../util/isMobile'
import { PlayerFlavor } from '../app'
import { formatGateways } from '../../util/gatewayUtil'
import CollectionHelmet from './CollectionHelmet'

const LISTEN_INTERVAL_SECONDS = 1

Expand Down Expand Up @@ -103,6 +104,10 @@ const CollectionPlayerContainer = ({
if (flavor === PlayerFlavor.TINY) return null

return (
<>
<CollectionHelmet
collectoin={collection}
/>
<CollectionPlayerCard
activeTrackIndex={activeTrackIndex}
backgroundColor={backgroundColor}
Expand All @@ -116,6 +121,7 @@ const CollectionPlayerContainer = ({
seekTo={seekTo}
isTwitter={isTwitter}
/>
</>
)
}

Expand Down
8 changes: 4 additions & 4 deletions src/components/titles/Titles.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ const Titles = ({

return (
<div className={styles.titles}>
<div
<h1
className={styles.title}
onClick={onClickTitle}>
{title}
</div>
<div
</h1>
<h2
className={styles.artistName}
onClick={onClickArtist}
>
{artistName}
{isVerified && <IconVerified />}
</div>
</h2>
</div>
)
}
Expand Down
2 changes: 2 additions & 0 deletions src/components/titles/Titles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
text-overflow: ellipsis;
white-space: nowrap;
font-size: 18px;
margin: 0;
}

.title:hover {
Expand All @@ -24,6 +25,7 @@
display: flex;
align-items: center;
overflow: hidden;
margin: 0;
}

.artistName:hover {
Expand Down
34 changes: 34 additions & 0 deletions src/components/track/TrackHelmet.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { h } from "preact";
import { Helmet } from "react-helmet";

const TrackHelmet = ({ track }) => {
if (!track) {
return null;
}

const title = `${track.title} by ${track.userName} • Audius`;
const description = `Listen to ${track.title} on Audius. ${track.userName} · Song`;
const hostname = getAudiusHostname()
const url = `https://${hostname}/${track.urlPath}`;
const structuredData = {
"@context": "http://schema.googleapis.com/",
"@type": "MusicRecording",
"@id": url,
url: url,
name: track.title,
description: description,
}

return (
<Helmet encodeSpecialCharacters={false}>
<title>{title}</title>
<meta name="description" content={description} />
<link rel="canonical" href={url} />
<script type="application/ld+json">
{JSON.stringify(structuredData)}
</script>
</Helmet>
);
};

export default TrackHelmet;
24 changes: 16 additions & 8 deletions src/components/track/TrackPlayerContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import TrackPlayerTiny from './TrackPlayerTiny'
import usePlayback from '../../hooks/usePlayback'
import { PauseContext } from '../pausedpopover/PauseProvider'
import TrackPlayerCard from './TrackPlayerCard'
import TrackHelmet from './TrackHelmet'
import { useSpacebar } from '../../hooks/useSpacebar'
import { useRecordListens } from '../../hooks/useRecordListens'
import { PlayingState } from '../playbutton/PlayButton'
Expand Down Expand Up @@ -120,26 +121,33 @@ const TrackPlayerContainer = ({
did404
}

let trackPlayer
if (flavor === PlayerFlavor.COMPACT) {
return (
trackPlayer = (
<TrackPlayerCompact
{...props}
/>
)
}

if (flavor === PlayerFlavor.TINY) {
return (
else if (flavor === PlayerFlavor.TINY) {
trackPlayer = (
<TrackPlayerTiny
{...props}
/>
)
}

else {
trackPlayer = (
<TrackPlayerCard
{...props}
/>
)
}
return (
<TrackPlayerCard
{...props}
/>
<>
<TrackHelmet track={track} />
{trackPlayer}
</>
)
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/track/TrackPlayerTiny.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ const TrackPlayerTiny = ({
<div className={styles.playContainer}>
</div>
<div className={styles.infoContainer}>
<div
<h1
className={cn(styles.info, {
[styles.animating]: animating
})}
ref={infoRef}
style={infoStyle}
>
{info}
</div>
</h1>
</div>
<div className={styles.logoContainer}>
<AudiusLogoGlyph
Expand Down
1 change: 1 addition & 0 deletions src/components/track/TrackPlayerTiny.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
letter-spacing: 0.01em;
color: var(--neutral);
white-space: nowrap;
margin: 0;
margin-left: 24px;

display: inline-block;
Expand Down

0 comments on commit df593a9

Please sign in to comment.