npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

svelte-document

v1.1.0

Published

Make documents (PDFs) with Svelte.

Downloads

14

Readme

Create documents, resumes, or presentations from a collection of Svelte files. No configuration needed, and exports to a very portable PDF file.

Usage

Getting started

Install svelte-document from npm as a global package, then invoke it in any directory containing .svelte pages that you want formatted into a PDF. A file called document.pdf will be generated in the current working directory.

# Install the package globally
npm install -g svelte-document

# Invoke the command
svelte-document

Page semantics and ordering

To order your pages is to simply number them: 1.svelte, 2.svelte, 3.svelte, and so on. The order which your filesystem presents the files do not impact the order in the document. You can also title your page by inserting any contents after a space character, like so: 5 How to Install Linux.svelte.

You can also use periods in your number to create subsections if needed, such as in 5.1 Troubleshooting.svelte.

Folders are not parsed, so you can use them to store components and assets, and files starting with + are ignored, save for +layout.svelte (explained later).

Page metadata in components

You can export the following Svelte variables in a <script>...</script> block and they will be automatically filled in by the tool:

| Variable name | Description | | ------------- | --------------------------------------------------------------------------------------------------------------------------- | | page_name | The name of the page provided after the page index in your file name. If there is no name, this value will be empty (""). | | page_path | The full path to the current page component. | | page_index | The page index from the file name. This is a string. | | page_count | The number of the page, starting from 1. This is an integer. |

Importing assets

Images

You can import images directly like so:

<script>
    import img from "./my-image.png"
</script>

<img src={img} />

Fonts

Fonts can also be imported. The file name of the font can be used in font-family styling, like so:

<script>
    import "./FontFile.ttf"
</script>

<div style="font-family: FontFile;">Hello world!</div>

Layout

You can provide a +layout.svelte file that will wrap every page. Its functionality is the same as SvelteKit's +layout.svelte.

[!TIP] Layout files can import CSS stylesheets using import statements, like so: import "./styles.css". Other pages cannot import CSS stylesheets, but can use <style>...</style> blocks.

Configuration

svelte-document is zero configuration, but you can provide optional configuration in a document.config.json file in the root of your document files, with the following fields: | Field | Default | Description | |-|-|-| | size | A4 | Dimensions of the page. Accepted values: A5, A4, A3, B5, B4, JIS-B5, JIS-B4, letter, legal, ledger, or a set of custom dimensions with the following format: {number}in/cm/mm {number}in/cm/mm, such as 24in 24in or 300mm 300mm. | | orientation | portrait | Orientation of the page. Accepted values: portrait, landscape | | out | document.pdf | Output file path/name, relative to the current working directory. |

Roadmap

  • [x] Implement PostCSS to support plugins such as TailwindCSS and Sass.
    • Done. svelte.config.js is now considered during compilation, so preprocessors (e.g. svelte-preprocess) can be used to implement suport for TailwindCSS, Sass, PostCSS, etc. Needs testing.
  • [ ] Implement plugin mechanism to extend functionality.
  • [ ] Better compatibility with projects using Node packages.

License

Copyright (c) 2024 Louka Ménard Blondin

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.