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

@compiiile/compiiile-print

v1.0.5

Published

An Astro integration to add a print-ready page containing all Compiiile files

Downloads

4

Readme

compiiile-print

An Astro integration to add a print-ready page containing all Compiiile files.

Features

  • :page_facing_up: Add a /print route displaying all your pages ready to be printed
  • :wrench: Header can be fully customized
  • :nail_care: Apply your own style
  • :white_check_mark: All pages come after a page-break, and with a pagination

Installation

yarn add @compiiile/compiiile-print # install as a project dependency with yarn
# or
npm install @compiiile/compiiile-print # install as a project dependency with npm

Add to Compiiile

Import the dependency and add it to your Compiiile config file (compiiile.config.js):

import printIntegration from "@compiiile/compiiile-print"

export default {
    integrations:[printIntegration()]
}

You should now get a print-ready page when navigating to the /print route :sparkles:

Customize

Style

To customize the print page with your own style, pass an object to the print integration with a style property which is a String containing your custom CSS. Here is an example to set the header style:

import printIntegration from "@compiiile/compiiile-print"

export default {
    integrations:[printIntegration({
        style: `
            .page-header-top-left {
                
            }
            
            .page-header-top-center {
                
            }

            .page-header-top-right {
                
            }
            
            h2 {
            
            }
        `
    })]
}

:warning: By default, the print page switches to the light theme. If you want to print while using the dark theme, set the theme as a route param like so: /print?theme=dark.

Page header

You can customize the header displayed on each pages by passing specific object keys to the data property of your config:

  • data.printHeader.topLeft: content to be displayed at the top left of the header,
  • data.printHeader.topCenter: content to be displayed at the top center of the header,
  • data.printHeader.topRight: content to be displayed at the top right of the header.

The value must be a String and can contain HTML tags.

Full example

Here is a full working example with custom CSS and a header containing a logo:

import printIntegration from "@compiiile/compiiile-print"
import fs from "node:fs/promises"

const headerLogoPath = new URL("./logo.png", import.meta.url) // logo in the same directory as the config file
const headerLogo = await fs.readFile(headerLogoPath, {encoding:'base64'})

export default {
    integrations:[printIntegration({
        style: `
            .page-header-top-center {
                color: #d82727;
                font-weight: bold;
            }

            .page-header-top-right {
                color: #273ed8;
                line-height: 1.2rem;
                text-align: right;
            }

            html.theme--dark .page-header-top-right {
                color: #8db0e8;
            }
        `
    })],
    data: {
        printHeader: {
            topLeft: `<img src="data:image/png;base64,${headerLogo}" width="150"/>`,
            topCenter: "My custom title",
            topRight: "Compiiile<br/>2024",
        }
    }
}

Contributions

Attention is more directed on the Compiiile project. So please, open an issue first to discuss any fix or improvement on this integration.

License

This project is licensed under the terms of the GNU General Public License v3.0.

See LICENSE.md.