GithubHelp home page GithubHelp logo

nextjs-slugtest's Introduction

Created with

npx create-next-app@latest

And choosing all defaults. Then deleted lots of stuff.

Setup to play with nested routes and various slug libraries / capabilities.

Would probably go with this library to generate the slugs, seems pretty crispy and well troden:

https://www.npmjs.com/package/slugify

Then, when either CREATING or updating the IDENTIFIER of the thing that needs to be slugged;

  • in the database i'd have a pk that is a UUID that never ever changes
  • an IDENTIFIER that can change
  • and would generate a slug based on the above via a method that would catch collisions and retry
  • the slug must be a unique index in the db, much like the pk - it needs to do the work of ensuring uniqueness however...
  • if the data model like suggested here is such that the lesson is always in a given collection, then its uniqueness needs are less.

Could also go with something like this to add randomness, but it makes all urls look less good:

https://stackoverflow.com/questions/47477695/generating-a-collision-immune-obfuscating-slug-manually

However, if you want to set a max size to your slugs of say 8 chars, adding a few random bytes at the end isn't a bad thing, kinda better than 01, 02, 03 which does reveal some internals in a sloppyish way.

nextjs-slugtest's People

Contributors

mobob avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.