Move makeSlug to function

This commit is contained in:
Sam Carlton 2021-04-17 22:36:06 -05:00
parent d1cb178be1
commit 00f1f1397c
5 changed files with 17 additions and 30 deletions

View file

@ -1,7 +1,6 @@
import { promises as fs } from 'fs'
import MarkdownIt from 'markdown-it'
import slugify from 'slugify'
import axios from 'axios'
import statuses, { getStatusName } from './statuses'
@ -9,17 +8,11 @@ import appStoreGenres from './app-store/genres.js'
import parseDate from './parse-date'
import { eitherMatches } from './matching.js'
import { getAppEndpoint } from './app-derived'
import { makeSlug } from './slug.js'
const md = new MarkdownIt()
const makeSlug = name => slugify(name, {
lower: true,
strict: true
})
const getTokenLinks = function ( childTokens ) {
const tokenList = []
@ -264,10 +257,7 @@ export default async function () {
if (isHeading && token.type === 'inline') {
categoryTitle = token.content
categorySlug = slugify(token.content, {
lower: true,
strict: true
})
categorySlug = makeSlug( token.content )
// appList[categorySlug] = []
}

View file

@ -1,10 +1,8 @@
import { promises as fs } from 'fs'
import slugify from 'slugify'
import axios from 'axios'
// import { statuses } from './build-app-list'
import { getAppEndpoint } from './app-derived'
import { makeSlug } from './slug.js'
// console.log('process.env.GAMES_SOURCE', process.env.GAMES_SOURCE)
@ -101,10 +99,7 @@ export default async function () {
if (isPlayable(game) && statusesTranslations.hasOwnProperty(environmentName(game)) === false) continue
// Generate slug
const slug = slugify(game.Games, {
lower: true,
strict: true
})
const slug = makeSlug( game.Games )
// Find index of game is list so far
const gameIndex = gameList.findIndex(game => {

View file

@ -1,11 +1,11 @@
import slugify from 'slugify'
import axios from 'axios'
import { fuzzyMatchesWholeWord } from './matching.js'
import { byTimeThenNull } from './sort-list.js'
import { getVideoEndpoint } from './app-derived.js'
import parseDate from './parse-date'
import { makeSlug } from './slug.js'
const inTimestamps = ( name, video ) => {
@ -150,10 +150,7 @@ export default async function ( applist ) {
if (fetchedVideos[videoId].title === 'Deleted video') continue
// Build video slug
const slug = slugify(`${fetchedVideos[videoId].title}-i-${videoId}`, {
lower: true,
strict: true
})
const slug = makeSlug( `${fetchedVideos[videoId].title}-i-${videoId}` )
const apps = []
// Generate new tag set based on api data

View file

@ -1,12 +1,8 @@
// Universal JS imports only
import slugify from 'slugify'
import { makeSlug } from './slug.js'
export function makeCategorySlug ( categoryName ) {
return slugify(categoryName, {
lower: true,
strict: true
})
return makeSlug( categoryName )
}

9
helpers/slug.js Normal file
View file

@ -0,0 +1,9 @@
// Universal JS imports only
import slugify from 'slugify'
export function makeSlug ( name ) {
return slugify(name, {
lower: true,
strict: true
})
}