Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates to work with template #12

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Conversation

lucaferranti
Copy link
Member

No description provided.

@fonsp
Copy link
Member

fonsp commented Aug 10, 2024

Hey! What is this PR again?

It looks like the change is this:

image

What is _data used for again?

@fonsp
Copy link
Member

fonsp commented Aug 10, 2024

All the formatting makes this PR a bit unmergable (and lots of conflicts with other changes), maybe you can just make a new branch with just the change?

@fonsp
Copy link
Member

fonsp commented Aug 10, 2024

This code should also be in a different cell: right now the _data folder is read once for every time that a notebook is rendered, but you only need it once.

@lucaferranti
Copy link
Member Author

lucaferranti commented Aug 10, 2024

In the computational-thinking-template there is a _data folder used for basic website info (generate name, semester, ToC etc.) JuliaPluto/computational-thinking-template#24 (btw that works locally, but on on CI for some reason, I need to check the failure). That piece of code was removed here, not sure if by accident or intentionally

I'll rebase, I think my vscode also introduced some extra formatting changes without my persimission (editors are just like cats sometimes)

@lucaferranti
Copy link
Member Author

This code should also be in a different cell: right now the _data folder is read once for every time that a notebook is rendered, but you only need it once.

Good point! I think something like

const METADATA = ....

In its own cell should work?

@lucaferranti lucaferranti reopened this Aug 10, 2024
@lucaferranti
Copy link
Member Author

ok let's see what it looks like on the template side

src/notebook.jl Outdated Show resolved Hide resolved
@fonsp
Copy link
Member

fonsp commented Aug 10, 2024

Nice! I like the _data/something.jl concept! Can you add an assert that the file ends in .jl?

@assert endswithjl(filename) "Only Julia files are currently supported for data input."

We also need to add the id of the cell that does these includes to this list. This means that when there is an error in one of the data files, the error message will show in the dashboard.

And I think metadata is a fine name, but it is confusing because there is already notebook metadata (and cell metadata but shhhh).

I'm looking at the "data" section of https://www.11ty.dev/docs/data-configuration/ (it makes sense to copy their API because they thought about it very hard), and it looks like they merge it with data from other layers. I think that's a nice idea:

For example, if you set the global data year.jl to be 2024, then you can access use number in your _includes/layout.jlmd as $(year). But if one notebook has frontmatter year set to 2022, then for that one notebook, the variable year will be overriden to 2022.

@fonsp
Copy link
Member

fonsp commented Aug 10, 2024

So I think it should be:

frontmatter=merge(
				# lowest priority
				global_data, 
				# high priority
				output.frontmatter, 
				# overrides for this notebook
				FrontMatter(
					"content" => content,
					"page" => page,
					"collections" => collections,
					"root_url" => root_url,
				),
			)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants