Home

Awesome

Hakuba screenshots

Hakuba

中文版介绍

Hakuba (白馬村 , Hakuba-mura) is a village located in Nagano Prefecture, Japan. If you enjoy hiking or climbing, skiing or other activities, this would be a great place to go (btw I haven't been there yet...)

A fast blog starter that reads data off GitHub Discussions.

See how fast it is in action!!

Please star and fork if you like it!

How Does It Work

Hakuba fetches the contents on GitHub Discussions with GitHub GraphQL API and webhooks. Then renders the actual blog pages from them.

Quick Start

Recommended hosting services:

The output directory named build.

Deploy with Vercel:
Deploy with Vercel

... or continue scrolling for guide about manual deployment

Hakuba just a blog starter,data and code are completely separated,so you can create a empty repository to write posts and pages discussion, and write a script to clone this repository and build.

The advantage of this is that you can easily deploy your blog and don't need to worry about code updates.

Configuration

There are various ways to configure it, you can choose to configure it all using environment variables, or partly through discussion.

If configured blog through discussion, title must be index, category must be CONFIG_CATEGORY, Here is an example.

NameDescriptionRequiredenvconfigured through discussion
GITHUB_TOKENRequire a access token with permissions in the public_repo scope for public repositories, or the repo scope for private ones.
REPOSITORYThe target repository
CONFIG_CATEGORYCategory name of posts for configuration purposes on GitHub Discussion. Config at default.
POST_CATEGORYCategory name of actual posts on GitHub Discussion. Post at default.
PAGE_CATEGORYCategory name of posts for dedicated pages on GitHub Discussion. Page at default.
PAGE_SIZENumber Category name of posts for configuration purposes in GitHub Discussion.kof posts per page, 10 at default.
BLOG_NAMEName of the blog, Hakuba fetches it from GitHub profile if left blank.
BIOBiography of the block, Hakuba fetches it from GitHub profile if left blank.
EMAILEmail for contact in the about section
TWITTERTwitter handle without the leading @ (e.g. SvelteJS)
DOMAINDomain of the blog. RSS feed will be disabled if left blank.
DESCRIPTIONDescription of the blog in SEO metadata.
KEYWORDSKeywords for SEO metadata.
COMMENTWhether to enable comments, true at default.
LANGUAGELanguage of the block in form of HTML language code. en at default.
TIMEZONETimezone of Date.prototype.toLocaleDateString(locals, options), GMT at default.

Setup GitHub Discussions

Create discussions categories for configurations, posts, and pages. Then Set their format to Announcement.

Hakuba supports mdx and HTML script tags for pages and posts, so don't make them public-editable❗❗❗

Only the page named index will be used as the main configuration. Here is an example.

Setup Webhooks

If you deployed Hakuba using vercel, netlify or Cloudflare Pages, update of the contents could be automated with webhooks when discussions are modified.

Manual Deployment

Clone the repository with git:

git clone git@github.com:YeungKC/Hakuba.git

Then, generate the pages:

# Run any one of them

yarn build
npm run build
pnpm build

Finally, upload the build directory to your web server.

Update code

If you are using a fork or clone, you need to run the following command:

git remote add upstream https://github.com/YeungKC/Hakuba.git
git fetch upstream/master
git merge upstream/master
git push origin master

Additional Settings for Pages and Posts

Pages and posts support Markdown front matter for metadata and configuration overrides.

Front matter for pages

Added page will be displayed in navigation.

If you added page title is __error, it will be replaced the error page.

Here is an example

namedesc
langLanguage of the post in the form of html language attribute
commentWhether to enable comments
priorityPriority for indexing
pathPath to the page, use all lowercase title by default
excerptExcerpt of the page for SEO metadata

Post front matter

Here is an example

namedesc
langLanguage of the post in the form of html language tag
commentWhether to enable comments
pathPath to the post, use discussion number by default
excerptExcerpt of the page for SEO metadata
titleTitle of the post. Hakuba uses the title of the discussion post at default.
publishedDate published. Hakuba uses the date of the discussion post at default.
updatedDate updated. Hakuba uses the latest date of modification of the discussion post at default.
timezoneTimezone of Date.prototype.toLocaleDateString(locals, options), config.TIMEZONE at default.

Limitations

Because use Mdsvex to preprocess the markdown, the following limitations apply:

In markdown you can begin a code block by indenting 4 spaces. This doesn’t work in mdsvex as indentation is common with XML-based languages. Indenting 4 spaces will do nothing.

see also: https://mdsvex.com/docs#limitations

Dependabot Auto Merge

This project uses action-dependabot-auto-merge for updating dependencies automatically. If there is a CI failure, try to configure Dependabot secrets.

Migrate

Clone this repository, configure GITHUB_TOKEN and REPOSITORY environment variables, install dependencies with package manager and run:

# Run any one of them

npm run generateData
yarn generateData
pnpm generateData

The post path is src/routes/post/_source/[discussion number].md and the page path is src/routes/_page/[title].md.

Roadmap

Credits

License

GPL-3.0