✨ Add ability to override link parameters
This commit is contained in:
parent
dfd4975b72
commit
c262425766
@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
### Added
|
||||
|
||||
- Ability to override individual link parameters
|
||||
- French translation ([#2](https://github.com/jpanther/lynx/pull/2))
|
||||
|
||||
## [1.0.0] - 2021-11-01
|
||||
|
31
README.md
31
README.md
@ -47,7 +47,7 @@ Below is a quick start guide using Hugo modules.
|
||||
|
||||
4. In the root folder of your website, replace the `config.toml` file that was generated by Hugo with the one from Lynx. You will find the theme config file in the Hugo cache directory, or [download a copy](https://minhaskamal.github.io/DownGit/#/home?url=https://github.com/jpanther/lynx/tree/stable/config.toml) from GitHub.
|
||||
|
||||
5. Edit the settings in the `config.toml` file to suit your needs. You can also create a `content/_index.md` file to add additional text to your site.
|
||||
5. Follow the [configuration instructions](#configuration) below.
|
||||
|
||||
### Installing theme updates
|
||||
|
||||
@ -55,6 +55,35 @@ As new releases are posted, you can update the theme using Hugo. Simply run `hug
|
||||
|
||||
---
|
||||
|
||||
## Configuration
|
||||
|
||||
The main theme configuration is managed in the `config.toml` file. Most parameters are self explanatory and the default config contains some basic examples.
|
||||
|
||||
The author name and image are displayed at the top of the page. Both are optional and will default to the site title with no image when not provided.
|
||||
|
||||
Links can either be a simple string containing the URL for the link, or an object that defines the link parameters. Links are displayed in the order provided in the config file.
|
||||
|
||||
Acceptable link parameters are:
|
||||
|
||||
- `href` = the URL the link should point to
|
||||
- `icon` = the name of the icon to use for this link (optional)
|
||||
- `text` = the link text (optional)
|
||||
|
||||
```toml
|
||||
[author]
|
||||
links = {
|
||||
# Simple link
|
||||
{ github = { href = "https://github.com/jpanther/lynx", text = "Visit my website" }}
|
||||
|
||||
# Custom link
|
||||
{ link = { href = "https://github.com/jpanther/lynx", text = "GitHub Project", icon = "github" }}
|
||||
}
|
||||
```
|
||||
|
||||
Additional page content can be provided by creating a Markdown file at `content/_index.md`. The contents of this file will be displayed between the title and links. Check out the exampleSite to see this in practice.
|
||||
|
||||
---
|
||||
|
||||
## Contributing
|
||||
|
||||
Lynx is expected to evolve over time. I intend to keep adding features and making changes as required.
|
||||
|
@ -10,7 +10,8 @@ disableKinds = ["taxonomy", "term"]
|
||||
|
||||
[author]
|
||||
# name = "Your name here"
|
||||
# image = "img/author.jpg"
|
||||
# image = "img/author.jpg" # path relative to static directory
|
||||
|
||||
links = [
|
||||
# { email = "mailto:hello@your_domain.com" },
|
||||
# { link = "https://link-to-some-website.com/" },
|
||||
|
@ -1,9 +1,5 @@
|
||||
theme = "lynx"
|
||||
languageCode = "en-au"
|
||||
defaultContentLanguage = "en"
|
||||
|
||||
title = "Lynx"
|
||||
# copyright = "Copy, _right?_ :thinking_face:"
|
||||
|
||||
enableEmoji = true
|
||||
disableKinds = ["taxonomy", "term"]
|
||||
|
@ -14,22 +14,27 @@
|
||||
{{ with .Site.Author.links }}
|
||||
<div class="flex flex-col flex-wrap min-w-full mt-4 sm:min-w-0">
|
||||
{{ range $links := . }}
|
||||
{{ range $name, $url := $links }}
|
||||
{{ range $type, $data := $links }}
|
||||
{{ $href := $data }}
|
||||
{{ $icon := $type }}
|
||||
{{ $text := i18n (printf "link.%s" $type) }}
|
||||
{{ if reflect.IsMap $data }}
|
||||
{{ with $data.href }}{{ $href = . }}{{ end }}
|
||||
{{ with $data.icon }}{{ $icon = . }}{{ end }}
|
||||
{{ with $data.text }}{{ $text = . }}{{ end }}
|
||||
{{ end }}
|
||||
<a
|
||||
class="link link-{{ $name }} sm:px-24 min-w-full py-2 mb-3 text-lg rounded"
|
||||
href="{{ $url }}"
|
||||
class="link link-{{ $type }} sm:px-24 min-w-full py-2 mb-3 text-lg rounded"
|
||||
href="{{ $href }}"
|
||||
target="_blank"
|
||||
alt="{{ $name | title }}"
|
||||
rel="me noopener noreferrer"
|
||||
><div class="">
|
||||
<span class="mr-1">{{ partial "icon.html" $name }}</span
|
||||
>{{ i18n (printf "link.%s" $name) }}
|
||||
<span class="mr-1">{{ partial "icon.html" $icon }}</span>{{ $text }}
|
||||
</div></a
|
||||
>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
</article>
|
||||
{{ end }}
|
||||
|
Loading…
Reference in New Issue
Block a user