generate the summary and the document objects from inside the webpage() function
This commit is contained in:
parent
500a6ad181
commit
f7db139b0d
10 changed files with 234 additions and 144 deletions
124
lib/main.typ
124
lib/main.typ
|
|
@ -2,7 +2,7 @@
|
|||
#import "./html_body.typ": html-body
|
||||
#import "./html_utils.typ": html-show, reset-page-states
|
||||
#import "./summary.typ": summary, card-list
|
||||
#import "./states.typ": current-page-label
|
||||
#import "./states.typ": current-page-label, state-page-summaries
|
||||
#import "./pyscript.typ": state-use-pyscript, state-pyscript-data-list, state-pyscript-version, state-pyscript-interpreters, state-pyscript-default-interpreter, pyscript-show, pyscript-data
|
||||
#import "./rss.typ": rss
|
||||
#import "./icons.typ"
|
||||
|
|
@ -14,10 +14,18 @@
|
|||
base-url: none,
|
||||
/// The url path of the page (full url of the page is base-url + path), eg: "/index.html"
|
||||
path: none,
|
||||
/// Title of the page, default to document.title
|
||||
/// Title of the page
|
||||
title: none,
|
||||
/// Use only for html 'lang' attribute.
|
||||
lang: "en",
|
||||
/// Date of publication
|
||||
date: none,
|
||||
/// Label of the page (for links)
|
||||
page-label: none,
|
||||
/// Preview image
|
||||
preview-image: [],
|
||||
/// The copyright for the preview image
|
||||
preview-img-copyright: none,
|
||||
//-- <head> only args --
|
||||
/// Website icon, *needs* to be path (TODO: fix when typst support multi-file out)
|
||||
icon: none,
|
||||
|
|
@ -25,9 +33,9 @@
|
|||
og-type: "website",
|
||||
/// Name of the site for metadata of the page
|
||||
site-name: none,
|
||||
/// Description of the site for metadata, default to document.description
|
||||
/// Description of the site for metadata
|
||||
description: none,
|
||||
/// Author of the site for metadata, default to document.author
|
||||
/// Author of the site for metadata
|
||||
author: none,
|
||||
/// Tags describing the content of the page
|
||||
tags: (),
|
||||
|
|
@ -35,8 +43,6 @@
|
|||
stylesheets: (),
|
||||
/// List of related sites for metadata
|
||||
me-links: (),
|
||||
/// Label of the page (for links)
|
||||
page-label: none,
|
||||
/// Dictionnary of available pyscript-data for each versions of pyscript
|
||||
/// expected in the form of ("<version>": pyscript-data-list("<url>", { html.link(...) }), ...)
|
||||
pyscript-data-list: (:),
|
||||
|
|
@ -63,42 +69,76 @@
|
|||
) = {
|
||||
assert(type(base-url) == str, message: "A page must have a base url")
|
||||
assert(type(path) == str, message: "A page must have a path")
|
||||
assert(type(title) == str or type(title) == content, message: "A page must have title")
|
||||
//assert(type(preview-image) != none, message: "summary() must have a preview-image")
|
||||
assert(author != none, message: "A page must have at least one author")
|
||||
assert(description != none, message: "A page must have a description")
|
||||
assert(date != none, message: "A page must have a date")
|
||||
|
||||
context {
|
||||
state-pyscript-data-list.update(x => pyscript-data-list)
|
||||
state-pyscript-interpreters.update(x => pyscript-interpreters)
|
||||
state-pyscript-version.update(x => pyscript-version)
|
||||
state-pyscript-default-interpreter.update(x => pyscript-default-interpreter)
|
||||
if page-label == none {
|
||||
page-label = label(path)
|
||||
}
|
||||
show: html-show
|
||||
show raw.where(block: true, lang: "python-run"): pyscript-show
|
||||
current-page-label.update(x => page-label)
|
||||
html.html(lang: lang, {
|
||||
html-head(
|
||||
base-url,
|
||||
path,
|
||||
title,
|
||||
page-label,
|
||||
icon: icon,
|
||||
og-type: og-type,
|
||||
site-name: site-name,
|
||||
description: description,
|
||||
author: author,
|
||||
tags: tags,
|
||||
stylesheets: stylesheets,
|
||||
me-links: me-links
|
||||
)
|
||||
html-body(
|
||||
logo: logo,
|
||||
header: header,
|
||||
footer: footer,
|
||||
nav-elements: nav-elements,
|
||||
menu: menu,
|
||||
[
|
||||
#body
|
||||
#metadata("end of page " + str(page-label)) #label(str(page-label) + "-end")
|
||||
]
|
||||
)
|
||||
reset-page-states()
|
||||
})
|
||||
|
||||
state-page-summaries.update(
|
||||
x => x + (
|
||||
summary(
|
||||
url: base-url + path,
|
||||
title: title,
|
||||
preview-image: preview-image,
|
||||
img-copyright: preview-img-copyright,
|
||||
author: author,
|
||||
description: description,
|
||||
date: date,
|
||||
tags: tags,
|
||||
page-label: page-label,
|
||||
)
|
||||
,)
|
||||
)
|
||||
|
||||
[#document(
|
||||
path,
|
||||
title: title,
|
||||
//author: author,
|
||||
description: description,
|
||||
date: date,
|
||||
{
|
||||
context {
|
||||
state-pyscript-data-list.update(x => pyscript-data-list)
|
||||
state-pyscript-interpreters.update(x => pyscript-interpreters)
|
||||
state-pyscript-version.update(x => pyscript-version)
|
||||
state-pyscript-default-interpreter.update(x => pyscript-default-interpreter)
|
||||
}
|
||||
show: html-show
|
||||
show raw.where(block: true, lang: "python-run"): pyscript-show
|
||||
current-page-label.update(x => page-label)
|
||||
html.html(lang: lang, {
|
||||
html-head(
|
||||
base-url,
|
||||
path,
|
||||
title,
|
||||
page-label,
|
||||
icon: icon,
|
||||
og-type: og-type,
|
||||
site-name: site-name,
|
||||
description: description,
|
||||
author: author,
|
||||
tags: tags,
|
||||
stylesheets: stylesheets,
|
||||
me-links: me-links
|
||||
)
|
||||
html-body(
|
||||
logo: logo,
|
||||
header: header,
|
||||
footer: footer,
|
||||
nav-elements: nav-elements,
|
||||
menu: menu,
|
||||
[
|
||||
#body
|
||||
#metadata("end of page " + str(page-label)) #label(str(page-label) + "-end")
|
||||
]
|
||||
)
|
||||
reset-page-states()
|
||||
})
|
||||
}
|
||||
) #page-label]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue