mirror of https://github.com/mickael-menu/zk
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.4 KiB
Go
50 lines
1.4 KiB
Go
package core
|
|
|
|
// Link represents a link in a note to another note or an external resource.
|
|
type Link struct {
|
|
// Label of the link.
|
|
Title string
|
|
// Destination URI of the link.
|
|
Href string
|
|
// Type of link, e.g. wiki link.
|
|
Type LinkType
|
|
// Indicates whether the target is a remote (e.g. HTTP) resource.
|
|
IsExternal bool
|
|
// Relationships between the note and the linked target.
|
|
Rels []LinkRelation
|
|
// Excerpt of the paragraph containing the note.
|
|
Snippet string
|
|
// Start byte offset of the snippet in the note content.
|
|
SnippetStart int
|
|
// End byte offset of the snippet in the note content.
|
|
SnippetEnd int
|
|
}
|
|
|
|
// LinkType represents the kind of link, e.g. wiki link.
|
|
type LinkType string
|
|
|
|
const (
|
|
LinkTypeImplicit LinkType = "implicit" // No markup, e.g. http://example.com
|
|
LinkTypeMarkdown LinkType = "markdown"
|
|
LinkTypeWikiLink LinkType = "wiki-link"
|
|
)
|
|
|
|
// LinkRelation defines the relationship between a link's source and target.
|
|
type LinkRelation string
|
|
|
|
const (
|
|
// LinkRelationDown defines the target note as a child of the source.
|
|
LinkRelationDown LinkRelation = "down"
|
|
// LinkRelationDown defines the target note as a parent of the source.
|
|
LinkRelationUp LinkRelation = "up"
|
|
)
|
|
|
|
// LinkRels creates a slice of LinkRelation from a list of strings.
|
|
func LinkRels(rel ...string) []LinkRelation {
|
|
rels := []LinkRelation{}
|
|
for _, r := range rel {
|
|
rels = append(rels, LinkRelation(r))
|
|
}
|
|
return rels
|
|
}
|