Skip to content

Commit

Permalink
chore: add content path
Browse files Browse the repository at this point in the history
  • Loading branch information
K-Sato1995 committed Jan 26, 2024
1 parent 5a4ae28 commit cbeaae9
Show file tree
Hide file tree
Showing 5 changed files with 161 additions and 2 deletions.
3 changes: 3 additions & 0 deletions config/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package config

const GENERATED_HTML_DIR = "generated"
const TEMPLATE_DIR = "templates"
const CONTENT_DIR = "contents"

type SiteInfo struct {
Title string
Expand All @@ -10,6 +11,7 @@ type SiteInfo struct {
type Config struct {
TemplatePath string // dir that contains base html/css
GeneratedPath string // dir that contains generated html/css
ContentPath string // dir that contains markdown files
SiteInfo SiteInfo
HotReloadServerPort int
}
Expand All @@ -18,6 +20,7 @@ func NewConfig(custom Config) Config {
config := Config{
TemplatePath: TEMPLATE_DIR,
GeneratedPath: GENERATED_HTML_DIR,
ContentPath: CONTENT_DIR,
SiteInfo: SiteInfo{
Title: "My Blog",
Description: "This is my blog",
Expand Down
44 changes: 44 additions & 0 deletions example/contents/created-ssg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
----
- Title: Created a simple ssg in Go
- Description: Lorem markdownum tanta. Per aperto et neinferre nefandis dicta caloriseffugere dies fallacibus placidi illam inter agitat me viderat in.
- PublishedDate: 2024-01-23
----

# Ut manet Dardaniam obliquat cruorem urbi fugiebant

## Non anxia terruit Lenis dempta succidit nebulas

Lorem markdownum tanta. Per aperto et ne *tenent* inferre nefandis dicta caloris
effugere dies fallacibus placidi illam inter agitat me viderat in.

1. Illa ut agmen
2. Tanta illo Hectoris fauces tumefecit pascua in
3. Fulvis crines consiste vulnera arces minabitur Lynceus
4. Tu erigite Cecropios sortes pulsavere nostra citra
5. Modo ipse pallorem deorum Britannos cadmus

Vixque mala mensas quam **defodit undas media**. Dabat laudisque, verba quibus
torrentis Troiana est et cruorem inque. *Ut nomina* venientis vitio nec: sunt
patria, tot atque spectante. Silva se Ephyren peti denique. Territa pharetrae
iugulo radiosque habent, qui traxit inquit **canes digitis** Narcissum quoque.

- Pamphagos corpora armis Leucothoe perfusam
- Esset an palmas paulumque nimium
- Non pariterque veteris rexit duo ferro
- Esse confinia

## Iuno vita recessu

Nasamoniaci iuventa Cinyphius: tellus non eadem, cornua mea lustro a quam urbem
inminet vultum, quid erimus creat. Centumque remis rima tacitus erit. *Diu*
vectus quod? Sit has, **usum** operum annus tota culta ac dicit domus **pisces
viro** et. Abiit Saturnia exsultat tenebat.

Amat rogat simul enim poma amores innumerae haerebat *mentem* vota domesticus
parta undis: quid et! Facis obstitit sistrum nescisse Solis [etiamnunc
haec](http://surrexere-ramis.com/saxo); nunc furor sanguine sub fusus quem avi
traiecta. Potentior a mortalia lapillis virtutis dei, reduxi, sola.

Ipsos incomitata dixit patebat. Pudorque meo spectante esse adimunt patet illos
poenas colla dabat; invasit coronas ignarus non meis qui conditor **solvere**.
In carchesia pennis O felicia nervi ab adiciunt prodis, quam errorem.
100 changes: 100 additions & 0 deletions example/generated/created-ssg.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="title" content="Go Simple SSG"/>
<meta name="description" content="Lorem markdownum tanta. Per aperto et neinferre nefandis dicta caloriseffugere dies fallacibus placidi illam inter agitat me viderat in."/>
<title>Created a simple ssg in Go</title>

<link rel="stylesheet" href="./detail.css">
</head>
<body>
<div class="container">
<nav class="header">
<a href="/" class="header__title">Go Simple SSG</a>
<ul class="header__links">
<li class="header__links_item">
<a href="/" class="header__links__item__link">Home</a>
</li>
<li class="header__links_item">
<a href="/about.html" class="header__links__item__link">About</a>
</li>
</ul>
</nav>

<div class="post-detail">
<div class="post-detail__top">
<h1 class="post-detail__top__title">Created a simple ssg in Go</h1>
<div class="post-detail__top__info">
<span class="post-detail__top__info__date">
2024-01-23,
</span>
<a class="post-detail__top__info__author" href="/about.html">by K-Sato</a>
</div>
</div>

<div class="post-detail__content">
<h1 id="ut-manet-dardaniam-obliquat-cruorem-urbi-fugiebant">Ut manet Dardaniam obliquat cruorem urbi fugiebant</h1>

<h2 id="non-anxia-terruit-lenis-dempta-succidit-nebulas">Non anxia terruit Lenis dempta succidit nebulas</h2>

<p>Lorem markdownum tanta. Per aperto et ne <em>tenent</em> inferre nefandis dicta caloris
effugere dies fallacibus placidi illaminter agitat me viderat in.</p>

<ol>
<li>Illa ut agmen</li>
<li>Tanta illo Hectoris fauces tumefecit pascua in</li>
<li>Fulvis crines consiste vulnera arces minabitur Lynceus</li>
<li>Tu erigite Cecropios sortes pulsavere nostra citra</li>
<li>Modo ipse pallorem deorum Britannos cadmus</li>
</ol>

<p>Vixque mala mensas quam <strong>defodit undas media</strong>. Dabat laudisque, verba quibus
torrentis Troiana est et cruorem inque. <em>Ut nomina</em> venientis vitio nec: sunt
patria, tot atque spectante. Silva se Ephyren peti denique. Territa pharetrae
iugulo radiosque habent, qui traxit inquit <strong>canes digitis</strong> Narcissum quoque.</p>

<ul>
<li>Pamphagos corpora armis Leucothoe perfusam</li>
<li>Esset an palmas paulumque nimium</li>
<li>Non pariterque veteris rexit duo ferro</li>
<li>Esse confinia</li>
</ul>

<h2 id="iuno-vita-recessu">Iuno vita recessu</h2>

<p>Nasamoniaci iuventa Cinyphius: tellus non eadem, cornua mea lustro a quam urbem
inminet vultum, quid erimus creat. Centumque remis rima tacitus erit. <em>Diu</em>
vectus quod? Sit has, <strong>usum</strong> operum annus tota culta ac dicit domus <strong>pisces
viro</strong> et. Abiit Saturnia exsultat tenebat.</p>

<p>Amat rogat simul enim poma amores innumerae haerebat <em>mentem</em> vota domesticus
parta undis: quid et! Facis obstitit sistrum nescisse Solis <a href="http://surrexere-ramis.com/saxo" target="_blank">etiamnunc
haec</a>; nunc furor sanguine sub fusus quem avi
traiecta. Potentior a mortalia lapillis virtutis dei, reduxi, sola.</p>

<p>Ipsos incomitata dixit patebat. Pudorque meo spectante esse adimunt patet illos
poenas colla dabat; invasit coronas ignarus non meis qui conditor <strong>solvere</strong>.
In carchesia pennis O felicia nervi ab adiciunt prodis, quam errorem.</p>

</div>
</div>


<footer class="footer">
<ul class="footer__links">
<li class="footer__links_item">
<a href="/" class="footer__links__item__link">Home</a>
</li>
<li class="footer__links_item">
<a href="/about.html" class="footer__links__item__link">About</a>
</li>
<li class="footer__links_item">
<span class="footer__copy-right">© 2021 K-Sato</span>
</li>
</ul>
</footer>
</div>
</body>
</html>
9 changes: 9 additions & 0 deletions example/generated/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@
</nav>
<div class="content">

<div class="post-item">
<p class="post-item__date">2024-01-23</p>
<h2 class="post-item__title">
<a class="post-item__title__link" href="created-ssg.html">Created a simple ssg in Go</a
>
</h2>
<p class="post-item__description">Lorem markdownum tanta. Per aperto et neinferre nefandis dicta caloriseffugere dies fallacibus placidi illam inter agitat me viderat in.</p>
</div>

<div class="post-item">
<p class="post-item__date">2024-01-23</p>
<h2 class="post-item__title">
Expand Down
7 changes: 5 additions & 2 deletions example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func main() {
},
})
engine := gosimplessg.New(baseConfig)
go startHMR(baseConfig.TemplatePath, engine)
go startHMR(baseConfig.TemplatePath, baseConfig.ContentPath, engine)
serveFiles()
}

Expand All @@ -32,12 +32,15 @@ func serveFiles() {
}
}

func startHMR(templatePath string, engine *gosimplessg.Engine) {
func startHMR(templatePath string, contentPath string, engine *gosimplessg.Engine) {
w := watcher.New()
w.FilterOps(watcher.Write)
if err := w.AddRecursive(templatePath); err != nil {
log.Fatal(err)
}
if err := w.AddRecursive(contentPath); err != nil {
log.Fatal(err)
}
go func() {
for {
select {
Expand Down

0 comments on commit cbeaae9

Please sign in to comment.