W.D. Neumann's Thing

SplashDown

So after trying to get thins set up with Publish the other day I decided to try to get the Splash plugin up and running. A task that, while not complicated, was made about 18 times harder than it needed to be due, yet again, to John Sundell's shitty documentation. I'm sorry, the guy may do some good things for the community, but if he can't take 10 minutes out of his day to write decent documentation for his stuff, then I'm going to call him out for it.

Seriously, go try to get his Splash plugin running with Publish based solely off of what he has on his github page. You can't, unless you already know how to do it. So I'm going to document it here, because I know I'll forget it soon enough. Hopefully this stays current for a while.

Note: These directions are just for basic setups. I'm aware that there are more complex publishing pipelines that can be built manually and do things a different way. When I learn about them, I will update this document. This is just to get up and running.

Step 1: Add the Splash plugin to your project

Change the Package.swift file for your site's project so it looks more or less like this:

let package = Package(
    name: "WebsiteProjectName",
    products: [
        .executable(
            name: "WebsiteProjectName",
            targets: ["WebsiteProjectName"]
        )
    ],
    dependencies: [
      .package(
        name: "Publish", 
        url: "https://github.com/johnsundell/publish.git", 
        from: "0.6.0"
      ),
      .package(
        name: "SplashPublishPlugin", 
        url: "https://github.com/johnsundell/splashpublishplugin", 
        from: "0.1.0"
      )
    ],
    targets: [
        .target(
            name: "WebsiteProjectName",
            dependencies: ["Publish", "SplashPublishPlugin"]
        )
    ]
)

The change from the base Package.swift file is the addition of the line
.package(name: "SplashPublishPlugin", url: "https://github.com/johnsundell/splashpublishplugin", from: "0.1.0")
and adding "SplashPublishPlugin" to the target dependencies.

Step 2: Import the plugin

Add the following import to your main.swift and, if you have any, any other swift files where you are publishing content with Publish. I have none, so I don't know if this is even a thing.

import SplashPublishPlugin

Step 3: Change your publishing call

The default invocation to publish your site is

try WebsiteStructName().publish(withTheme: .whateverThemeYouAreUsing)

Change this to:

try WebsiteStructName()
  .publish(
    withTheme: .whateverThemeYouAreUsing, 
    plugins: [.splash(withClassPrefix: "")]
  )

If you do this and build your site, you'll see that the code looks like code, but there is no syntax highlighting. This is because you need to add the proper CSS info to your styles.css file. Here's what I am using, change the colors, etc. to your personal liking:

pre code {
  display: block;
  background-color: #1a1a1a;
  padding: 15px 20px;
  border-radius: 12px;
  color: #a9bcbc;
  line-height: 1.4em;
  font-size: 0.95em;
  overflow-x: auto;
  white-space: pre;
  -webkit-overflow-scrolling: touch;
}

pre code .keyword {
  color: #b294bb
}
pre code .type {
  color: #f0c674;
}
pre code .call {
  color: #81a2be;
}
pre code .property {
  color: #cc6666;
}
pre code .number {
  color: #de935f;
}
pre code .string {
  color: #b5bd68;
}
pre code .comment {
  color: #969896;
}
pre code .dotAccess {
  color: #de935f;
}
pre code .preprocessing {
  color: #8abeb7;
}

Some sample code:

#ifAvailable(macOS, *, *)

public func channelRead(context: ChannelHandlerContext, data: NIOAny) {
  let hola : [UInt8] = [194, 161, 72, 111, 108, 97]
  
  print("Reading, yo!")
  var bytebuffer = self.unwrapInbountIn(data)
  self.numbytes -= byteBuffer.readableBytes
}

// boopinatin, yo
let boop: Noop = .blarp

There. That should work. I've got a lot more digging to do tonight to help make things look less shitty though. Also, I need some non-godawful CSS. This default styling is trash.

Tagged with: