Links to channel notes (#7262)

Release Notes:

- Added outline support for Markdown files
- Added the ability to link to channel notes:
https://zed.dev/channel/zed-283/notes#Roadmap
This commit is contained in:
Conrad Irwin 2024-02-01 22:22:02 -07:00 committed by GitHub
parent b35a7223b6
commit 69e0ea92e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 260 additions and 65 deletions

View file

@ -74,11 +74,19 @@ impl Channel {
pub fn link(&self) -> String {
RELEASE_CHANNEL.link_prefix().to_owned()
+ "channel/"
+ &self.slug()
+ &Self::slug(&self.name)
+ "-"
+ &self.id.to_string()
}
pub fn notes_link(&self, heading: Option<String>) -> String {
self.link()
+ "/notes"
+ &heading
.map(|h| format!("#{}", Self::slug(&h)))
.unwrap_or_default()
}
pub fn is_root_channel(&self) -> bool {
self.parent_path.is_empty()
}
@ -90,9 +98,8 @@ impl Channel {
.unwrap_or(self.id)
}
pub fn slug(&self) -> String {
let slug: String = self
.name
pub fn slug(str: &str) -> String {
let slug: String = str
.chars()
.map(|c| if c.is_alphanumeric() { c } else { '-' })
.collect();