Unify slugify()

Provides a new util.js file with a unified `slugify()` function that also
lowercases the slug. Change all uses of `slugify()` to use this instead.
This commit is contained in:
Nick Pegg 2017-10-11 22:25:46 -07:00
parent b9fe8c7f38
commit 6109bb690d
5 changed files with 15 additions and 6 deletions

View file

@ -3,9 +3,9 @@ import React, { Component } from 'react';
import Icon from 'react-fontawesome';
import Markdown from 'react-markdown';
import { Link } from 'react-router-dom';
import slugify from 'slugify';
import { ListLink } from './Nav';
import { slugify } from './util';
class Article extends Component {

View file

@ -1,10 +1,10 @@
import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import slugify from 'slugify';
import Icon from 'react-fontawesome';
import { Row } from './skeleton';
import { slugify } from './util';
class ListLink extends Component {
@ -36,7 +36,7 @@ class NavList extends Component {
for (let page of blob.pages) {
let slug = page.slug;
if (!slug) {
slug = slugify(page.title).toLowerCase();
slug = slugify(page.title);
}
if (page.parent == null) {

View file

@ -1,9 +1,9 @@
import hljs from 'highlight.js';
import React, { Component } from 'react';
import Markdown from 'react-markdown';
import slugify from 'slugify';
import { NotFound } from './NotFound';
import { slugify } from './util';
class Page extends Component {
@ -25,7 +25,7 @@ class Page extends Component {
for (let page of blob.pages) {
let slug = page.slug;
if (!slug) {
slug = slugify(page.title).toLowerCase();
slug = slugify(page.title);
}
if (slug === this.params.slug) {

View file

@ -1,9 +1,9 @@
import React, { Component } from 'react';
import slugify from 'slugify';
import { Article } from './Article';
import { HistoryNav } from './Nav';
import { NotFound } from './NotFound';
import { slugify } from './util';
class Post extends Component {

9
src/util.js Normal file
View file

@ -0,0 +1,9 @@
import baseSlugify from 'slugify';
function slugify(s) {
// Slugify a string to our specs. Hooray consistency!
return baseSlugify(s).toLowerCase();
}
export { slugify };