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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃拰 Pluto.frontmatter #2008

Merged
merged 5 commits into from
Apr 4, 2022
Merged

馃拰 Pluto.frontmatter #2008

merged 5 commits into from
Apr 4, 2022

Conversation

fonsp
Copy link
Owner

@fonsp fonsp commented Mar 28, 2022

frontmatter(nb::Notebook; raise::Bool=false)::Dict{String,Any}

Extract frontmatter from a notebook, which is extra meta-information that the author attaches to the notebook, often including title, description, tags, author, and more. Search for frontmatter online to learn more.

Currently, you can give frontmatter to a notebook by defining a global variable frontmatter anywhere in the notebook, which should be a named tuple.

frontmatter = (
	title = "鈿★笍 JavaScript for widgets",
	description = "A simple notebook demonstrating the Julia syntax essentials",
	layout = "layout.jlhtml",
	tags = ["docs", "advanced", "widgets"],
);

This definition will be picked up (using syntax analysis) and evaluated. Note:

  • You are not allowed to use variables defined in other cells. (But you can use frontmatter in your notebook.)
  • You can use ; to hide it from being displayed, only the definition matters.

This might change in the future, because we might make this a GUI thing!

Related to #1984

@github-actions
Copy link
Contributor

Try this Pull Request!

Open Julia and type:

julia> import Pkg
julia> Pkg.activate(temp=true)
julia> Pkg.add(url="https://github.com/fonsp/Pluto.jl", rev="frontmatter-1")
julia> using Pluto

Copy link
Collaborator

@rikhuijzer rikhuijzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of having a frontmatter which can contain any valid Julia object. Very clever. All systems that I know fallback to string representations.

@fonsp
Copy link
Owner Author

fonsp commented Apr 4, 2022

Yeah I think that that's nice for dates, not sure what else... Any cool ideas where this is useful?

fonsp and others added 2 commits April 4, 2022 12:58
Co-authored-by: Rik Huijzer <rikhuijzer@pm.me>
@fonsp fonsp merged commit bd4b8ac into main Apr 4, 2022
@fonsp fonsp deleted the frontmatter-1 branch April 4, 2022 12:34
@rikhuijzer
Copy link
Collaborator

Yeah I think that that's nice for dates, not sure what else... Any cool ideas where this is useful?

Images maybe? That it handles storing images and getting permalinks for the open graph for Twitter thumbnails and stuff

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.

None yet

2 participants