Add tag command
This commit is contained in:
@ -252,9 +252,8 @@ final class PageContentParser {
|
||||
return handleSvg(arguments, markdown: markdown)
|
||||
case .audioPlayer:
|
||||
return audioPlayer.process(arguments, markdown: markdown)
|
||||
default:
|
||||
results.invalid(command: nil, markdown)
|
||||
return ""
|
||||
case .tagLink:
|
||||
return handleTagLink(arguments, markdown: markdown)
|
||||
}
|
||||
}
|
||||
|
||||
@ -439,6 +438,45 @@ final class PageContentParser {
|
||||
.content
|
||||
}
|
||||
|
||||
/**
|
||||
Format: ``
|
||||
*/
|
||||
private func handleTagLink(_ arguments: [String], markdown: Substring) -> String {
|
||||
guard arguments.count == 1 else {
|
||||
results.invalid(command: .tagLink, markdown)
|
||||
return ""
|
||||
}
|
||||
let tagId = arguments[0]
|
||||
|
||||
guard let tag = content.tag(tagId) else {
|
||||
results.missing(tag: tagId, markdown: markdown)
|
||||
return ""
|
||||
}
|
||||
|
||||
let localized = tag.localized(in: language)
|
||||
let url = tag.absoluteUrl(for: language)
|
||||
let title = localized.name
|
||||
let description = localized.description ?? ""
|
||||
|
||||
let image = localized.linkPreviewImage.map { image in
|
||||
let size = content.settings.pages.pageLinkImageSize
|
||||
results.files.insert(image)
|
||||
results.imagesToGenerate.insert(.init(size: size, image: image))
|
||||
|
||||
return RelatedPageLink.Image(
|
||||
url: image.absoluteUrl,
|
||||
description: image.getDescription(for: language),
|
||||
size: size)
|
||||
}
|
||||
|
||||
return RelatedPageLink(
|
||||
title: title,
|
||||
description: description,
|
||||
url: url,
|
||||
image: image)
|
||||
.content
|
||||
}
|
||||
|
||||
/**
|
||||
Format: ``
|
||||
*/
|
||||
|
@ -5,10 +5,6 @@ import Foundation
|
||||
*/
|
||||
enum ShorthandMarkdownKey: String {
|
||||
|
||||
/// A standard url
|
||||
/// Format: ``
|
||||
case url
|
||||
|
||||
/// An image
|
||||
/// Format: ``
|
||||
case pageLink = "page"
|
||||
|
||||
/// A pretty link to a tag list on the site.
|
||||
/// Format: ``
|
||||
case tagLink = "tag"
|
||||
|
||||
/// Additional HTML code include verbatim into the page.
|
||||
/// Format: ``
|
||||
case includedHtml = "html"
|
||||
|
Reference in New Issue
Block a user