lektor.builder.Artifact

During the build process Lektor creates artifact objects to represent final build artifacts. Generally each Source Object will generate one artifact for which it acts as a primary source.

There are however many cases in which a source object will create sub-artifacts. For instance any thumbnail created in the context of a page will be creating its own artifact. To give plugins the same ability the artifact system is partially documented. See also sub_artifact to see how to create your own artifact instances.

The most important function of an artifact is open which can open the artifact for reading or writing. If the build goes well, Lektor will commit those changes and persist them.

Example

ctx = get_ctx()
@ctx.sub_artifact('artifact.txt')
def build_stylesheet(artifact):
    with artifact.open('w') as f:
        f.write('Hello World!\n')

Comments