TokamakPublish
1.0.0
게시 정적 생성기의 테마에 Tokamak을 사용하세요.
Tokamak으로 전체 테마를 작성하거나 기존 Plot
HTML과 통합할 수 있습니다.
.foundation
테마의 Tokamak 구현은 .tokamakFoundation
이라는 이름으로 제공됩니다.
TokamakHTMLFactory
자신만의 Tokamak 테마를 만들려면 TokamakHTMLFactory
프로토콜을 따르세요. 이를 위해서는 다음과 같은 기능이 필요합니다.
struct MyThemeFactory < Site : Website > : TokamakHTMLFactory {
func makeIndexView ( for index : Index , context : PublishingContext < Self . Site > ) throws -> IndexView
func makeSectionView (
for section : Publish . Section < Self . Site > ,
context : PublishingContext < Self . Site >
) throws -> SectionView
func makeItemView ( for item : Item < Self . Site > , context : PublishingContext < Self . Site > ) throws -> ItemView
func makePageView ( for page : Page , context : PublishingContext < Self . Site > ) throws -> PageView
func makeTagListView ( for page : TagListPage , context : PublishingContext < Self . Site > ) throws -> TagListView
func makeTagDetailsView ( for page : TagDetailsPage , context : PublishingContext < Self . Site > ) throws -> TagDetailsView
}
이러한 함수에서는 SwiftUI 호환 구문을 사용하여 View
구축할 수 있습니다.
struct MyThemeFactory < Site : Website > : TokamakHTMLFactory {
func makePageView ( for page : Page , context : PublishingContext < Self . Site > ) throws -> PageView {
Text ( " Welcome to my website " )
. font ( . largeTitle )
VStack ( alignment : . leading ) {
page . body
}
. frame ( idealWidth : 820 , maxWidth : 820 )
. padding ( . vertical , 40 )
Text ( " 2020 © Tokamak Contributors " )
. font ( . caption )
}
...
}
view
노드를 사용하여 플롯 HTML에 Tokamak 뷰를 포함할 수 있습니다.
let myHTML = Plot . HTML (
. body (
. h1 ( . text ( " My Website " ) ) ,
. view {
Text ( " This is a Tokamak " ) + Text ( " View " )
. font ( . system ( . body , design : . monospaced ) )
} ,
. view ( MyTokamakView ( ) )
)
)
Tokamak 뷰에 Plot 노드를 쉽게 포함할 수 있습니다.
struct ContentView : View {
var body : some View {
Text ( " My Website " )
. font ( . largeTitle )
Node . p (
. span ( " This is a Plot " ) ,
. span ( . text ( " Node " ) , . style ( " font-family: monospace " ) )
)
}
}