-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit afeb197
Showing
18 changed files
with
232 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
github: razonyang | ||
custom: | ||
- https://paypal.me/razonyang | ||
- https://afdian.com/a/razonyang |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: lint | ||
|
||
on: | ||
push: | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 16 | ||
- run: npm i | ||
- run: npm run lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
name: release-please | ||
|
||
jobs: | ||
release-please: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: googleapis/release-please-action@v4 | ||
with: | ||
command: manifest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
public/ | ||
resources/ | ||
.hugo_build.lock | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
pull_request_rules: | ||
- name: Automatic merge for Renovate pull requests | ||
conditions: | ||
- author=renovate[bot] | ||
actions: | ||
merge: | ||
method: rebase | ||
|
||
- name: Automatic merge on approval | ||
conditions: | ||
- "#approved-reviews-by>=1" | ||
actions: | ||
merge: | ||
method: rebase |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
".": "0.0.1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
**/*.tmpl.scss |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": "stylelint-config-standard-scss", | ||
"rules": { | ||
"at-rule-no-unknown": null, | ||
"color-function-notation": null, | ||
"scss/at-rule-no-unknown": true, | ||
"scss/at-extend-no-missing-placeholder": null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 HugoMods Authors | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Hugo Cookies Module | ||
|
||
[![Used By](https://flat.badgen.net/github/dependents-repo/hugomods/cookies?icon=github&label=used+by&color=green)](https://github.com/hugomods/cookies/network/dependents) | ||
![Hugo Requirements](https://img.shields.io/badge/dynamic/json?color=important&label=requirements&query=requirements&logo=hugo&style=flat-square&url=https://api.razonyang.com/v1/hugo/modules/github.com/hugomods/cookies) | ||
[![License](https://flat.badgen.net/github/license/hugomods/cookies)](https://github.com/hugomods/cookies/blob/main/LICENSE) | ||
[![Version](https://flat.badgen.net/github/tag/hugomods/cookies)](https://github.com/hugomods/cookies/tags) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
let cookies: Record<string, string> = {} | ||
|
||
export const getCookies = (fresh = false): Record<string, string> => { | ||
if (fresh) { | ||
cookies = {} | ||
} | ||
|
||
if (Object.keys(cookies).length === 0 && document.cookie !== '') { | ||
for (const cookie of document.cookie.split(';')) { | ||
const match = cookie.trim().match(/([^=]+)=(.+)/) | ||
if (match === null || match.length < 3) { | ||
continue | ||
} | ||
|
||
cookies[match[1]] = match[2] | ||
} | ||
} | ||
|
||
return cookies | ||
} | ||
|
||
export const getCookie = (name: string, fresh = false): null | string => { | ||
return getCookies(fresh)[name] ?? null | ||
} | ||
|
||
export interface CookieOptions { | ||
path?: string | ||
expires?: Date | ||
maxAge?: number | ||
secure?: boolean | ||
sameSite?: string | ||
} | ||
|
||
export const setCookie = (name: string, value: string, options: CookieOptions = {}): void => { | ||
const cookie: string[] = [] | ||
cookie.push(`${name}=${value}`) | ||
if (options.path !== undefined) { | ||
cookie.push(`Path=${options.path}`) | ||
} | ||
if (options.maxAge !== undefined) { | ||
cookie.push(`Max-Age=${options.maxAge}`) | ||
} | ||
if (options.expires !== undefined) { | ||
cookie.push(`Expires=${options.expires.toUTCString()}`) | ||
} | ||
if (options.secure === true) { | ||
cookie.push('Secure') | ||
} | ||
if (options.sameSite !== undefined) { | ||
cookie.push(`SameSite=${options.sameSite}`) | ||
} | ||
|
||
document.cookie = cookie.join(';') | ||
} | ||
|
||
export const deleteCookie = (name: string, options: CookieOptions = {}): void => { | ||
setCookie(name, '', Object.assign(options, { maxAge: 0 })) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module github.com/hugomods/cookies | ||
|
||
go 1.18 |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"name": "@hugomods/cookies", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/hugomods/cookies.git" | ||
}, | ||
"author": "Razon Yang <[email protected]>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/hugomods/cookies/issues" | ||
}, | ||
"homepage": "https://github.com/hugomods/cookies", | ||
"devDependencies": { | ||
"@hugomods/prettier-config": "^0.1.0", | ||
"@tsconfig/recommended": "^1.0.2", | ||
"stylelint": "^16.0.0", | ||
"stylelint-config-standard-scss": "^13.0.0", | ||
"stylelint-scss": "^6.0.0", | ||
"ts-standard": "^12.0.2", | ||
"typescript": "^5.7.2" | ||
}, | ||
"scripts": { | ||
"lint": "npm run lint:standard", | ||
"lint:prettier": "prettier **/*.html i18n/* data/* **/*.md --check", | ||
"lint:prettier:fix": "prettier **/*.html i18n/* data/* **/*.md -w", | ||
"lint:standard": "ts-standard .", | ||
"lint:standard:fix": "ts-standard --fix .", | ||
"lint:style": "stylelint \"**/*.scss\"", | ||
"lint:style:fix": "stylelint \"**/*.scss\" --fix" | ||
}, | ||
"prettier": "@hugomods/prettier-config" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", | ||
"monorepo-tags": true, | ||
"release-type": "go", | ||
"tag-separator": "/", | ||
"changelog-sections": [ | ||
{ "type": "chore", "section": "Miscellaneous Chores", "hidden": true }, | ||
{ "type": "ci", "section": "Continuous Integration" }, | ||
{ "type": "docs", "section": "Documentation 📝" }, | ||
{ "type": "feat", "section": "Features ✨" }, | ||
{ "type": "feature", "section": "Features ✨" }, | ||
{ "type": "fix", "section": "Bug Fixes 🐞" }, | ||
{ "type": "perf", "section": "Performance Improvements ⚡️" }, | ||
{ "type": "style", "section": "Styles 🎨" } | ||
], | ||
"packages": { | ||
".": { | ||
"exclude-paths": [ | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"$schema": "https://docs.renovatebot.com/renovate-schema.json", | ||
"extends": [ | ||
"config:base" | ||
], | ||
"packageRules": [ | ||
{ | ||
"matchManagers": [ "gomod" ], | ||
"matchDepTypes": [ "indirect" ], | ||
"enabled": true | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": "@tsconfig/recommended/tsconfig.json", | ||
"compilerOptions": { | ||
"preserveConstEnums": true, | ||
"strictNullChecks": true | ||
}, | ||
"include": ["assets/**/*"], | ||
"exclude": ["node_modules"] | ||
} |