TokamakPublish
1.0.0
ใช้ Tokamak ในธีมของคุณสำหรับ Publish static Generator
คุณสามารถเขียนธีมทั้งหมดของคุณด้วย Tokamak หรือรวมเข้ากับ Plot
HTML ที่คุณมีอยู่
การใช้งาน Tokamak ของธีม .foundation
มีให้ภายใต้ชื่อ . .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
}
ในฟังก์ชันเหล่านี้ คุณสามารถสร้าง View
ด้วยไวยากรณ์ที่เข้ากันได้กับ SwiftUI:
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 )
}
...
}
คุณสามารถรวมมุมมอง Tokamak ใน Plot HTML ของคุณด้วยโหนด view
:
let myHTML = Plot . HTML (
. body (
. h1 ( . text ( " My Website " ) ) ,
. view {
Text ( " This is a Tokamak " ) + Text ( " View " )
. font ( . system ( . body , design : . monospaced ) )
} ,
. view ( MyTokamakView ( ) )
)
)
คุณสามารถรวมโหนด Plot ในมุมมอง Tokamak ของคุณได้อย่างง่ายดาย:
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 " ) )
)
}
}