Skip to content

Commit

Permalink
(merge) refactor: restructure project and merge template data
Browse files Browse the repository at this point in the history
  • Loading branch information
anirudhsudhir authored Mar 5, 2024
2 parents bd77f48 + bc77047 commit 052c74f
Show file tree
Hide file tree
Showing 11 changed files with 370 additions and 330 deletions.
56 changes: 38 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ The ssg currently requires the following directory structure

```text
ssg/
|--content/
| |--index.md (This file is necessary and cannot be omitted)
| |--about.md
|--content/
| |--index.md (This file is necessary and cannot be omitted)
| |--about.md
| |--posts/
| |--post1.md
| ....
| ....
|
|--layout/
|--layout/
| |--page.html (This file is necessary and cannot be omitted)
| |--posts.html (This file is necessary to create a 'Posts' section)
| |--posts.html (This file is necessary to create a 'Posts' section)
| |--partials/
| |--header.html
| ....
Expand Down Expand Up @@ -45,20 +45,22 @@ ssg/
- Static assets such as images and fonts are stored in static/
- The layout of the site is configured using html files in layout/

- The 'config.yml' file stores the configuration of the site and includes details such as the baseURL
- The 'page.html' file defines the layout of a basic page of the site
- The 'posts.html' file defines the layout of a page displaying all the posts of the site
- The layout files can be composed of smaller html files which are stored in the partials/ folder
- The 'config.yml' file stores the configuration of the site and includes details such as the baseURL
- The 'page.html' file defines the layout of a basic page of the site
- The 'posts.html' file defines the layout of a page displaying all the posts of the site
- The layout files can be composed of smaller html files which are stored in the partials/ folder

#### Layout

The layout files can access the following rendered data from the markdown files:

- {{.Body}} : Returns the markdown body rendered to HTML
- {{.Filename}} : Returns the name of the current file
- {{.Date}} : Returns the last modified date of the current file
- {{.Frontmatter.[Tagname]}} : Returns the value of the frontmatter tag
- Example: {{.Frontmatter.Title}} : Returns the value of the title tag
- Example: {{.Frontmatter.Title}} : Returns the value of the title tag
- {{.Layout.[Tagname]}}: Returns the particular configuration detail of the page
- Example: {{.Layout.Navbar}} : Returns a string slice with the names of all the navbar elements
- Example: {{.Layout.Navbar}} : Returns a string slice with the names of all the navbar elements

## Notes

Expand All @@ -67,21 +69,35 @@ The layout files can access the following rendered data from the markdown files:
2. CSS: CSS can be added in the following ways:

- In an external file in the 'static/' directory and linked to the layout files
- To link the stylesheet, use the baseURL along with the relative path

Example: `<link rel="stylesheet" href="{{.Layout.BaseURL}}static/style.css">`
- To link the stylesheet, use the baseURL along with the relative path

Example: `<link rel="stylesheet" href="{{.Layout.BaseURL}}static/style.css">`

- Placed inside `<style></style>` tags in the `<head></head>` of the layout files
- Inline with the html elements

3. Frontmatter: Metadata such as the title of the page can be added as frontmatter to the markdown files in the YAML format. Currently, the following tags are supported:

- title : The title of the current page
- date: The date of the current page
- draft: When set to 'true', the current page is not rendered unless the '-d' flag is used
- type: Sets the type of the page. Use type 'post' for posts
- previewimage: Stores the preview image of the current page
- description: Stores the description of the current post previewed in posts.html
- scripts: Stores a slice of javascript files to be included with the current page only

(**The above tags are Frontmatter tags**)

4. config.yml: This file stores additional information regarding the layout
4. config.yml: This file stores additional information regarding the layout of the site

- navbar: Stores the links to be added to the navbar (same name as the markdown files)
- baseURL: Stores the base URL of the site
- siteTitle: Stores the name of the site
- siteScripts: Stores the javascript files to be included with every page. The following scripts are currently available:
- prism.js : Provides syntax highlighting for code blocks

(**The above tags are Layout tags**)

Sample config.yml:

Expand All @@ -93,13 +109,17 @@ navbar:
baseURL: http://localhost:8000/
# Replace this with the actual canonical-url of your site.

# baseURL tells search-engines (SEO), web-crawlers (robots.txt) so people can discover your site on the internet.
# It's also embeded in your sitemap / atom feed and can be used to change metadata about your site.
# baseURL tells search-engines (SEO), web-crawlers (robots.txt) so people can discover your site on the internet.
# It's also embeded in your sitemap / atom feed and can be used to change metadata about your site.

siteTitle: ssg
siteScripts:
- prism.js
```
## Flags
```
```text
Usage:
ssg [flags]

Expand Down
Loading

0 comments on commit 052c74f

Please sign in to comment.