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:
parent
b35a7223b6
commit
69e0ea92e4
13 changed files with 260 additions and 65 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue