Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredwray committed Aug 2, 2023
1 parent c38bdd0 commit 739e288
Show file tree
Hide file tree
Showing 113 changed files with 259 additions and 336 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

strategy:
matrix:
node-version: ['16', '18']
node-version: ['16', '18', '20']

steps:
- uses: actions/checkout@v3
Expand All @@ -26,11 +26,11 @@ jobs:
run: yarn

- name: Testing
run: yarn run test
run: yarn test

- name: Code Coverage
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_KEY }}
files: packages/writr-cli/coverage/coverage-final.json
files: coverage/coverage-final.json

189 changes: 158 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,56 +1,183 @@
![Writr](logo.png)
![Writr](../../logo.png)

> Enabling the world to write better via Markdown
---

### CLI Tool for Markdown
[![Build](https://github.com/jaredwray/writr/actions/workflows/tests.yml/badge.svg)](https://github.com/jaredwray/writr/actions/workflows/tests.yml)
[![GitHub license](https://img.shields.io/github/license/jaredwray/writr)](https://github.com/jaredwray/writr/blob/master/LICENSE)
[![codecov](https://codecov.io/gh/jaredwray/writr/branch/master/graph/badge.svg?token=1YdMesM07X)](https://codecov.io/gh/jaredwray/writr)
[![npm](https://img.shields.io/npm/dm/writr)](https://npmjs.com/package/writr)

# How to Use the Writr Mono Repo
---

Writr provides readme information for each of its packages. In addtion we have a couple of other documents for review:
## Getting Started

* [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) - Our code of conduct
* [CONTRIBUTING.md](CONTRIBUTING.md) - How to contribute to this project
* [SECURITY.md](SECURITY.md) - Security guidelines and supported versions
## 1. Install Writr

## Getting Started
> npm install -g writr
Writr is designed to make it easier to write with Markdown.
## 2. Setup your directory (look at /blog_example for how to do this)

## Open a Pull Request
> writr init
You can contribute changes to this repo by opening a pull request:
```
blog/*.md //markdown files in the folder root
blog/images //images for the blog
blog/config.json //config file (optional)
blog/templates //template directory for your index, post, and tag
```

1) After forking this repository to your Git account, make the proposed changes on your forked branch.
2) Run tests and linting locally using `yarn test`
3) Commit your changes and push them to your forked repository.
4) Navigate to the main `writr` repository and select the *Pull Requests* tab.
5) Click the *New pull request* button, then select the option "Compare across forks"
6) Leave the base branch set to main. Set the compare branch to your forked branch, and open the pull request.
7) Once your pull request is created, ensure that all checks have passed and that your branch has no conflicts with the base branch. If there are any issues, resolve these changes in your local repository, and then commit and push them to git.
8) Similarly, respond to any reviewer comments or requests for changes by making edits to your local repository and pushing them to Git.
9) Once the pull request has been reviewed, those with write access to the branch will be able to merge your changes into the `writr` repository.
## 3. Create your first post

If you need more information on the steps to create a pull request, you can find a detailed walkthrough in the [Github documentation](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork)
> writr new
## Post an Issue
This will allow you to answer a couple questions to setup your first blog post.

To post an issue, navigate to the "Issues" tab in the main repository, and then select "New Issue." Enter a clear title describing the issue, as well as a description containing additional relevant information. Also select the label that best describes your issue type. For a bug report, for example, create an issue with the label "bug." In the description field, Be sure to include replication steps, as well as any relevant error messages.
## 4. Run Writr on it with defaults. This will output everything to ./blog_output

If you're reporting a security violation, be sure to check out the project's [security policy](https://github.com/jaredwray/writr/blob/main/SECURITY.md).
> writr
Please also refer to our [Code of Conduct](https://github.com/jaredwray/writr/blob/main/CODE_OF_CONDUCT.md) for more information on how to report issues.
## 5. You can serve your blog with a simple webserver

## Ask a Question
> writr serve
To ask a question, create an issue with the label "question." In the issue description, include the related code and any context that can help us answer your question.
## 4. Integrate your blog with Express

## Packages in this Repository
Then in express map your `blog_output` via static files:

* [writr-cli](https://github.com/jaredwray/writr/tree/main/packages/writr-cli): command line interface for exports, rendering, and more with markdown files
```javascript
app.use("/blog/*/images", express.static(path.join(__dirname, "blog_output/images")))
app.use("/blog/images", express.static(path.join(__dirname, "blog_output/images")))
app.use("/blog", express.static(path.join(__dirname, "blog_output")))
```

## License
---

MIT © Jared Wray
## CLI

* -h, --help: Output usage information
* -p, --path: Path of where the blog, and config are located
* -o, --output: Path of where to output the generated blog
* -r, --render: What do you want rendered such as html or json (example --render html,json)
* -c, --config: Configuration file location if different than 'path'
* init: Initialize a new blog
* new: Create a new blog post
* serve: Serve the blog. You can also specify a port with --port and --watch for hot reloading

## Templates

There are three templates that are part of every instance of Writr. By default it goes in the `/blog/templates` directory. Here are the files and are in `Handlebars` format:
* index.hjs: This is the main template that lists all of the latest blogs or what you want to add.
* post.hjs: The post itself and usually supporting items around that such as what is next to look at and tags.
* tag.hjs: Showing articles by tag filtering.

## Template Partials

You can use template partials such as a header or footer by creating a folder in templates called `partials`. In there create a standard handlebars template file such as `header.hjs`. To reference it go to any of the main template files and include it like `{{> header}}`:

```html
<h1>Post</h1>

{{> header}}

<p>{{post.title}}</p>
<p>{{post.author}}</p>
<p>{{{post.body}}}</p>

<p>{{post.matter.featured_image}}</p>

<p>{{previousPost.id}}</p>
<p>{{nextPost.id}}</p>
...
```

## Different Templates / Layouts

You can also set a post to use a different layout by setting the `layout` value in the `front-matter` like so:

```yaml
---
title: 'Docula: Persistent Links and Styles!'
tags:
- Github
- Open Source
- Docula
date: 2017-03-07
layout: post2
featured_image: Docula_%20Persistent%20Links%20and%20Styles%201.jpeg
---
```

## Permalinks

In your posts `front-matter` you can specify the format of the url to be generated. By default is the `:title` (also known as the `none` style) that is formatted correctly.

### Variables

| Variable | Description |
| --- | ----------- |
| year | Year from the post’s filename with four digits. |
| short_year | Year from the post’s filename without the century. (00..99) |
| month | Month from the post’s filename. (01..12) |
| i_month | Month without leading zeros |
| short_month | Three-letter month abbreviation, e.g. "Dec". |
| long_month | Full month name, e.g. “January”. |
| day | Day of the month from the post’s filename. (01..31) |
| i_day | Day of the month without leading zeros from the post’s filename. |
| y_day | Day of the year (01...365) |
| short_day | Three-letter weekday abbreviation, e.g. “Sun”. |
| long_day | Weekday name, e.g. “Sunday”. |
| week | Week number of the current year, starting with the first week having a majority of its days in January. (01..53) |
| hour | Hour of the day, 24-hour clock, zero-padded from the post’s date front matter. (00..23) |
| minute | Minute of the hour from the post’s date front matter. (00..59) |
| second | Second of the minute from the post’s date front matter. (00..59) |
| title | Title from the document’s front matter. |


### Default Styles

You can simply put in the style on permalink setting in the individual post `front-matter` or globally in `config.json`

| Style | Template |
| --- | ----------- |
| default | /:title/ |
| date | /:year/:month/:day/:title/ |
| ordinal | /:year/:y_day/:title/ |


#### Set Layout it in the Post

```yaml
---
title: 'Docula: Persistent Links and Styles!'
tags:
- Github
- Open Source
- Docula
permalink: date
date: 2017-03-07
layout: post2
featured_image: Docula_%20Persistent%20Links%20and%20Styles%201.jpeg
---
```

The url will be: `/2017/03/07/docula-persistent-links-and-styles`

#### Set Layout Globally

To set it globally you can set it in the `config.json` by setting the `permaLink` variable like so:
```javascript
{
"output" : "./blog_output",
"render": [ "html" , "json", "atom", "images"],
"path": "./blog_example",
"title": "Example Blog",
"url": "https://writr.io/blog",
"authorName": "Jared Wray",
"authorEmail": "[email protected]",
"permalink": ":year/:month/:title"
}
```

## Markdown
To learn more about Markdown go here: https://markdownguide.org
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
115 changes: 98 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,102 @@
{
"name": "@writr/mono-repo",
"version": "1.0.0",
"description": "Writr Mono Repo",
"repository": "https://github.com/jaredwray/writr.git",
"author": "Jared Wray <[email protected]>",
"license": "MIT",
"private": true,
"workspaces": [
"packages/*"
"name": "writr",
"version": "1.9.10",
"description": "A Simple to Use Markdown Blog",
"type": "module",
"exports": "./dist/index.js",
"types": "./dist/index.d.ts",
"repository": "https://github.com/jaredwray/writr.git",
"author": "Jared Wray <[email protected]>",
"license": "MIT",
"keywords": [
"static-site-generator",
"static-site",
"ssg",
"documentation",
"website",
"blog",
"templates",
"generator",
"framework",
"writr",
"writer",
"html",
"markdown",
"handlebars"
],
"scripts": {
"watch": "tsc -w -p .",
"clean-all": "npm run clean && rm -rf node_modules && rm -rf coverage && rm -rf package-lock.json && rm -rf ./test/output",
"clean": "rm -rf ./dist && npm run clean-output",
"clean-output": "rm -rf ./blog_output && rm -rf ./test_output",
"compile": "npm run clean && tsc -p .",
"build": "npm run test && npm run compile",
"test": "npm run clean-output && NODE_OPTIONS=--experimental-vm-modules jest --coverage --runInBand && npm run clean-output",
"test-output": "npm run compile && node ./bin/writr.js -p ./blog_example"
},
"bin": {
"writr": "./bin/writr.js"
},
"dependencies": {
"array-sort": "^1.0.0",
"axios": "^1.4.0",
"browser-sync": "^2.29.3",
"cheerio": "^1.0.0-rc.12",
"commander": "^11.0.0",
"ecto": "^2.1.13",
"feed": "^4.2.2",
"fs-extra": "^11.1.1",
"gray-matter": "^4.0.3",
"inquirer": "^9.2.9",
"keyv": "^4.5.3",
"luxon": "^3.3.0",
"moment": "^2.29.4",
"node-html-markdown": "^1.3.0",
"parse-json": "^7.0.0",
"striptags": "^3.2.0",
"winston": "^3.10.0"
},
"devDependencies": {
"@types/array-sort": "^1.0.0",
"@types/browser-sync": "^2.27.0",
"@types/fs-extra": "^11.0.1",
"@types/inquirer": "^9.0.3",
"@types/jest": "^29.5.3",
"@types/keyv": "^3.1.4",
"@types/luxon": "^3.3.1",
"@types/node": "^20.4.5",
"@types/parse-json": "^4.0.0",
"jest": "^29.6.2",
"jest-ts-webcompat-resolver": "^1.0.0",
"jest-resolve": "^29.6.2",
"source-map-support": "^0.5.21",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typescript": "^5.1.6"
},
"files": [
"dist",
"bin",
"init"
],
"jest": {
"moduleFileExtensions": [
"ts",
"js"
],
"scripts": {
"test": "yarn workspaces run test",
"coverage": "yarn workspaces run coverage",
"clean": "rm -rf node_modules && rm -rf yarn.lock && yarn workspaces run clean"
"transform": {
"^.+\\.[jt]sx?$": [
"ts-jest",
{
"useESM": true,
"tsconfig": "tsconfig.json"
}
]
},
"dependencies": {
"@types/node": "^20.2.5"
}
"testMatch": [
"**/test/**/*.test.(ts)"
],
"resolver": "jest-ts-webcompat-resolver",
"testEnvironment": "node"
}
}
Loading

0 comments on commit 739e288

Please sign in to comment.