Tag: slug

如何制作和存储邮件标题的slu??

我使用MongoDB / mongoose来存储具有以下模式的博客文章: PostSchema = mongoose.Schema({ title: {type: String}, body: {type: String} }); 现在我的posturl如下所示: http://www.example.local/posts/571f78d077b4454bafcfcced 我想我的post包含slu like如下: http://www.example.local/posts/571f78d077b4454bafcfcced/how-to-make-and-store-slug-for-title 所以我的问题是: 我应该生成一次slug和存储PostModel架构或每个post上显示? 如何为标题(现有的节点模块解决这个任务)生成slug basen非ASCII字符? 我应该使用什么地方将查询从http://www.example.local/posts/571f78d077b4454bafcfccedredirect到http://www.example.local/posts/571f78d077b4454bafcfcced/how-to-make-and-store-slug-for-title (nodejs,nginx,客户端)。 谢谢! EIDT:我也发现,在StackOverflow数据库viwer的问题与ID 503429 SO存储non slugged标题。 那么这是否意味着SO在每次请求问题时都会计算出slu g?