This commit is contained in:
Brandon Rozek 2020-02-16 16:54:11 -05:00
commit d63dee8bf4
10 changed files with 61 additions and 29 deletions

View file

@ -4,11 +4,11 @@
Pulp is a [Hugo](https://gohugo.io/) theme for getting a simple, easy-to-read blog site. Pulp is a [Hugo](https://gohugo.io/) theme for getting a simple, easy-to-read blog site.
## Screenshots ## Screenshots
![screenshot-top](https://user-images.githubusercontent.com/17229643/55247370-c7a5b100-528a-11e9-835b-108bd6047699.png) ![screenshot-top](https://user-images.githubusercontent.com/17229643/72672672-bd16fc80-3a01-11ea-9056-7439db39ed75.png)
![screenshot-list](https://user-images.githubusercontent.com/17229643/55247387-d12f1900-528a-11e9-8144-c984031e16c0.png) ![screenshot-list](https://user-images.githubusercontent.com/17229643/72672673-c607ce00-3a01-11ea-8356-d3cfc4ead65e.png)
![screenshot-page](https://user-images.githubusercontent.com/17229643/55247395-d5f3cd00-528a-11e9-82ed-4830523c5bfa.png) ![screenshot-page](https://user-images.githubusercontent.com/17229643/72672675-cacc8200-3a01-11ea-914e-c80876d03b16.png)
## Installation ## Installation
If your site is also under version control using git, the easiest way to install this theme is to add it as a submodule. If you have not created a git repo for your project yet, you need to run `git init` beforehand. Inside the folder of your Hugo site, run the following command. If your site is also under version control using git, the easiest way to install this theme is to add it as a submodule. If you have not created a git repo for your project yet, you need to run `git init` beforehand. Inside the folder of your Hugo site, run the following command.

View file

@ -16,15 +16,6 @@ const bigramTokeniser = (obj, metadata) => {
return [] return []
} }
if (Array.isArray(obj)) {
return obj.map((t) => {
return new lunr.Token(
lunr.utils.asString(t).toLowerCase(),
lunr.utils.clone(metadata)
)
})
}
let str = obj.toString().trim().toLowerCase() let str = obj.toString().trim().toLowerCase()
let tokens = [] let tokens = []
@ -70,6 +61,7 @@ const initLunr = () => {
builder.pipeline.reset() builder.pipeline.reset()
builder.ref('ref') builder.ref('ref')
builder.field('title', { boost: 10 }) builder.field('title', { boost: 10 })
builder.field('tags', { boost: 10 })
builder.field('body') builder.field('body')
builder.metadataWhitelist = ['position'] builder.metadataWhitelist = ['position']
for (let page of pagesIndex) { for (let page of pagesIndex) {
@ -112,11 +104,12 @@ const initUI = () => {
const query = $(event.currentTarget).val() const query = $(event.currentTarget).val()
// Icon switching // Icon switching
const iconUrl = $('#searchBoxIcon').attr('src')
if (query.length) { if (query.length) {
$('#searchBoxIcon').attr('src', '../img/clear.png') $('#searchBoxIcon').attr('src', iconUrl.replace('search.png', 'clear.png'))
$('#searchBoxIcon').css('cursor', 'pointer') $('#searchBoxIcon').css('cursor', 'pointer')
} else { } else {
$('#searchBoxIcon').attr('src', '../img/search.png') $('#searchBoxIcon').attr('src', iconUrl.replace('clear.png', 'search.png'))
$('#searchBoxIcon').css('cursor', 'default') $('#searchBoxIcon').css('cursor', 'default')
} }

View file

@ -1,4 +1,5 @@
{{ define "main"}} {{ define "main"}}
<h1>{{ .Title }}</h1>
{{ partial "header.html" . }} {{ partial "header.html" . }}
<!-- search box --> <!-- search box -->
<div id="searchBox"> <div id="searchBox">
@ -7,6 +8,14 @@
</div> </div>
<!-- search results --> <!-- search results -->
<div id="searchResults"></div> <div id="searchResults"></div>
<!-- tags -->
<div id="tags">
<ul>
{{ range .Site.Taxonomies.tags.ByCount }}
<li><a href="{{ .Page.Permalink }}">{{ .Page.Title }} ({{ .Count }})</a></li>
{{ end }}
</ul>
</div>
<!-- contents --> <!-- contents -->
<div id="contentsList"> <div id="contentsList">
{{ $listPageDateFormat := .Site.Params.listPageDateFormat | default "January, 2006"}} {{ $listPageDateFormat := .Site.Params.listPageDateFormat | default "January, 2006"}}

View file

@ -3,6 +3,7 @@
"ref": "{{ $page.Permalink }}", "ref": "{{ $page.Permalink }}",
"title": {{ $page.Title | jsonify }}, "title": {{ $page.Title | jsonify }},
"section": "{{ $page.Section }}", "section": "{{ $page.Section }}",
"tags": {{ $page.Params.tags | jsonify }},
"date" : {{ $page.Date.Format "2006.01.02" | jsonify }}, "date" : {{ $page.Date.Format "2006.01.02" | jsonify }},
"body": {{ $page.Plain | jsonify }} "body": {{ $page.Plain | jsonify }}
} }

View file

@ -1,6 +1,20 @@
{{ define "main"}} {{ define "main"}}
<h1 class='title'>{{ .Title }}</h1> <h1 class='title'>{{ .Title }}</h1>
{{ partial "header.html" . }} {{ partial "header.html" . }}
<!-- date -->
{{ $singlePageDateFormat := .Site.Params.singlePageDateFormat | default "January 2, 2006"}}
<p class="date">{{ .Date.Format $singlePageDateFormat }}</p>
<!-- tags -->
<div id="tags">
<ul>
{{ range .Param "tags" }}
{{ $name := . }}
{{ with $.Site.GetPage (printf "/tags/%s" ($name | urlize)) }}
<li><a href="{{ .Permalink }}">{{ $name }}</a></li>
{{ end }}
{{ end }}
</ul>
</div>
<!-- content --> <!-- content -->
<div id="contentBody"> <div id="contentBody">
{{ .Content }} {{ .Content }}

View file

@ -0,0 +1,13 @@
{{ define "main"}}
<h1>{{ .Title }}</h1>
{{ partial "header.html" . }}
<!-- tags -->
<div id="tags">
<ul>
{{ range .Site.Taxonomies.tags.ByCount }}
<li><a href="{{ .Page.Permalink }}">{{ .Page.Title }} ({{ .Count }})</a></li>
{{ end }}
</ul>
</div>
{{ partial "footer.html" . }}
{{ end }}

View file

@ -15,7 +15,7 @@
</header> </header>
<!-- description --> <!-- description -->
<p> <p>
{{ .Site.Params.description }} {{ .Site.Params.description | safeHTML }}
</p> </p>
<!-- navigation --> <!-- navigation -->
<nav> <nav>

View file

@ -9,7 +9,7 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="{{ .Site.Author }}" /> <meta name="author" content="{{ .Site.Params.Author }}" />
<link rel="shortcut icon" type="image/x-icon" href="/img/{{ .Site.Params.favicon }}"> <link rel="shortcut icon" type="image/x-icon" href="/img/{{ .Site.Params.favicon }}">
<!-- css --> <!-- css -->

View file

@ -2,7 +2,7 @@
<!-- avator --> <!-- avator -->
<div class="avatar"> <div class="avatar">
<img class="avatarMask" src="{{ .Site.BaseURL }}/img/{{ .Site.Params.avatar }}"> <img class="avatarMask" src="{{ .Site.BaseURL }}/img/{{ .Site.Params.avatar }}">
<a href="{{ .Site.BaseURL }}"><img src="{{ .Site.BaseURL }}/img/avatar-border.svg" }}></a> <a href="{{ .Site.BaseURL }}"><img src="{{ .Site.BaseURL }}/img/avatar-border.svg"></a>
</div> </div>
<!-- author --> <!-- author -->
<h2><a class="author" href="{{ .Site.BaseURL }}">{{ .Site.Params.Author }}</a></h2> <h2><a class="author" href="{{ .Site.BaseURL }}">{{ .Site.Params.Author }}</a></h2>

View file

@ -276,14 +276,16 @@ eslint-scope@^4.0.3:
estraverse "^4.1.1" estraverse "^4.1.1"
eslint-utils@^1.3.0, eslint-utils@^1.3.1: eslint-utils@^1.3.0, eslint-utils@^1.3.1:
version "1.3.1" version "1.4.2"
resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-1.3.1.tgz#9a851ba89ee7c460346f97cf8939c7298827e512" resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-1.4.2.tgz#166a5180ef6ab7eb462f162fd0e6f2463d7309ab"
integrity sha512-Z7YjnIldX+2XMcjr7ZkgEsOj/bREONV60qYeB/bjMAqqqZ4zxKyWX+BOUkdmRmA9riiIPVvo5x86m5elviOk0Q== integrity sha512-eAZS2sEUMlIeCjBeubdj45dmBHQwPHWyBcT1VSYB7o9x9WRRqKxyUoiXlRjyAwzN7YEzHJlYg0NmzDRWx6GP4Q==
dependencies:
eslint-visitor-keys "^1.0.0"
eslint-visitor-keys@^1.0.0: eslint-visitor-keys@^1.0.0:
version "1.0.0" version "1.1.0"
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#3f3180fb2e291017716acb4c9d6d5b5c34a6a81d" resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz#e2a82cea84ff246ad6fb57f9bde5b46621459ec2"
integrity sha512-qzm/XxIbxm/FHyH341ZrbnMUpe+5Bocte9xkmFMzPMjRaZMcXww+MpBptFvtU+79L362nqiLhekCxCxDPaUMBQ== integrity sha512-8y9YjtM1JBJU/A9Kc+SbaOV4y29sSWckBwMHa+FGtVj5gN/sbnKDf6xJUl+8g7FAij9LVaP8C24DUiH/f/2Z9A==
eslint@^5.15.3: eslint@^5.15.3:
version "5.15.3" version "5.15.3"
@ -571,9 +573,9 @@ js-tokens@^4.0.0:
integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==
js-yaml@^3.12.0: js-yaml@^3.12.0:
version "3.13.0" version "3.13.1"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.0.tgz#38ee7178ac0eea2c97ff6d96fff4b18c7d8cf98e" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847"
integrity sha512-pZZoSxcCYco+DIKBTimr67J6Hy+EYGZDY/HCWC+iAEA9h1ByhMXAIVUXMcMFpOCxQ/xjXmPI2MkDL5HRm5eFrQ== integrity sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==
dependencies: dependencies:
argparse "^1.0.7" argparse "^1.0.7"
esprima "^4.0.0" esprima "^4.0.0"
@ -615,9 +617,9 @@ locate-path@^2.0.0:
path-exists "^3.0.0" path-exists "^3.0.0"
lodash@^4.17.11: lodash@^4.17.11:
version "4.17.11" version "4.17.15"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg== integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==
mimic-fn@^1.0.0: mimic-fn@^1.0.0:
version "1.2.0" version "1.2.0"