mirror of https://github.com/jpanther/congo.git
Compare commits
37 Commits
693e834cb1
...
e9552734d8
Author | SHA1 | Date |
---|---|---|
Wen Junhua | e9552734d8 | |
James Panther | bce395070c | |
James Panther | 9433645cb6 | |
James Panther | c282e97333 | |
James Panther | 6d4cf0584b | |
James Panther | 3ce38cc6f0 | |
pomeloy | 9285958da9 | |
James Panther | c045ea2c3c | |
Amine LOUHICHI | a754abafa8 | |
James Panther | f7032c7844 | |
stupidjoey | c53eaf28ef | |
James Panther | c83eb3b698 | |
Jon Seager | eb866438a9 | |
James Panther | 4b85f9a13c | |
James Jarvis | 83d7a1422c | |
James Panther | 0e8f764870 | |
James Panther | 83d5984a53 | |
James Panther | 31fcdcf64e | |
pomeloy | c5f342c7f6 | |
James Panther | b21e8497e5 | |
James Panther | 08d0427688 | |
pomeloy | 1cf7d8bdd3 | |
pomeloy | 7d1b63b11d | |
pomeloy | 9a341f1724 | |
Wen Junhua | 2cf1371c3e | |
Wen Junhua | a1a2e10481 | |
Wen Junhua | 97a3f0064c | |
Wen Junhua | a7fa3be37d | |
Wen Junhua | 679898570c | |
Wen Junhua | db07288d01 | |
Wen Junhua | 3c81e00bed | |
Wen Junhua | eb527de54b | |
Wen Junhua | 3a998b4598 | |
Wolf Noble | 8e2de6c6dc | |
Wolf Noble | a1a6d6f468 | |
Wolf Noble | 92658f1b88 | |
stereobooster | f2af0198fa |
|
@ -33,7 +33,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|||
|
||||
- Hamburger menu is not dismissed when links are clicked ([#705](https://github.com/jpanther/congo/pull/705))
|
||||
- KaTeX, table and code elements wider than the page are not formatted correctly ([#753](https://github.com/jpanther/congo/pull/753))
|
||||
- Status bar styling is not applied in Safari on iOS ([#789](https://github.com/jpanther/congo/pull/789))
|
||||
- 'ß' character is output at the top of articles ([#764](https://github.com/jpanther/congo/pull/764))
|
||||
- Article metadata element is output when there is no metadata to display ([#786](https://github.com/jpanther/congo/pull/786))
|
||||
- Header elements not vertically centered when using locale switcher ([#788](https://github.com/jpanther/congo/pull/788))
|
||||
|
||||
### Removed
|
||||
|
||||
|
|
|
@ -8,13 +8,9 @@ function getCSSValue(varName) {
|
|||
|
||||
function setThemeColor() {
|
||||
var metaThemeColor = document.querySelector("meta[name=theme-color]");
|
||||
var metaAppleMobileWebAppStatusBarStyle = document.querySelector("meta[name=apple-mobile-web-app-status-bar-style]");
|
||||
document.documentElement.classList.contains("dark")
|
||||
? metaThemeColor.setAttribute("content", getCSSValue("--color-neutral-800"))
|
||||
: metaThemeColor.setAttribute("content", getCSSValue("--color-neutral"));
|
||||
document.documentElement.classList.contains("dark")
|
||||
? metaAppleMobileWebAppStatusBarStyle.setAttribute("content", getCSSValue("--color-neutral-800"))
|
||||
: metaAppleMobileWebAppStatusBarStyle.setAttribute("content", getCSSValue("--color-neutral"));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ Sitios web reales que se han creado con Congo.
|
|||
|
||||
La lista a continuación es solo un puñado de sitios web creados con el tema Congo. Échales un vistazo para descubrir algunos excelentes ejemplos de lo que el tema puede hacer.
|
||||
|
||||
| Website | Detalles |
|
||||
| Website | Details |
|
||||
| ---------------------------------------------------------------------- | ------------------------------- |
|
||||
| [jamespanther.com](https://jamespanther.com) | Personal site - Theme author |
|
||||
| [antoinesoetewey.com](https://antoinesoetewey.com/) | Personal site |
|
||||
|
@ -39,7 +39,6 @@ La lista a continuación es solo un puñado de sitios web creados con el tema Co
|
|||
| [Jh123x](https://jh123x.com/) | Personal site and Blog |
|
||||
| [sforzando LLC. and Inc.](https://sfz.dev/) | Corporate site and Blog |
|
||||
| [szegedkungfu.hu](https://balance-se.github.io/) | Sports association site |
|
||||
| [jcransom.com](https://www.jcransom.com/) | Personal Site and Blog |
|
||||
| [cbrincoveanu.com](https://www.cbrincoveanu.com/) | Personal site and Blog |
|
||||
| [medical-humanities](https://medical-humanities.org) | Academic site |
|
||||
| [boyersnet.com](https://boyersnet.com) | Personal site and Blog |
|
||||
|
@ -64,5 +63,12 @@ La lista a continuación es solo un puñado de sitios web creados con el tema Co
|
|||
| [simaosilva.com](https://simaosilva.com) | Personal Site |
|
||||
| [kom.al](https://kom.al) | Personal Site |
|
||||
| [andrea.mortaro.it](https://andrea.mortaro.it) | Personal Site and Blog |
|
||||
| [yoganath.me](https://yoganath.me) | Personal Site and Blog |
|
||||
| [josh-v.com](https://josh-v.com) | Personal Site and Tech blog |
|
||||
| [rshmhrj.io](https://rshmhrj.io/) | Personal Site and Tech blog |
|
||||
| [jamesjarvis.io](https://jamesjarvis.io) | Personal Site and Blog |
|
||||
| [jnsgr.uk](https://jnsgr.uk) | Personal site and blog |
|
||||
| [stupidjoey.net](https://stupidjoey.net) | Personal Site and Tech blog |
|
||||
| [aminelch.github.io](https://aminelch.github.io) | Personal Site and Blog |
|
||||
|
||||
**¿Usuaria de congo?** Para agregar tu sitio a esta lista, [haz un pull request](https://github.com/jpanther/congo/blob/dev/exampleSite/content/users/index.md).
|
||||
|
|
|
@ -39,7 +39,6 @@ Congoを使用して構築された実際のウェブサイト。
|
|||
| [Jh123x](https://jh123x.com/) | Personal site and Blog |
|
||||
| [sforzando LLC. and Inc.](https://sfz.dev/) | Corporate site and Blog |
|
||||
| [szegedkungfu.hu](https://balance-se.github.io/) | Sports association site |
|
||||
| [jcransom.com](https://www.jcransom.com/) | Personal Site and Blog |
|
||||
| [cbrincoveanu.com](https://www.cbrincoveanu.com/) | Personal site and Blog |
|
||||
| [medical-humanities](https://medical-humanities.org) | Academic site |
|
||||
| [boyersnet.com](https://boyersnet.com) | Personal site and Blog |
|
||||
|
@ -64,5 +63,12 @@ Congoを使用して構築された実際のウェブサイト。
|
|||
| [simaosilva.com](https://simaosilva.com) | Personal Site |
|
||||
| [kom.al](https://kom.al) | Personal Site |
|
||||
| [andrea.mortaro.it](https://andrea.mortaro.it) | Personal Site and Blog |
|
||||
| [yoganath.me](https://yoganath.me) | Personal Site and Blog |
|
||||
| [josh-v.com](https://josh-v.com) | Personal Site and Tech blog |
|
||||
| [rshmhrj.io](https://rshmhrj.io/) | Personal Site and Tech blog |
|
||||
| [jamesjarvis.io](https://jamesjarvis.io) | Personal Site and Blog |
|
||||
| [jnsgr.uk](https://jnsgr.uk) | Personal site and blog |
|
||||
| [stupidjoey.net](https://stupidjoey.net) | Personal Site and Tech blog |
|
||||
| [aminelch.github.io](https://aminelch.github.io) | Personal Site and Blog |
|
||||
|
||||
**Congoを使っていますか?** あなたのウェブサイトを加えるために[Pull Request](https://github.com/jpanther/congo/blob/dev/exampleSite/content/users/index.md)を投げてください。
|
||||
|
|
|
@ -39,7 +39,6 @@ The list below is just a handful of the websites that are built using the Congo
|
|||
| [Jh123x](https://jh123x.com/) | Personal site and Blog |
|
||||
| [sforzando LLC. and Inc.](https://sfz.dev/) | Corporate site and Blog |
|
||||
| [szegedkungfu.hu](https://balance-se.github.io/) | Sports association site |
|
||||
| [jcransom.com](https://www.jcransom.com/) | Personal Site and Blog |
|
||||
| [cbrincoveanu.com](https://www.cbrincoveanu.com/) | Personal site and Blog |
|
||||
| [medical-humanities](https://medical-humanities.org) | Academic site |
|
||||
| [boyersnet.com](https://boyersnet.com) | Personal site and Blog |
|
||||
|
@ -67,6 +66,9 @@ The list below is just a handful of the websites that are built using the Congo
|
|||
| [yoganath.me](https://yoganath.me) | Personal Site and Blog |
|
||||
| [josh-v.com](https://josh-v.com) | Personal Site and Tech blog |
|
||||
| [rshmhrj.io](https://rshmhrj.io/) | Personal Site and Tech blog |
|
||||
|
||||
| [jamesjarvis.io](https://jamesjarvis.io) | Personal Site and Blog |
|
||||
| [jnsgr.uk](https://jnsgr.uk) | Personal site and blog |
|
||||
| [stupidjoey.net](https://stupidjoey.net) | Personal Site and Tech blog |
|
||||
| [aminelch.github.io](https://aminelch.github.io) | Personal Site and Blog |
|
||||
|
||||
**Congo user?** To add your site to this list, [submit a pull request](https://github.com/jpanther/congo/blob/dev/exampleSite/content/users/index.md).
|
||||
|
|
|
@ -39,12 +39,10 @@ showEdit: false
|
|||
| [Jh123x](https://jh123x.com/) | Personal site and Blog |
|
||||
| [sforzando LLC. and Inc.](https://sfz.dev/) | Corporate site and Blog |
|
||||
| [szegedkungfu.hu](https://balance-se.github.io/) | Sports association site |
|
||||
| [jcransom.com](https://www.jcransom.com/) | Personal Site and Blog |
|
||||
| [cbrincoveanu.com](https://www.cbrincoveanu.com/) | Personal site and Blog |
|
||||
| [medical-humanities](https://medical-humanities.org) | Academic site |
|
||||
| [boyersnet.com](https://boyersnet.com) | Personal site and Blog |
|
||||
| [major.io](https://major.io) | Personal site and Blog |
|
||||
| [Rpengの博客](https://we1.top) | Personal site and Blog |
|
||||
| [顾宇的博客](https://www.guyu.me/) | Personal Blog (in Chinese) |
|
||||
| [cgutierr-zgz.github.io](https://cgutierr-zgz.github.io/) | Personal site and Tech blog |
|
||||
| [adam.sr](https://adam.sr) | Personal site and Blog |
|
||||
|
@ -65,6 +63,12 @@ showEdit: false
|
|||
| [simaosilva.com](https://simaosilva.com) | Personal Site |
|
||||
| [kom.al](https://kom.al) | Personal Site |
|
||||
| [andrea.mortaro.it](https://andrea.mortaro.it) | Personal Site and Blog |
|
||||
|
||||
| [yoganath.me](https://yoganath.me) | Personal Site and Blog |
|
||||
| [josh-v.com](https://josh-v.com) | Personal Site and Tech blog |
|
||||
| [rshmhrj.io](https://rshmhrj.io/) | Personal Site and Tech blog |
|
||||
| [jamesjarvis.io](https://jamesjarvis.io) | Personal Site and Blog |
|
||||
| [jnsgr.uk](https://jnsgr.uk) | Personal site and blog |
|
||||
| [stupidjoey.net](https://stupidjoey.net) | Personal Site and Tech blog |
|
||||
| [aminelch.github.io](https://aminelch.github.io) | Personal Site and Blog |
|
||||
|
||||
**想成为Congo的用户?** 要将您的网站添加到此列表中,请提交[Pull Request](https://github.com/jpanther/congo/blob/dev/exampleSite/content/users/index.md)来添加。
|
||||
|
|
|
@ -20,7 +20,9 @@
|
|||
|
||||
<figure>
|
||||
{{- with $img -}}
|
||||
{{ partial "picture.html" (dict "img" . "alt" $altText "class" $class "x2" $x2) }}
|
||||
{{ $lazy := $.Page.Site.Params.enableImageLazyLoading | default true }}
|
||||
{{ $webp := $.Page.Site.Params.enableImageWebp | default true }}
|
||||
{{ partial "picture.html" (dict "img" . "alt" $altText "class" $class "x2" $x2 "lazy" $lazy "webp" $webp) }}
|
||||
{{- else -}}
|
||||
<img src="{{ .Destination | safeURL }}" alt="{{ $altText }}" class="{{ $class }}" />
|
||||
{{- end -}}
|
||||
|
|
|
@ -10,14 +10,23 @@
|
|||
<h1 class="mt-0 text-4xl font-extrabold text-neutral-900 dark:text-neutral">
|
||||
{{ .Title | emojify }}
|
||||
</h1>
|
||||
{{ if or
|
||||
(.Params.showDate | default (.Site.Params.article.showDate | default true))
|
||||
(and (.Params.showDateUpdated | default (.Site.Params.article.showDateUpdated | default false)) (ne (partial "functions/date.html" .Date) (partial "functions/date.html" .Lastmod)))
|
||||
(and (.Params.showWordCount | default (.Site.Params.article.showWordCount | default false)) (ne .WordCount 0))
|
||||
(and (.Params.showReadingTime | default (.Site.Params.article.showReadingTime | default true)) (ne .ReadingTime 0))
|
||||
(.Params.showEdit | default (.Site.Params.article.showEdit | default false))
|
||||
}}
|
||||
<div class="mb-12 mt-8 text-base text-neutral-500 print:hidden dark:text-neutral-400">
|
||||
{{ partial "article-meta.html" (dict "context" . "scope" "single") }}
|
||||
</div>
|
||||
{{ end }}
|
||||
{{ with $feature }}
|
||||
<div class="prose">
|
||||
{{ $altText := $.Params.featureAlt | default $.Params.coverAlt | default "" }}
|
||||
{{ $class := "mb-6 -mt-4 rounded-md" }}
|
||||
{{ partial "picture.html" (dict "img" . "alt" $altText "class" $class "lazy" false) }}
|
||||
{{ $webp := $.Page.Site.Params.enableImageWebp | default true }}
|
||||
{{ partial "picture.html" (dict "img" . "alt" $altText "class" $class "lazy" false "webp" $webp) }}
|
||||
{{ with $.Params.coverCaption }}
|
||||
<figcaption class="-mt-3 mb-6 text-center">{{ . | markdownify }}</figcaption>
|
||||
{{ end }}
|
||||
|
|
|
@ -1,19 +1,12 @@
|
|||
{{ if .Params.showAuthor | default (.Site.Params.article.showAuthor | default true) }}
|
||||
<div class="flex">
|
||||
{{ $lazy := .Params.enableImageLazyLoading|default .Site.Params.enableImageLazyLoading | default true }}
|
||||
{{ $altText := ($.Site.Language.Params.Author.name | default "Author") }}
|
||||
{{ with .Site.Language.Params.Author.image }}
|
||||
{{ $authorImage := resources.Get . }}
|
||||
{{ if $authorImage }}
|
||||
{{ $authorImage := $authorImage.Fill "192x192 Center" }}
|
||||
<img
|
||||
class="!mb-0 !mt-0 me-4 h-24 w-24 rounded-full"
|
||||
width="96"
|
||||
height="96"
|
||||
alt="{{ $.Site.Language.Params.Author.name | default "Author" }}"
|
||||
src="{{ $authorImage.RelPermalink }}"
|
||||
{{ if $.Site.Params.enableImageLazyLoading | default true }}
|
||||
loading="lazy"
|
||||
{{ end }}
|
||||
/>
|
||||
{{ $imgClass := "!mb-0 !mt-0 me-4 w-24 h-auto rounded-full" }}
|
||||
{{ partial "picture.html" (dict "img" $authorImage "alt" $altText "class" $imgClass "lazy" $lazy ) }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
<div class="place-self-center">
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="theme-color" content="rgb(255,255,255)" />
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="rgb(255,255,255)" />
|
||||
{{/* Title */}}
|
||||
{{ if .IsHome -}}
|
||||
<title>{{ .Site.Title | emojify }}</title>
|
||||
|
|
|
@ -4,17 +4,13 @@
|
|||
{{ end }} flex flex-col items-center justify-center text-center"
|
||||
>
|
||||
<header class="mb-3 flex flex-col items-center">
|
||||
{{ $lazy := .Params.enableImageLazyLoading | default .Site.Params.enableImageLazyLoading | default true }}
|
||||
{{ $altText := ($.Site.Language.Params.Author.name | default "Author") }}
|
||||
{{ with .Site.Language.Params.Author.image }}
|
||||
{{ $authorImage := resources.Get . }}
|
||||
{{ if $authorImage }}
|
||||
{{ $authorImage := $authorImage.Fill "288x288 Center" }}
|
||||
<img
|
||||
class="mb-2 h-36 w-36 rounded-full"
|
||||
width="144"
|
||||
height="144"
|
||||
alt="{{ $.Site.Language.Params.Author.name | default "Author" }}"
|
||||
src="{{ $authorImage.RelPermalink }}"
|
||||
/>
|
||||
{{ $imgClass := "mb-2 h-auto w-36 rounded-full" }}
|
||||
{{ partial "picture.html" (dict "img" $authorImage "alt" $altText "class" $imgClass "lazy" $lazy) }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
<h1 class="text-4xl font-extrabold">
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
{{ $img := .img }}
|
||||
{{ $alt := .alt }}
|
||||
{{ $class := .class }}
|
||||
{{ $lazy := .lazy | default $.Page.Site.Params.enableImageLazyLoading | default true }}
|
||||
{{ $webp := .webp | default $.Page.Site.Params.enableImageWebp | default true }}
|
||||
{{ $lazy := .lazy }}
|
||||
{{ $webp := .webp }}
|
||||
{{ $lqip := .lqip | default false }}
|
||||
{{ $x2 := .x2 | default false }}
|
||||
|
||||
|
@ -57,7 +57,7 @@
|
|||
<source
|
||||
{{ if lt .Width 660 }}
|
||||
{{ with .Resize (printf "%dx%d webp" .Width .Height) }}
|
||||
src="{{ .RelPermalink }}"
|
||||
srcset="{{ .RelPermalink }}"
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
srcset=" {{- (.Resize "330x webp").RelPermalink }} 330w,
|
||||
|
@ -70,19 +70,18 @@
|
|||
{{ end }}
|
||||
{{ end }}
|
||||
{{ if gt .Width 1320 }}
|
||||
,{{ (.Resize "1320x webp").RelPermalink }} 2x
|
||||
,{{ (.Resize "1320x webp").RelPermalink }} 1320w
|
||||
{{ else }}
|
||||
{{ with .Resize (printf "%dx%d webp" .Width .Height) }}
|
||||
,{{ .RelPermalink }} {{ .Width }}w
|
||||
{{ end }}
|
||||
{{ end }}"
|
||||
src="{{ (.Resize "660x webp").RelPermalink }}"
|
||||
{{ end }}
|
||||
sizes="100vw"
|
||||
type="image/webp"
|
||||
/>
|
||||
{{ end }}
|
||||
<img
|
||||
src="{{ .RelPermalink }}"
|
||||
width="{{ $width }}"
|
||||
height="{{ $height }}"
|
||||
{{ with $class }}class="{{ . }}"{{ end }}
|
||||
|
@ -91,20 +90,20 @@
|
|||
{{ if lt .Width 660 }}
|
||||
src="{{ .RelPermalink }}"
|
||||
{{ else }}
|
||||
src="{{ (.Resize "660x").RelPermalink }}"
|
||||
srcset=" {{- (.Resize "330x").RelPermalink }} 330w,
|
||||
{{- (.Resize "660x").RelPermalink }}
|
||||
660w
|
||||
{{- (.Resize "660x").RelPermalink }} 660w
|
||||
{{ if gt .Width 1024 }}
|
||||
,{{ (.Resize "1024x").RelPermalink }} 1024w
|
||||
{{ else }}
|
||||
,{{ .RelPermalink }} {{ .Width }}w
|
||||
{{ end }}
|
||||
{{ if gt .Width 1320 }}
|
||||
,{{ (.Resize "1320x").RelPermalink }} 2x
|
||||
,{{ (.Resize "1320x").RelPermalink }} 1320w
|
||||
{{ else }}
|
||||
,{{ .RelPermalink }} {{ .Width }}w
|
||||
{{ end }}"
|
||||
src="{{ (.Resize "660x").RelPermalink }}"
|
||||
sizes="100vw"
|
||||
{{ end }}
|
||||
/>
|
||||
</picture>
|
||||
|
|
|
@ -20,10 +20,10 @@
|
|||
>
|
||||
</button>
|
||||
{{ if eq $dir "down" }}
|
||||
<div class="invisible h-2 w-full bg-transparent group-hover:visible"></div>
|
||||
<div class="invisible w-full bg-transparent group-hover:visible"></div>
|
||||
{{ end }}
|
||||
<div
|
||||
class="{{ cond (eq $dir "down") "top-8" "bottom-7" }} invisible absolute z-50 flex flex-col whitespace-nowrap rounded border border-neutral-300 bg-neutral text-start text-base shadow group-hover:visible ltr:right-0 rtl:left-0 dark:border-neutral-600 dark:bg-neutral-800"
|
||||
class="{{ if not (eq $dir "down") }} bottom-7 {{ end }} invisible absolute z-50 flex flex-col whitespace-nowrap rounded border border-neutral-300 bg-neutral text-start text-base shadow group-hover:visible ltr:right-0 rtl:left-0 dark:border-neutral-600 dark:bg-neutral-800"
|
||||
>
|
||||
{{ $siteLanguages := site.Languages }}
|
||||
{{ $pageLang := .Page.Lang }}
|
||||
|
|
|
@ -19,7 +19,9 @@
|
|||
{{ with $href }}<a href="{{ . }}">{{ end }}
|
||||
|
||||
{{- with $img -}}
|
||||
{{ partial "picture.html" (dict "img" . "alt" $altText "class" $class) }}
|
||||
{{ $lazy := $.Page.Site.Params.enableImageLazyLoading | default true }}
|
||||
{{ $webp := $.Page.Site.Params.enableImageWebp | default true }}
|
||||
{{ partial "picture.html" (dict "img" . "alt" $altText "class" $class "lazy" $lazy "webp" $webp) }}
|
||||
{{- else -}}
|
||||
<img src="{{ $url.String }}" alt="{{ $altText }}" class="{{ $class }}"/>
|
||||
{{- end -}}
|
||||
|
|
|
@ -13,7 +13,9 @@
|
|||
{{ $altText = (.Get "caption") | markdownify | plainify }}
|
||||
{{ end }}
|
||||
|
||||
{{ partial "picture.html" (dict "img" $image "alt" $altText "x2" true) }}
|
||||
{{ $lazy := $.Page.Site.Params.enableImageLazyLoading | default true }}
|
||||
{{ $webp := $.Page.Site.Params.enableImageWebp | default true }}
|
||||
{{ partial "picture.html" (dict "img" $image "alt" $altText "x2" true "lazy" $lazy "webp" $webp) }}
|
||||
|
||||
{{- if .Get "href" }}</a>{{ end -}}
|
||||
{{- if .Get "caption" -}}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -9,7 +9,8 @@
|
|||
"dev": "NODE_ENV=development ./node_modules/tailwindcss/lib/cli.js -i ./assets/css/main.css -o ./assets/css/compiled/main.css --jit -w",
|
||||
"build": "NODE_ENV=production ./node_modules/tailwindcss/lib/cli.js -i ./assets/css/main.css -o ./assets/css/compiled/main.css --jit",
|
||||
"example": "hugo server --bind 0.0.0.0 -p 8008 --source exampleSite --themesDir ../.. --buildDrafts -b http://localhost/congo/ ",
|
||||
"lighthouse": "lhci autorun"
|
||||
"lighthouse": "lhci autorun",
|
||||
"add-icon": "node scripts/index.js add-icon"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -32,6 +33,7 @@
|
|||
"@tailwindcss/typography": "^0.5.10",
|
||||
"chart.js": "^4.4.1",
|
||||
"fuse.js": "^7.0.0",
|
||||
"jsdom": "^23.0.1",
|
||||
"katex": "^0.16.9",
|
||||
"mermaid": "^10.7.0",
|
||||
"prettier": "^3.2.4",
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/env node
|
||||
const { program } = require("commander");
|
||||
const { add_icon_to_congo } = require("./update_icon");
|
||||
|
||||
// Adds an icon to the project.
|
||||
program
|
||||
.command("add-icon <icon_name>")
|
||||
.description("Add icon to the project")
|
||||
.action(add_icon_to_congo);
|
||||
|
||||
program.parse(process.argv);
|
|
@ -0,0 +1,97 @@
|
|||
const jsdom = require("jsdom");
|
||||
const fs = require("fs");
|
||||
|
||||
const DOC_DIR = "./exampleSite/content/samples/icons";
|
||||
const FONTAWESOME_VERSION = "v6.5.1";
|
||||
const DEFAULT_TABLE_DELIMITER = "| -------------------- | --------------------------------- |";
|
||||
|
||||
/**
|
||||
* Saves an icon to the congo project and update documentation.
|
||||
* @param {string} icon_name Icon name from Font Awesome to download
|
||||
* @returns null
|
||||
*/
|
||||
const add_icon_to_congo = async (icon_name) => {
|
||||
try {
|
||||
const icon_url = create_icon_url(icon_name, FONTAWESOME_VERSION);
|
||||
const file = await get_file(icon_url);
|
||||
const final_svg = modify_svg_string(file);
|
||||
const icon_download_path = create_icon_download_path(icon_name);
|
||||
save_file(icon_download_path, final_svg);
|
||||
add_documentation(icon_name);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
const modify_svg_string = (svg_string) => {
|
||||
try {
|
||||
dom = new jsdom.JSDOM(svg_string);
|
||||
svg = dom.window.document.documentElement.querySelector("svg");
|
||||
svg.querySelector("path").setAttribute("fill", "currentColor");
|
||||
return svg.outerHTML;
|
||||
} catch (e) {
|
||||
throw new Error("Invalid SVG file");
|
||||
}
|
||||
};
|
||||
|
||||
const create_icon_url = (icon_name, fontawesome_version) => {
|
||||
return `https://site-assets.fontawesome.com/releases/${fontawesome_version}/svgs/brands/${icon_name}.svg`;
|
||||
};
|
||||
|
||||
const create_icon_download_path = (icon_name) => {
|
||||
return `./assets/icons/${icon_name}.svg`;
|
||||
};
|
||||
|
||||
const get_file = async (url) => {
|
||||
console.log("Getting file at " + url + "...");
|
||||
const response = await fetch(url);
|
||||
if (response.status >= 400) {
|
||||
throw new Error("Could not download icon / icon not found");
|
||||
}
|
||||
console.log("File retrieved!");
|
||||
return response.text();
|
||||
};
|
||||
|
||||
const save_file = (file_path, file) => {
|
||||
console.log("Saving file at " + file_path + "...");
|
||||
fs.writeFile(file_path, file, function (err) {
|
||||
if (err) throw err;
|
||||
console.log("File saved!");
|
||||
});
|
||||
};
|
||||
|
||||
const add_documentation = async (icon_name) => {
|
||||
files = get_md_docs();
|
||||
|
||||
for (const file of files) {
|
||||
const file_path = `${DOC_DIR}/${file}`;
|
||||
const file_contents = fs.readFileSync(file_path, "utf8");
|
||||
const file_result = process_file(file_contents, icon_name);
|
||||
// Save file_result to file_path
|
||||
fs.writeFile(file_path, file_result, function (err) {
|
||||
if (err) throw err;
|
||||
});
|
||||
console.log(`Updated ${file_path}`);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Process the file contents to include the icon name.
|
||||
* @param {string} file_contents contents of the documentation files.
|
||||
* @returns {string} processed file contents.
|
||||
*/
|
||||
const process_file = (file_contents, icon_name) => {
|
||||
const [headers, table] = file_contents.split(DEFAULT_TABLE_DELIMITER);
|
||||
const table_rows = table.split("\n").map((x) => x.trim()).filter((row) => row !== "");
|
||||
table_rows.push(table_rows[0].replace("amazon", icon_name));
|
||||
table_rows.sort();
|
||||
const new_table = table_rows.join("\n");
|
||||
return `${headers.trimEnd()}\n${DEFAULT_TABLE_DELIMITER}\n${new_table}\n`;
|
||||
};
|
||||
|
||||
const get_md_docs = () => {
|
||||
return fs.readdirSync(DOC_DIR).filter((file) => file.endsWith(".md"));
|
||||
};
|
||||
|
||||
module.exports = { add_icon_to_congo };
|
Loading…
Reference in New Issue