Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions gridsome.server.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const redditChannels = require("./data/redditChannels");
const podcasts = require("./data/podcasts");
const blogs = require("./data/blogs");
const learningPlatforms = require("./data/learningPlatforms");
const createSlug = require("./src/utils/slugify");

let id_list = videoTutorials.map((tech) =>
tech.videoTutorials.map((video) => video.url)
Expand Down Expand Up @@ -131,8 +132,9 @@ module.exports = function(api) {

data.allVideo.edges.forEach(({ node }) => {
if (node.category !== "playlist") {
const SLUG_NAME = createSlug(node.name);
createPage({
path: `/video-tutorials/${node.name}/${node.id}`,
path: `/video-tutorials/${SLUG_NAME}/${node.id}`,
component: "./src/templates/VideoPage.vue",
context: {
id: node.id,
Expand All @@ -149,8 +151,9 @@ module.exports = function(api) {

videoTutorials.forEach((category) => {
if (category.category !== "playlist") {
const SLUG_NAME = createSlug(category.name);
createPage({
path: `/video-tutorials/${category.name.toLowerCase()}`,
path: `/video-tutorials/${SLUG_NAME}`,
component: "./src/templates/TechnologyPage.vue",
context: {
technology: category.name.toLowerCase(),
Expand All @@ -161,9 +164,9 @@ module.exports = function(api) {
},
});
} else if (category.category === "playlist") {
const PRETTY_PATH = category.name.replace(" ", "-").toLowerCase();
const SLUG_NAME = createSlug(category.name);
createPage({
path: `/video-tutorials/playlists/${PRETTY_PATH}`,
path: `/video-tutorials/playlists/${SLUG_NAME}`,
component: "./src/templates/PlaylistPage.vue",
context: {
name: category.name.toLowerCase(),
Expand Down
8 changes: 7 additions & 1 deletion src/components/PlaylistCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<g-link
@mouseenter.native="hover = true"
@mouseleave.native="hover = false"
:to="`video-tutorials/playlists/${name.replace(' ', '-').toLowerCase()}`"
:to="playlistPath"
class="m-3"
>
<section
Expand Down Expand Up @@ -71,6 +71,7 @@ import IsraelFlagIcon from "~/components/UI/IsraelFlagIcon";
import { formatDistance } from "date-fns";
import { format } from "date-fns";
import { he } from "date-fns/locale";
import createSlug from "~/utils/slugify";

export default {
props: {
Expand Down Expand Up @@ -116,6 +117,11 @@ export default {
amountDirection() {
return this.hebrewName.length === 0 ? "right-0" : "left-0";
},

playlistPath() {
const slug = createSlug(this.name);
return `video-tutorials/playlists/${slug}`;
},
},
};
</script>
Expand Down
9 changes: 8 additions & 1 deletion src/components/TechCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
>
<div class="pt-2 px-5 flex-grow">
<g-link
:to="`/video-tutorials/${name.toLowerCase()}`"
:to="tutorialPath"
:style="`color: ${color}`"
class="text-center flex flex-col justify-between h-full"
>
Expand Down Expand Up @@ -56,6 +56,7 @@
import AppIcon from "~/components/UI/AppIcon";
import ExternalIcon from "~/components/UI/ExternalIcon";
import YoutubeIcon from "~/components/UI/YoutubeIcon";
import createSlug from "~/utils/slugify";
export default {
props: {
name: String,
Expand All @@ -82,6 +83,12 @@ export default {
"--color-hover": this.color,
};
},
tutorialPath() {
if (!this.name) return '/video-tutorials';

const slug = createSlug(this.name);
return `/video-tutorials/${slug}`;
},
},
};
</script>
Expand Down
8 changes: 7 additions & 1 deletion src/components/VideoCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<g-link
@mouseenter.native="hover = true"
@mouseleave.native="hover = false"
:to="`video-tutorials/${category}/${id}`"
:to="videoPath"
class="m-2"
>
<section
Expand Down Expand Up @@ -50,6 +50,7 @@ import IsraelFlagIcon from "~/components/UI/IsraelFlagIcon";
import { formatDistance } from "date-fns";
import { format } from "date-fns";
import { he } from "date-fns/locale";
import createSlug from "~/utils/slugify";

export default {
props: {
Expand Down Expand Up @@ -104,6 +105,11 @@ export default {
direction() {
return this.doesContainHebrewLetters([this.title]) ? "rtl" : "ltr";
},

videoPath() {
const slug = createSlug(this.category);
return `video-tutorials/${slug}/${this.id}`;
},
},
};
</script>
Expand Down
4 changes: 3 additions & 1 deletion src/templates/TechnologyPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
import VideoCard from "~/components/VideoCard";
import PlaylistCard from "~/components/PlaylistCard";
import AppIcon from "~/components/UI/AppIcon";
import createSlug from "~/utils/slugify";
export default {
components: {
VideoCard,
Expand Down Expand Up @@ -160,8 +161,9 @@ export default {
if (this.currentPage + 1 > this.$page.videos.pageInfo.totalPages) {
$state.complete();
} else {
const slug = createSlug(this.$context.technology);
const { data } = await this.$fetch(
`/video-tutorials/${this.$context.technology}/${this.currentPage + 1}`
`/video-tutorials/${slug}/${this.currentPage + 1}`
);
if (data.videos.edges.length) {
this.currentPage = data.videos.pageInfo.currentPage;
Expand Down
7 changes: 6 additions & 1 deletion src/templates/VideoPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
>
<g-link
:title="`${$context.name}-חזור ל`"
:to="`video-tutorials/${$context.name}`"
:to="backPath"
>
<div class="p-8">
<app-icon
Expand Down Expand Up @@ -69,6 +69,7 @@
<script>
import AppLoader from "~/components/UI/AppLoader";
import AppIcon from "~/components/UI/AppIcon";
import createSlug from "~/utils/slugify";
export default {
components: {
AppLoader,
Expand All @@ -88,6 +89,10 @@ export default {
direction() {
return this.isHebrew ? "rtl" : "ltr";
},
backPath() {
const slug = createSlug(this.$context.name);
return `video-tutorials/${slug}`;
},

description() {
return this.showMore
Expand Down
12 changes: 12 additions & 0 deletions src/utils/slugify.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = function (name) {
if (!name) return '';

return name.toString().toLowerCase()
.replace(/#/g, '-sharp')
.replace(/\+/g, '-plus')
.replace(/\s+/g, '-')
.replace(/[^\w\-]+/g, '')
.replace(/\-\-+/g, '-')
.replace(/^-+/, '')
.replace(/-+$/, '');
};