TokamakPublish
1.0.0
Utilice Tokamak en sus temas para el generador estático de publicación.
Puede escribir su tema completo con Tokamak o integrarlo con su Plot HTML existente.
Se proporciona una implementación Tokamak del tema .foundation con el nombre .tokamakFoundation .
TokamakHTMLFactory Para crear su propio tema Tokamak, cumpla con el protocolo TokamakHTMLFactory . Eso requiere las siguientes funciones:
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
} En estas funciones, puede crear una View con sintaxis compatible con 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 )
}
...
} Puede incluir vistas Tokamak en su Plot HTML con el nodo 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 ( ) )
)
)Puede incluir nodos Plot en sus vistas Tokamak con la misma facilidad:
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 " ) )
)
}
}