Skip to content

Commit

Permalink
feat: reorganize project structure
Browse files Browse the repository at this point in the history
  • Loading branch information
K-Sato1995 committed Jan 24, 2024
1 parent 1d4bd97 commit cc52c20
Show file tree
Hide file tree
Showing 14 changed files with 257 additions and 0 deletions.
16 changes: 16 additions & 0 deletions baseProject/contents/test.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
----
- Title: Test
- Description: description
----

# Heading1

description1

## Heading2

description1

- list
- item
- item
22 changes: 22 additions & 0 deletions baseProject/contents/testMd.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
----
- Title: "SSG"
- Description: "description"
----

# Go ssg generator
## Overview

- template: svelte
- generator: go (write this)

## Steps

- define svelte/md code
- run gen
- get md data in go
- run svelte compiler with template with the given data

## Refs

- https://github.com/zupzup/blog-generator
- https://www.zupzup.org/static-blog-generator-go/index.html
7 changes: 7 additions & 0 deletions baseProject/generated/detail.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* templates/detail.css */
.detail_title {
font-size: 1.5rem;
font-weight: 600;
margin-bottom: .5rem;
color: red;
}
7 changes: 7 additions & 0 deletions baseProject/generated/layout.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* templates/layout.css */
.description {
font-size: 1.2rem;
font-weight: 300;
line-height: 1.5;
margin-bottom: 1.5rem;
}
15 changes: 15 additions & 0 deletions baseProject/generated/list.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* templates/layout.css */
.description {
font-size: 1.2rem;
font-weight: 300;
line-height: 1.5;
margin-bottom: 1.5rem;
}

/* templates/list.css */
.title {
font-size: 1.5rem;
font-weight: 600;
margin-bottom: .5rem;
color: red;
}
24 changes: 24 additions & 0 deletions baseProject/generated/list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!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="Articles List"/>
<meta name="description" content="List of articles"/>

<link rel="stylesheet" href="./list.css">
<title>Articles</title>
</head>
<body>
<div id="content">
<h1 id="title">Articles</h1>
<ul>

<li><a href="generated/test.html">Test</a></li>

<li><a href="generated/testMd.html">SSG</a></li>

</ul>
</div>
</body>
</html>
34 changes: 34 additions & 0 deletions baseProject/generated/test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!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="Example Title"/>
<meta name="description" content="Example Description"/>
<title>My Page Title</title>

<link rel="stylesheet" href="./detail.css">
</head>
<body>
<div id="content">
<h1 class="detail_title">My Page Title</h1>
<h1 id="heading1">Heading1</h1>

<p>description1</p>

<h2 id="heading2">Heading2</h2>

<p>description1</p>

<ul>
<li>list

<ul>
<li>item</li>
<li>item</li>
</ul></li>
</ul>

</div>
</body>
</html>
45 changes: 45 additions & 0 deletions baseProject/generated/testMd.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!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="Example Title"/>
<meta name="description" content="Example Description"/>
<title>My Page Title</title>

<link rel="stylesheet" href="./detail.css">
</head>
<body>
<div id="content">
<h1 class="detail_title">My Page Title</h1>
<h1 id="go-ssg-generator">Go ssg generator</h1>

<h2 id="overview">Overview</h2>

<ul>
<li>template: svelte</li>
<li>generator: go (write this)</li>
</ul>

<h2 id="steps">Steps</h2>

<ul>
<li>define svelte/md code</li>
<li>run gen

<ul>
<li>get md data in go</li>
<li>run svelte compiler with template with the given data</li>
</ul></li>
</ul>

<h2 id="refs">Refs</h2>

<ul>
<li><a href="https://github.com/zupzup/blog-generator" target="_blank">https://github.com/zupzup/blog-generator</a></li>
<li><a href="https://www.zupzup.org/static-blog-generator-go/index.html" target="_blank">https://www.zupzup.org/static-blog-generator-go/index.html</a></li>
</ul>

</div>
</body>
</html>
26 changes: 26 additions & 0 deletions baseProject/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package main

import (
gosimplessg "go-simple-ssg"
"go-simple-ssg/config"
"log"
"net/http"
)

func main() {
baseConfig := config.NewConfig(config.Config{})
engine := gosimplessg.New(baseConfig)
engine.Build()
serveFiles()

}

func serveFiles() {
fs := http.FileServer(http.Dir(config.GENERATED_HTML_DIR))
http.Handle("/", fs)
log.Println("Serving files on http://localhost:8080...")
err := http.ListenAndServe(":8081", nil)
if err != nil {
log.Fatal(err)
}
}
7 changes: 7 additions & 0 deletions baseProject/templates/detail.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

.detail_title {
font-size: 1.5rem;
font-weight: 600;
margin-bottom: 0.5rem;
color: red;
}
18 changes: 18 additions & 0 deletions baseProject/templates/detail.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!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="{{.HTMLTitle}}"/>
<meta name="description" content="{{.MetaDescription}}"/>
<title>{{.PageTitle}}</title>
<!-- Generated path -->
<link rel="stylesheet" href="./detail.css">
</head>
<body>
<div id="content">
<h1 class="detail_title">{{.PageTitle}}</h1>
{{.Content}}
</div>
</body>
</html>
7 changes: 7 additions & 0 deletions baseProject/templates/layout.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

.description {
font-size: 1.2rem;
font-weight: 300;
line-height: 1.5;
margin-bottom: 1.5rem;
}
7 changes: 7 additions & 0 deletions baseProject/templates/list.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@import url("./layout.css");
.title {
font-size: 1.5rem;
font-weight: 600;
margin-bottom: 0.5rem;
color: red;
}
22 changes: 22 additions & 0 deletions baseProject/templates/list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!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="{{.HTMLTitle}}"/>
<meta name="description" content="{{.MetaDescription}}"/>
<!-- Generated path -->
<link rel="stylesheet" href="./list.css">
<title>{{.PageTitle}}</title>
</head>
<body>
<div id="content">
<h1 id="title">{{.PageTitle}}</h1>
<ul>
{{range .Articles}}
<li><a href="{{.Path}}">{{.Title}}</a></li>
{{end}}
</ul>
</div>
</body>
</html>

0 comments on commit cc52c20

Please sign in to comment.