-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the feature to add social media icons to the root container tem…
…plate using the configuration. (#39)
- Loading branch information
Showing
7 changed files
with
107 additions
and
241 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,29 @@ | ||
import io.github.tscholze.kotlog.Kotlog | ||
import io.github.tscholze.kotlog.models.BlogConfiguration | ||
import io.github.tscholze.kotlog.models.SocialMedia | ||
import io.github.tscholze.kotlog.models.SocialMediaPlatform | ||
|
||
fun main(args: Array<String>) { | ||
|
||
// 1. Create a configuration for the blog, | ||
// or it will be fetched from `~/.kotlog file` | ||
// | ||
// Sample: | ||
|
||
// val configuration = BlogConfiguration( | ||
// baseUrl = "https://tscholze.github.io/blog", | ||
// titleText = "Tobias Scholze | The Stuttering Nerd", | ||
// footerText = "Made with ❤️ without JavaScript| Kotlog | Tobias Scholze", | ||
// outputDirectoryName = "www" | ||
//) | ||
// 1.1 | ||
// fetched from `~/.kotlog file` | ||
// | ||
// 1.2. | ||
// Use a configuration object in code. | ||
val configuration = BlogConfiguration( | ||
baseUrl = "https://tscholze.github.io/blog", | ||
titleText = "Tobias Scholze | The Stuttering Nerd", | ||
footerText = "Made with ❤️ without JavaScript| Kotlog | Tobias Scholze", | ||
outputDirectoryName = "www", | ||
socialMedia = listOf( | ||
SocialMedia(SocialMediaPlatform.GITHUB, "tscholze"), | ||
SocialMedia(SocialMediaPlatform.TWITTER, "tobonautilus"), | ||
SocialMedia(SocialMediaPlatform.MASTODON, "@tobonaut@mastodon.social", "https://mastodon.social/@tobonaut") | ||
) | ||
) | ||
|
||
// 2. Call and run Kotlog with command line arguments and configuration. | ||
Kotlog(args) | ||
} | ||
|
||
Kotlog(args, configuration) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/main/kotlin/io/github/tscholze/kotlog/templates/components/SocialMediaIcon.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package io.github.tscholze.kotlog.templates.components | ||
|
||
import io.github.tscholze.kotlog.models.SocialMedia | ||
import io.github.tscholze.kotlog.models.SocialMediaPlatform | ||
import io.github.tscholze.kotlog.templates.Renderable | ||
|
||
/** | ||
* Renders a linked social media icon. | ||
* | ||
* @param socialMedia Social media entry. | ||
*/ | ||
class SocialMediaIcon(private val socialMedia: SocialMedia): Renderable { | ||
override fun render(): String { | ||
return when(socialMedia.platform) { | ||
SocialMediaPlatform.GITHUB -> "<a href=\"https://github.com/${socialMedia.id}\" title=\"GitHub\" target=\"_bank\"><i class=\"fab fa-github\"></i></a>" | ||
SocialMediaPlatform.MASTODON -> "<a rel=\"me\" href=\"${socialMedia.payload ?: ""}\" title=\"Mastodon\" target=\"_bank\"><i class=\"fab fa-mastodon\"></i></a>" | ||
SocialMediaPlatform.TWITTER -> "<a href=\"https://twitter.com/${socialMedia.id}\" title=\"Twitter\" target=\"_bank\"><i class=\"fab fa-twitter\"></i></a>" | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Renders a space separated row of linked social media icons. | ||
* | ||
* @param socialMedias List of social media entries. | ||
*/ | ||
class SocialMediaIcons(private val socialMedias: List<SocialMedia>): Renderable { | ||
override fun render(): String { | ||
return socialMedias | ||
.map { SocialMediaIcon(it).render() } | ||
.joinToString(" ") { it } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters