CREATE OR REPLACE FUNCTION slugify(input TEXT)
RETURNS TEXT AS $$
BEGIN
  RETURN lower(regexp_replace(unaccent(regexp_replace(input, '[^\w\s-]', '', 'g')), '\s+', '-', 'g'));
END;
$$ LANGUAGE plpgsql IMMUTABLE;
