diff --git a/src/components/vue/PlaylistSearchInput.vue b/src/components/vue/PlaylistSearchInput.vue new file mode 100644 index 0000000..83ab385 --- /dev/null +++ b/src/components/vue/PlaylistSearchInput.vue @@ -0,0 +1,152 @@ + + + diff --git a/src/pages/index.astro b/src/pages/index.astro index 036a20f..2322c0b 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -1,9 +1,22 @@ --- import Layout from '../layouts/Layout.astro'; + +import PlaylistSearchInput from '../components/vue/PlaylistSearchInput.vue'; + +const tagline = + 'Browse past versions of thousands of Spotify playlists saved over time'; --- - -
-

Spotify Playlist Archive

+ +
+

+ Spotify Playlist Archive +

+
+

{tagline}

+ +
diff --git a/src/utils/getPlaylistIdFromUrl.ts b/src/utils/getPlaylistIdFromUrl.ts new file mode 100644 index 0000000..bbdd9f9 --- /dev/null +++ b/src/utils/getPlaylistIdFromUrl.ts @@ -0,0 +1,15 @@ +export const getPlaylistIdFromUrl = (url: string) => { + const urlObject = new URL(url); + const [collectionName, playlistId] = urlObject.pathname + .split('/') + .filter(Boolean); + + const isValidPlaylistUrl = + urlObject.hostname === 'open.spotify.com' && + collectionName === 'playlist' && + playlistId; + + if (!isValidPlaylistUrl) throw new Error('Invalid playlist URL'); + + return playlistId; +};