Swiftpack.co - Deub27/LocalWebsitePublishPlugin as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by Deub27.
Deub27/LocalWebsitePublishPlugin 0.1.1
A local website plugin for the Publish static site generator
⭐️ 2
🕓 5 weeks ago
macOS
.package(url: "https://github.com/Deub27/LocalWebsitePublishPlugin.git", from: "0.1.1")

Local website plugin for Publish

A Publish plugin to localify HTML files in the output folder.

Goal: Make the generated website local on disk. No need for webserver

Replaces all href and src attributes to be relative to output folder.

The generated website is therefore accessible offline, directly from filesystem. Can be embedded in iOS app to be used within a WKWebView

Usage samples:

  • FAQ in iOS/MacOS app
  • Cocoapods ans SPM licences display in iOS/MacOS app

Installation

To install it into your Publish package, add it as a dependency within your Package.swift manifest:

let package = Package(
    ...
    dependencies: [
        ...
        .package(url: "https://github.com/Deub27/LocalWebsitePublishPlugin.git", from: "0.1.0")
    ],
    targets: [
        .target(
            ...
            dependencies: [
                ...
                "LocalWebsitePublishPlugin"
            ]
        )
    ]
    ...
)

Then import LocalWebsitePublishPlugin wherever you’d like to use it:

import LocalWebsitePublishPlugin

For more information on how to use the Swift Package Manager, check out this article, or its official documentation.

Usage

The plugin can then be used within any publishing pipeline like this:

import LocalWebsitePublishPlugin
...
try Website().publish(using: [
    ...
    .installPlugin(.localifyHTML()),
    ...
])

Note, that the html files must already be present in the output folder at the corresponding step in the publishing pipeline. It is therefore neccessary to add this step after .generateHTML(...) .

The wildcard .localifyHTML() method localify all html files in the top level of the output folder and subfolders.

GitHub

link
Stars: 2
Last commit: 5 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Dependencies

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics