Giter Site home page Giter Site logo

a2 / cnamepublishplugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from the-freshlord/cnamepublishplugin

0.0 2.0 0.0 99 KB

A plugin that generates a CNAME file for the Publish static site generator. ๐Ÿš€

License: MIT License

Swift 100.00%

cnamepublishplugin's Introduction

CNAME plugin for Publish

A Publish plugin that generates a custom domain name file for any Publish website deployed to GitHub.

Background

When developing your own static website and deploying to GitHub Pages, you will most likely want to have your own custom domain. This requires having a custom domain name file, also known as a CNAME in the root directory of your website or the GitHub repository that your website is hosted on. When generating your site and pushing to GitHub, the CNAME file is removed since Publish will always push whatever files are generated in the dedicated Output directory. This plugin aims to generate a CNAME file into the Output directory that Publish uses for deploying your site to GitHub.

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/SwiftyGuerrero/CNAMEPublishPlugin", from: "0.1.0")
    ],
    targets: [
        .target(
            ...
            dependencies: [
                ...
                "CNAMEPublishPlugin"
            ]
        )
    ]
    ...
)

Usage

In the file where you declare your Publish deployment pipeline, import CNAMEPublishPlugin:

import CNAMEPublishPlugin

The plugin can be installed at any point in the publishing pipeline, but before the deploy step:

import CNAMEPublishPlugin

...
try Website().publish(using: [
    ...
    .installPlugin(.generateCNAME(with: "test.io", "www.test.io")),
    .deploy(using: .gitHub("TestUser/TestUser.github.io"))
])

You can also add a CNAME to the Resources directory of your website and then use the addCNAME plugin to copy the CNAME to the output directory:

import CNAMEPublishPlugin

...
try Website().publish(using: [
    ...
    .installPlugin(.addCNAME()),
    .deploy(using: .gitHub("TestUser/TestUser.github.io"))
])

To verify that the file is generated and in the Output directory, you can use the publish run command to test publishing your site locally. Then in the created Output directory, you will see the generated CNAME as shown below:

To learn more about custom domains for GitHub Pages, visit GitHub's documentation related to managing your own custom domain.

cnamepublishplugin's People

Contributors

basthomas avatar the-freshlord avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.