web.siteconfig #
Site Module
The lib/web/site/
directory contains the Vlang code responsible for generating and managing a documentation website all the config elements are specified in heroscript
The result is in redis on the DB as used in the context on
- hset: siteconfigs:$name as json
- set: siteconfigs:current is the name of the last one we processed
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:'...'
how to use easy
import freeflowuniverse.herolib.web.site
siteconfig := site.new('/tmp/mypath')!
how to use with playbook
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(plbook: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 get #
fn get(name_ string) !&SiteConfig
get gets siteconfig from redis
fn new #
fn new(path string) !&SiteConfig
new creates a new siteconfig and stores it in redis, or gets an existing one
fn play #
fn play(args_ PlayArgs) !
struct BuildDest #
struct BuildDest {
pub mut:
path string
ssh_name string
}
struct CollectionsImport #
struct CollectionsImport {
pub mut:
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 docusaurus
replace map[string]string // will replace ${NAME} in the imported content
visible bool
}
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:
name string
content string
title string
description string
draft bool
folder string
prio int
src string
collection string
}
struct PlayArgs #
@[params]
struct PlayArgs {
pub mut:
heroscript string // if filled in then plbook will be made out of it
plbook ?PlayBook
reset bool
}
struct SiteConfig #
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
import_collections []CollectionsImport
pages []Page
// 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)
}
Combined config structure