web.site #
Site Module
config heroscript
!!site.config
name:'ThreeFold DePIN Tech'
description:'ThreeFold is laying the foundation for a geo aware Web 4, the next generation of the Internet.'
tagline:'Geo Aware Internet Platform'
favicon:'img/favicon.png'
image:'img/tf_graph.png'
copyright:'ThreeFold'
!!site.menu
title:'ThreeFold DePIN Tech'
logo_alt:'ThreeFold Logo'
logo_src:'img/logo.svg'
logo_src_dark:'img/new_logo_tft.png'
!!site.menu_item
label:'ThreeFold.io'
href:'https://threefold.io'
position:'right'
!!site.menu_item
label:'Mycelium Network'
href:'https://mycelium.threefold.io/'
position:'right'
!!site.menu_item
label:'AI Box'
href:'https://aibox.threefold.io/'
position:'right'
!!site.footer
style:'dark'
!!site.footer_item
title:'Docs'
label:'Introduction'
href:'https://docs.threefold.io/docs/introduction'
!!site.footer_item
title:'Docs'
label:'Litepaper'
href:'https://docs.threefold.io/docs/litepaper/'
!!site.footer_item
title:'Features'
label:'Become a Farmer'
href:'https://docs.threefold.io/docs/category/become-a-farmer'
!!site.footer_item
title:'Features'
label:'Components'
href:'https://docs.threefold.io/docs/category/components'
!!site.footer_item
title:'Web'
label:'ThreeFold.io'
href:'https://threefold.io'
!!site.footer_item
title:'Web'
label:'Dashboard'
href:'https://dashboard.grid.tf'
!!site.collections
url:'https://github.com/example/external-docs'
replace:'PROJECT_NAME:My Project, VERSION:1.0.0'
site structure
!!site.page name:intro
description:'ThreeFold is laying the foundation for a geo aware Web 4, the next generation of the Internet.'
#!!site.page name:mycelium draft:true folder:'/specs/components' prio:4
content:'the page content itself, only for small pages'
title:'Mycelium as Title'
description:'...'
!!site.page name:fungistor folder:'/specs/components' prio:1
src:'mycollection:mycelium.md'
title:'fungistor as Title'
description:'....'
!!site.page name:fungistor folder:'/specs/components' prio:1
src:'mycollection:mycelium' //can be without .md
title:'fungistor as Title'
description:'...'
factory
import freeflowuniverse.herolib.web.site
mut mysite := site.new()!
how to use with plbook
import freeflowuniverse.herolib.core.playbook
import freeflowuniverse.herolib.web.site
// path string
// text string
// git_url string
// git_pull bool
// git_branch string
// git_reset bool
// session ?&base.Session is optional
mut plbook := playbook.new( '....')!
site.play(mut plbook)!
example json
{
'name': 'depin',
'title': 'Documentation Site',
'description': 'ThreeFold is laying the foundation for a geo aware Web 4, the next generation of the Internet.',
'tagline': 'Geo Aware Internet Platform',
'favicon': 'img/favicon.png',
'image': 'img/tf_graph.png',
'copyright': 'ThreeFold',
'footer': {
'style': 'dark',
'links': [
{
'title': 'Docs',
'items': [
{
'label': 'Introduction',
'to': 'intro',
'href': ''
},
{
'label': 'Litepaper',
'to': '',
'href': 'https://docs.threefold.io/docs/litepaper/'
},
{
'label': 'Roadmap',
'to': '',
'href': 'https://docs.threefold.io/docs/roadmap'
},
{
'label': 'Manual',
'to': '',
'href': 'https://manual.grid.tf/'
}
]
},
{
'title': 'Features',
'items': [
{
'label': 'Become a Farmer',
'to': '',
'href': 'https://docs.threefold.io/docs/category/become-a-farmer'
},
{
'label': 'Components',
'to': '',
'href': 'https://docs.threefold.io/docs/category/components'
},
{
'label': 'Technology',
'to': '',
'href': 'https://threefold.info/tech/'
},
{
'label': 'Tokenomics',
'to': '',
'href': 'https://docs.threefold.io/docs/tokens/tokenomics'
}
]
},
{
'title': 'Web',
'items': [
{
'label': 'ThreeFold.io',
'to': '',
'href': 'https://threefold.io'
},
{
'label': 'Dashboard',
'to': '',
'href': 'https://dashboard.grid.tf'
},
{
'label': 'GitHub',
'to': '',
'href': 'https://github.com/threefoldtech/home'
},
{
'label': 'Mycelium Network',
'to': '',
'href': 'https://mycelium.threefold.io/'
},
{
'label': 'AI Box',
'to': '',
'href': 'https://www2.aibox.threefold.io/'
}
]
}
]
},
'menu': {
'title': 'ThreeFold DePIN Tech',
'items': [
{
'href': 'https://threefold.io',
'to': '',
'label': 'ThreeFold.io',
'position': 'right'
},
{
'href': 'https://mycelium.threefold.io/',
'to': '',
'label': 'Mycelium Network',
'position': 'right'
},
{
'href': 'https://aibox.threefold.io/',
'to': '',
'label': 'AI Box',
'position': 'right'
}
]
},
'import_collections': [
{
'url': 'https://github.com/example/external-docs',
'path': '',
'dest': '',
'replace': {
'PROJECT_NAME': 'My Project',
'VERSION': '1.0.0'
},
'visible': false
}
],
'pages': [
{
'name': 'intro',
'content': '',
'title': '',
'description': 'ThreeFold is laying the foundation for a geo aware Web 4, the next generation of the Internet.',
'draft': false,
'folder': '',
'prio': 0,
'src': ''
},
{
'name': 'mycelium',
'content': 'the page content itself, only for small pages',
'title': 'Mycelium as Title',
'description': '...',
'draft': true,
'folder': '/specs/components',
'prio': 4,
'src': ''
},
{
'name': 'fungistor',
'content': '',
'title': 'fungistor as Title',
'description': '....',
'draft': false,
'folder': '/specs/components',
'prio': 1,
'src': 'mycollection:mycelium.md'
},
{
'name': 'fungistor',
'content': '',
'title': 'fungistor as Title',
'description': '...',
'draft': false,
'folder': '/specs/components',
'prio': 1,
'src': 'mycollection:mycelium'
}
]
}
fn default #
fn default() !&Site
fn get #
fn get(args FactoryArgs) !&Site
fn new #
fn new(args FactoryArgs) !&Site
fn play #
fn play(mut plbook PlayBook) !
struct BuildDest #
struct BuildDest {
pub mut:
path string
ssh_name string
}
struct FactoryArgs #
@[params]
struct FactoryArgs {
pub mut:
name string = 'default'
}
struct ImportItem #
struct ImportItem {
pub mut:
name string // will normally be empty
url string // http git url can be to specific path
path string
dest string // location in the docs folder of the place where we will build the documentation site e.g. docusaurus
replace map[string]string // will replace ${NAME} in the imported content
visible bool = true
}
struct Menu #
struct Menu {
pub mut:
title string
items []MenuItem
logo_alt string @[json: 'logoAlt']
logo_src string @[json: 'logoSrc']
logo_src_dark string @[json: 'logoSrcDark']
}
struct MenuItem #
struct MenuItem {
pub mut:
href string
to string
label string
position string
}
menu config structures
struct Page #
struct Page {
pub mut:
title string
description string
draft bool
position int
hide_title bool
src string @[required]
path string @[required]
title_nr int
slug string
}
struct Section #
struct Section {
pub mut:
position int
path string
label string
}
struct Site #
@[heap]
struct Site {
pub mut:
pages []Page
sections []Section
siteconfig SiteConfig
}
struct SiteConfig #
@[heap]
struct SiteConfig {
pub mut:
name string
title string = 'My Documentation Site' // General site title
description string // General site description, can be used for meta if meta_description not set
tagline string
favicon string = 'img/favicon.png'
image string = 'img/tf_graph.png' // General site image, can be used for meta if meta_image not set
copyright string = 'someone'
footer Footer
menu Menu
imports []ImportItem
// New fields for Docusaurus compatibility
url string // The main URL of the site (from !!site.config url:)
base_url string // The base URL for Docusaurus (from !!site.config base_url:)
url_home string // The home page path relative to base_url (from !!site.config url_home:)
meta_title string // Specific title for SEO metadata (from !!site.config_meta title:)
meta_image string // Specific image for SEO metadata (og:image) (from !!site.config_meta image:)
build_dest []BuildDest // Production build destinations (from !!site.build_dest)
build_dest_dev []BuildDest // Development build destinations (from !!site.build_dest_dev)
}
fn (SiteConfig) generate #
fn (siteconfig SiteConfig) generate(args SiteGeneratorArgs) !
new creates a new siteconfig and stores it in redis, or gets an existing one
struct SiteGenerator #
struct SiteGenerator {
pub mut:
siteconfig_name string
path pathlib.Path
client &doctreeclient.DocTreeClient
flat bool // if flat then won't use sitenames as subdir's
}
struct SiteGeneratorArgs #
@[params]
struct SiteGeneratorArgs {
pub mut:
path string
flat bool // if flat then won't use sitenames as subdir's
}