File size: 2,284 Bytes
3fb26c5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from fh_bootstrap import *
from itertools import chain
from markdown import markdown

md_exts='codehilite', 'smarty', 'extra', 'sane_lists'
def Markdown(s, exts=md_exts, **kw): return Div(NotStr(markdown(s, extensions=exts)), **kw)

ghurl = 'https://github.com/nbroad1881'
hf_logo_svg = "https://huggingface.co/datasets/huggingface/brand-assets/resolve/main/hf-logo.svg"
li_url = "https://www.linkedin.com/in/nicholas-m-broad/"
kaggle_url = "https://www.kaggle.com/nbroad"
fh_url = "https://fastht.ml/"
fh_logo = 'assets/fasthtml_logo.svg'

def BstPage(selidx, title, *c):
    navitems = [('Home', '/'), ('Blog', '/blog')]
    
    ra_items = (
        A(Image(src="/assets/hf-logo.svg", width=28, height=28, cls="my-0 px-0 mx-0 py-0", left=False, pad=0), cls="ms-2 my-0 px-1 btn-lg btn", role="button", href="https://hf.co/nbroad"), 
        Icon('fab fa-github', dark=False, sz='lg', href=ghurl, cls='ms-2 px-2'),
        Icon("fab fa-linkedin", dark=False, sz='lg', href=li_url, cls='ms-2 px-2'),
        Icon("fab fa-kaggle", dark=False, sz='lg', href=kaggle_url, cls='ms-2 px-2'),
        Icon("fab fa-youtube", dark=False, sz='lg', href="https://www.youtube.com/@nicholasbroad1881", cls='ms-2 px-2'),
        Icon("fab fa-twitter", dark=False, sz='lg', href="https://twitter.com/nbroad1881", cls='ms-2 px-2'),
                )
    ftlinks = [A(k, href=v, cls='nav-link px-2 text-muted')
        for k,v in dict(Home='/').items()]
    return (
        Title(title),
        Script('initTOC()'),
        Container(
            Navbar('nav', selidx, items=navitems, ra_items=ra_items, cls='navbar-light bg-secondary rounded-lg',
                image=f'', hdr_href="fhurl", placement=PlacementT.Default, expand=SizeT.Md, toggle_left=False),
            Toc(Container(H1(title, cls='pb-2 pt-1'), *c, cls='mt-3')),
            BstFooter('Made using FastHTML', File(fh_logo), img_href=fh_url, cs=ftlinks),
        typ=ContainerT.Xl, cls='mt-3', data_bs_spy='scroll', data_bs_target='#toc'))

def Sections(h2s, texts):
    colors = 'yellow', 'pink', 'teal', 'blue'
    div_cls = 'py-2 px-3 mt-4 bg-light-{} rounded-lg'
    return chain([Div(H2(h2, id=f'sec{i+1}', cls=div_cls.format(colors[i%4])), Div(txt, cls='px-2'))
                  for i,(h2,txt) in enumerate(zip(h2s, texts))])