├── .editorconfig ├── .gitattributes ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── PULL_REQUEST_TEMPLATE.md ├── issue_label_bot.yaml └── workflows │ └── ci.yml ├── .gitignore ├── .npmrc ├── .prettierrc ├── .vscode ├── launch.json └── settings.json ├── CONTRIBUTING.md ├── KNOWN_ISSUES.md ├── LICENSE ├── README.md ├── circle.yml ├── examples ├── extract-css │ ├── README.md │ ├── css │ │ └── global.css │ ├── package.json │ ├── pages │ │ ├── about.vue │ │ └── index.vue │ ├── saber-browser.js │ └── saber-config.js └── vue-composition-api │ ├── README.md │ ├── package.json │ ├── pages │ └── index.vue │ └── saber-browser.js ├── lerna.json ├── other-packages ├── eslint-config-saber │ ├── CHANGELOG.md │ ├── index.js │ └── package.json └── extract-sfc-blocks │ ├── CHANGELOG.md │ ├── index.js │ └── package.json ├── package.json ├── packages ├── create-blog │ ├── CHANGELOG.md │ ├── LICENSE │ ├── cli.js │ └── package.json ├── create-site │ ├── CHANGELOG.md │ ├── LICENSE │ ├── cli.js │ ├── package.json │ └── template │ │ ├── .gitignore │ │ ├── README.md │ │ ├── package.json │ │ ├── pages │ │ ├── _posts │ │ │ ├── my-example-post.md │ │ │ ├── super-long-article.md │ │ │ └── super-short-article.md │ │ ├── about.md │ │ └── index.md │ │ ├── public │ │ └── favicon.ico │ │ └── saber-config.yml ├── saber-highlight-css │ ├── CHANGELOG.md │ ├── LICENSE │ ├── default.css │ └── package.json ├── saber-highlighter-prism │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── index.js │ ├── loadLanguages.js │ └── package.json ├── saber-log │ ├── CHANGELOG.md │ ├── LICENSE │ ├── package.json │ ├── rollup.config.js │ ├── src │ │ ├── colors.ts │ │ └── index.ts │ └── tsconfig.json ├── saber-markdown │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── babel-plugin-vue-features.js │ ├── package.json │ ├── rollup.config.js │ └── src │ │ └── index.js ├── saber-plugin-code-copy │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── lib │ │ ├── index.js │ │ └── saber-browser.js │ └── package.json ├── saber-plugin-feed │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── example │ │ ├── pages │ │ │ └── _posts │ │ │ │ ├── bye-world.md │ │ │ │ └── hello-world.md │ │ └── saber-config.yml │ ├── lib │ │ ├── index.js │ │ ├── saber-browser.js │ │ └── utils.js │ └── package.json ├── saber-plugin-git-modification-time │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── lib │ │ └── index.js │ └── package.json ├── saber-plugin-google-analytics │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── index.js │ ├── package.json │ └── saber-browser.js ├── saber-plugin-image │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── lib │ │ ├── index.js │ │ ├── saber-browser.js │ │ └── styles.module.css │ └── package.json ├── saber-plugin-meta-redirect │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── example │ │ ├── pages │ │ │ ├── about.md │ │ │ └── index.md │ │ ├── saber-config.yml │ │ └── saber-node.js │ ├── lib │ │ └── index.js │ └── package.json ├── saber-plugin-netlify-redirect │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── example │ │ ├── pages │ │ │ ├── about.md │ │ │ └── index.md │ │ ├── public │ │ │ └── _redirects │ │ ├── saber-config.yml │ │ └── saber-node.js │ ├── lib │ │ └── index.js │ └── package.json ├── saber-plugin-prismjs │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── index.js │ └── package.json ├── saber-plugin-pwa │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── lib │ │ ├── create-element.js │ │ ├── generate-manifest.js │ │ ├── get-app-config.js │ │ ├── index.js │ │ ├── noop-sw-middleware.js │ │ └── saber-browser.js │ └── package.json ├── saber-plugin-query-posts │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── lib │ │ ├── index.js │ │ └── utils.js │ └── package.json ├── saber-plugin-search │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── lib │ │ ├── index.js │ │ └── saber-browser.js │ └── package.json ├── saber-plugin-transformer-html │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── example │ │ ├── pages │ │ │ └── index.html │ │ └── saber-config.yml │ ├── lib │ │ └── index.js │ └── package.json ├── saber-plugin-transformer-pug │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── example │ │ ├── pages │ │ │ ├── about.vue │ │ │ └── index.pug │ │ └── saber-config.yml │ ├── lib │ │ ├── index.js │ │ └── pug-plain-loader.js │ └── package.json ├── saber-utils │ ├── CHANGELOG.md │ ├── LICENSE │ ├── build.js │ ├── index.d.ts │ ├── index.js │ ├── package.json │ └── src │ │ ├── fs.js │ │ ├── glob.js │ │ └── isAbsoluteUrl.js └── saber │ ├── .eslintignore │ ├── .eslintrc.js │ ├── CHANGELOG.md │ ├── LICENSE │ ├── babel.js │ ├── declarations.d.ts │ ├── example │ ├── pages │ │ ├── _bar │ │ │ └── hehe.md │ │ ├── _foo.vue │ │ ├── _posts │ │ │ ├── bar.md │ │ │ └── foo.md │ │ ├── about.md │ │ ├── hehe.css │ │ ├── hehe.module.css │ │ ├── hehe.vue │ │ ├── index.md │ │ └── wow.js │ ├── public │ │ └── test.txt │ ├── saber-browser.js │ ├── saber-config.json │ ├── saber-node.js │ └── src │ │ └── sum.js │ ├── jest.config.js │ ├── package.json │ ├── src │ ├── BrowserApi.ts │ ├── Compiler.ts │ ├── Pages.ts │ ├── Transformers.ts │ ├── WebpackUtils.ts │ ├── babel │ │ └── preset.js │ ├── cli-commands │ │ ├── build.js │ │ ├── dev.js │ │ ├── eject-theme.js │ │ ├── index.js │ │ ├── serve.js │ │ └── utils.js │ ├── cli.js │ ├── config-chain │ │ ├── Options.js │ │ ├── Plugin.js │ │ └── index.js │ ├── hooks.ts │ ├── index.ts │ ├── markdown │ │ ├── __test__ │ │ │ ├── __snapshots__ │ │ │ │ └── highlight-plugin.test.js.snap │ │ │ ├── create-env.js │ │ │ ├── excerpt-plugin.test.js │ │ │ ├── headings-plugin.test.js │ │ │ └── highlight-plugin.test.js │ │ ├── escape-interpolations-plugin.js │ │ ├── excerpt-plugin.js │ │ ├── headings-plugin.js │ │ ├── highlight-plugin.js │ │ ├── hoist-tags-plugin.js │ │ └── task-list-plugin.js │ ├── plugins │ │ ├── config-css.js │ │ ├── config-font.js │ │ ├── config-image.js │ │ ├── config-other-loaders.js │ │ ├── emit-runtime-polyfills.js │ │ ├── emit-saber-variables.js │ │ ├── extend-browser-api.js │ │ ├── extend-node-api.js │ │ ├── index.js │ │ ├── layouts.ts │ │ ├── source-pages.ts │ │ ├── transformer-components.js │ │ ├── transformer-default.js │ │ ├── transformer-markdown.js │ │ └── watch-config.ts │ ├── utils │ │ ├── __test__ │ │ │ ├── getPermalink.test.js │ │ │ └── resolvePackage.test.js │ │ ├── assetsAttribute.ts │ │ ├── configLoader.js │ │ ├── getFileNames.js │ │ ├── getPageType.js │ │ ├── getPermalink.js │ │ ├── inspectWebpack.js │ │ ├── parseAttributes.js │ │ ├── parseFrontmatter.js │ │ ├── prettyBytes.js │ │ ├── resolvePackage.js │ │ ├── serveDir.js │ │ ├── toml.min.js │ │ ├── validateConfig.ts │ │ └── yaml.min.js │ ├── vue-renderer │ │ ├── get-initial-document-data.js │ │ ├── get-initial-document.js │ │ ├── index.js │ │ ├── page-prop-loader.js │ │ ├── render-html.js │ │ ├── saber-page-loader.js │ │ ├── template-plugins │ │ │ ├── __test__ │ │ │ │ └── link.test.js │ │ │ ├── index.js │ │ │ └── link.js │ │ ├── transform-template-loader.js │ │ └── utils.js │ └── webpack │ │ ├── PrintStatusPlugin.js │ │ ├── babel-loader.js │ │ ├── toml-loader.js │ │ ├── webpack.config.js │ │ └── yaml-loader.js │ ├── tsconfig.json │ └── vue-app │ ├── 404.vue │ ├── components │ ├── ClientOnly.js │ ├── LayoutManager.vue │ └── SaberLink.js │ ├── create-app.js │ ├── dev-client.js │ ├── entry-client.js │ ├── entry-server.js │ ├── helpers │ ├── inject-config.js │ ├── path.js │ ├── scroll-handler.js │ └── set-transition.js │ ├── polyfills.js │ ├── router.js │ ├── theme │ └── layouts │ │ └── default.vue │ ├── utils │ └── is-absolute-url.js │ └── vendor │ └── promise.js ├── scripts └── release-pr.js ├── tsconfig.base.json ├── website ├── images │ ├── gh-pages-setting.png │ ├── logo-square.jpeg │ ├── logo.png │ └── simple-index-md-page.png ├── package.json ├── pages │ ├── _posts │ │ ├── html-and-pug-page │ │ │ ├── 1.webp │ │ │ ├── 2.webp │ │ │ ├── 3.gif │ │ │ ├── 4.webp │ │ │ └── index.md │ │ ├── integrate-netlify-forms │ │ │ └── index.md │ │ └── saber │ │ │ ├── index.md │ │ │ └── size-compare.png │ ├── blog │ │ └── index.md │ ├── docs │ │ ├── browser-apis.md │ │ ├── components.md │ │ ├── css-modules.md │ │ ├── css-preprocessors.md │ │ ├── deployment.md │ │ ├── i18n.md │ │ ├── images-fonts-and-files.md │ │ ├── index.md │ │ ├── installation.md │ │ ├── layouts.md │ │ ├── manipulating-head.md │ │ ├── markdown-features.md │ │ ├── node-apis.md │ │ ├── page-interface.md │ │ ├── page-transition.md │ │ ├── pages.md │ │ ├── permalinks.md │ │ ├── plugin-api.md │ │ ├── postcss.md │ │ ├── project-structure.md │ │ ├── routing.md │ │ ├── saber-config.md │ │ ├── saber-instance.md │ │ ├── static-folder.md │ │ ├── themes.md │ │ ├── using-vue-in-markdown.md │ │ └── working-with-webpack.md │ ├── index.vue │ ├── themes │ │ ├── _themes.yml │ │ ├── index.vue │ │ └── previews │ │ │ ├── saber-theme-minima.png │ │ │ └── saber-theme-tailsaw.png │ └── tutorial │ │ ├── images │ │ ├── about.png │ │ ├── first-page.png │ │ ├── hello-world.png │ │ ├── navbar-dumb.gif │ │ ├── not-found.png │ │ ├── post-list.png │ │ ├── prev-next-post.gif │ │ └── vue-devtools-page-prop.png │ │ └── tutorial.md ├── postcss.config.js ├── saber-config.js ├── saber-node.js ├── src │ ├── components │ │ ├── Header.vue │ │ ├── Logo.vue │ │ ├── PostList.vue │ │ ├── PostMeta.vue │ │ ├── Search.vue │ │ ├── Sidebar.vue │ │ ├── SiteNav.vue │ │ ├── SiteSearch.vue │ │ ├── Toc.vue │ │ ├── Vercel.vue │ │ └── Wrap.vue │ ├── css │ │ ├── button.css │ │ ├── global.css │ │ ├── page.css │ │ └── prism.css │ ├── layouts │ │ ├── blog.vue │ │ ├── docs.vue │ │ ├── index.vue │ │ ├── post.vue │ │ └── tutorial.vue │ ├── mixins │ │ └── doc.js │ └── saber-browser.js ├── static │ ├── _redirects │ ├── img │ │ ├── icons │ │ │ ├── icon_128x128.png │ │ │ ├── icon_16x16.png │ │ │ ├── icon_256x256.png │ │ │ ├── icon_32x32.png │ │ │ └── icon_512x512.png │ │ └── vercel-logo.svg │ └── manifest.json └── yarn.lock └── yarn.lock /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | patreon: egoist 4 | issuehunt: saberland 5 | ko_fi: support_egoist 6 | open_collective: saber 7 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | --- 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | ## Bug report 15 | 16 | #### Steps to reproduce 17 | 18 | 19 | 20 | 21 | 22 | #### What is expected? 23 | 24 | #### What is actually happening? 25 | 26 | #### Other relevant information 27 | 28 | - Result of running `saber -v`: 29 | - Browser version (optional): 30 | - Is Saber a global or local install? 31 | - Which package manager did you use for the install? 32 | - Does this issue occur when all plugins are disabled? 33 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | 5 | --- 6 | 7 | 8 | 9 | 10 | ## Feature request 11 | 12 | 13 | 14 | 15 | 16 | #### What problem does this feature solve? 17 | 18 | #### What does the proposed API look like? 19 | 20 | #### How should this be implemented in your opinion? 21 | 22 | #### Are you willing to work on this yourself? 23 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | **Summary** 7 | 8 | 9 | 10 | 11 | **What kind of change does this PR introduce?** (check at least one) 12 | 13 | - [ ] Bugfix 14 | - [ ] Feature 15 | - [ ] Code style update 16 | - [ ] Refactor 17 | - [ ] Docs 18 | - [ ] Build-related changes 19 | - [ ] Other, please describe: 20 | 21 | If changing the UI/CSS related code, please provide the **before/after** screenshot: 22 | 23 | **Does this PR introduce a breaking change?** (check one) 24 | 25 | - [ ] Yes 26 | - [ ] No 27 | 28 | If yes, please describe the impact and migration path for existing applications: 29 | 30 | **The PR fulfills these requirements:** 31 | 32 | - [ ] Briefly describing what this PR does in the title in [Angular Commit Message Conventions](https://git.io/fNGDG), e.g. `fix: rebuild when a page is added` 33 | 34 | To avoid wasting your time, it's best to open a **feature request issue** first and wait for approval before working on it. 35 | 36 | **Other information:** 37 | -------------------------------------------------------------------------------- /.github/issue_label_bot.yaml: -------------------------------------------------------------------------------- 1 | label-alias: 2 | bug: 'type: bug' 3 | feature_request: 'type: feature' 4 | question: 'question' 5 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: Node CI 2 | 3 | on: 4 | pull_request: 5 | push: 6 | branches: 7 | - master 8 | paths-ignore: 9 | - '**.md' 10 | 11 | jobs: 12 | test: 13 | name: Test on ${{ matrix.os }} 14 | runs-on: ${{ matrix.os }} 15 | 16 | strategy: 17 | matrix: 18 | os: [ubuntu-latest, windows-latest] 19 | 20 | steps: 21 | - uses: actions/checkout@v2.1.0 22 | 23 | - name: Use Node.js 12.x 24 | uses: actions/setup-node@v1.4.1 25 | with: 26 | node-version: 12.x 27 | 28 | - name: Get yarn cache directory path 29 | id: yarn-cache-dir-path 30 | run: echo "::set-output name=dir::$(yarn cache dir)" 31 | 32 | - uses: actions/cache@v1 33 | id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) 34 | with: 35 | path: ${{ steps.yarn-cache-dir-path.outputs.dir }} 36 | key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} 37 | restore-keys: | 38 | ${{ runner.os }}-yarn- 39 | 40 | - name: Install dependencies 41 | run: yarn 42 | 43 | - name: Test 44 | run: yarn test 45 | env: 46 | CI: true 47 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .saber 3 | dist 4 | public 5 | .DS_Store 6 | examples/*/yarn.lock 7 | examples/*/package-lock.json 8 | packages/*/types 9 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | registry=https://registry.npmjs.org 2 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "semi": false, 3 | "singleQuote": true, 4 | "bracketSpacing": true 5 | } 6 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "launch", 10 | "name": "Debug Saber with website", 11 | "program": "${workspaceFolder}/packages/saber/lib/cli.js", 12 | "cwd": "${workspaceFolder}/website/" 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "eslint.validate": ["javascript", "javascriptreact", "typescript"], 3 | "eslint.enable": true, 4 | "eslint.workingDirectories": [ 5 | { 6 | "directory": "packages/saber", 7 | "changeProcessCWD": true 8 | } 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Saber 2 | 3 | ## Set up Saber locally 4 | 5 | Fork this project, then: 6 | 7 | ```bash 8 | git clone git@github.com:$USER/saber.git 9 | cd saber 10 | 11 | # Install dependencies 12 | yarn 13 | 14 | # Link the `saber` binary if you want to run it globally 15 | cd packages/saber 16 | yarn link 17 | 18 | # If you wanna run the website locally 19 | cd website 20 | yarn dev # which uses the global `saber` command 21 | ``` 22 | 23 | Visual Studio Code users can take advantage of the debug configuration shipping with Saber, which allows testing Saber with the documentation website. If you want to debug with a different project, set `cwd` under `.vscode/launch.json` to your Saber project's working directory. 24 | 25 | ## Pull Requests 26 | 27 | Before starting to work on an issue, first ensure there are no open PRs for it already, then comment that you intend to work on it, to prevent others from wasting their time doing the same work. 28 | 29 | If the issue you're working on is funded by IssueHunt, you also need to submit the PR URL to IssueHunt after submitting your PR on GitHub. 30 | 31 | ## Publish a new version 32 | 33 | If you have write access to this project: 34 | 35 | ```bash 36 | # In root directory 37 | # Analyze git history, create git tag and update upstream 38 | yarn lerna version --conventional-commits 39 | # Publish to npm 40 | yarn lerna publish from-git 41 | ``` 42 | -------------------------------------------------------------------------------- /KNOWN_ISSUES.md: -------------------------------------------------------------------------------- 1 | # Known Issues 2 | 3 | ## Inline Critical CSS 4 | 5 | If you're using a `.js` file as page component, the CSS imported there won't be inlined in the initial HTML sent by the server. 6 | 7 | Inlining Critical CSS only works with ` 14 | -------------------------------------------------------------------------------- /examples/extract-css/pages/index.vue: -------------------------------------------------------------------------------- 1 | 7 | -------------------------------------------------------------------------------- /examples/extract-css/saber-browser.js: -------------------------------------------------------------------------------- 1 | import './css/global.css' 2 | -------------------------------------------------------------------------------- /examples/extract-css/saber-config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | build: { 3 | extractCSS: true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /examples/vue-composition-api/README.md: -------------------------------------------------------------------------------- 1 | # vue-composition-api 2 | 3 | With `@vue/composition-api` you can enjoy the upcoming Vue 3.x feature in Vue 2.x right away. 4 | 5 | ## How to run 6 | 7 | ```bash 8 | git clone https://github.com/saberland/saber.git --single-branch 9 | cd saber/examples/vue-composition-api 10 | yarn 11 | yarn dev 12 | ``` 13 | -------------------------------------------------------------------------------- /examples/vue-composition-api/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "name": "vue-composition-api", 4 | "description": "How to use the module @vue/composition-api with Saber", 5 | "scripts": { 6 | "dev": "saber", 7 | "build": "saber build" 8 | }, 9 | "dependencies": { 10 | "saber": "^0.9.1", 11 | "@vue/composition-api": "^0.3.2" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /examples/vue-composition-api/pages/index.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 29 | -------------------------------------------------------------------------------- /examples/vue-composition-api/saber-browser.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import VueCompositionApi from '@vue/composition-api' 3 | 4 | Vue.use(VueCompositionApi) 5 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "packages": ["packages/*", "other-packages/*"], 3 | "version": "independent", 4 | "npmClient": "yarn" 5 | } 6 | -------------------------------------------------------------------------------- /other-packages/eslint-config-saber/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## [0.0.2](https://github.com/saberland/saber/compare/eslint-config-saber@0.0.1...eslint-config-saber@0.0.2) (2019-12-02) 7 | 8 | **Note:** Version bump only for package eslint-config-saber 9 | 10 | ## 0.0.1 (2019-11-03) 11 | 12 | **Note:** Version bump only for package eslint-config-saber 13 | -------------------------------------------------------------------------------- /other-packages/eslint-config-saber/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | parser: '@typescript-eslint/parser', 3 | parserOptions: { 4 | warnOnUnsupportedTypeScriptVersion: false, 5 | sourceType: 'module', 6 | jsx: false, 7 | project: 'tsconfig.json' 8 | }, 9 | extends: [ 10 | 'eslint:recommended', 11 | 'plugin:@typescript-eslint/eslint-recommended', 12 | 'plugin:@typescript-eslint/recommended', 13 | 'plugin:@typescript-eslint/recommended-requiring-type-checking', 14 | 'plugin:prettier/recommended' 15 | ], 16 | env: { 17 | node: true, 18 | jest: true, 19 | es2017: true 20 | }, 21 | rules: { 22 | // Enable this rule when all files are migated to TS 23 | '@typescript-eslint/no-var-requires': 'off', 24 | '@typescript-eslint/camelcase': 'off', 25 | // Enable this rule later, it explodes the terminal 26 | '@typescript-eslint/explicit-function-return-type': 'off', 27 | '@typescript-eslint/member-delimiter-style': [ 28 | 'error', 29 | { 30 | multiline: { 31 | delimiter: 'none', 32 | requireLast: false 33 | }, 34 | singleline: { 35 | delimiter: 'semi', 36 | requireLast: false 37 | } 38 | } 39 | ], 40 | '@typescript-eslint/prefer-includes': 'off' 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /other-packages/eslint-config-saber/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "eslint-config-saber", 3 | "version": "0.0.2", 4 | "description": "ESLint config for core Saber repos", 5 | "man": "index.js", 6 | "files": [ 7 | "index.js" 8 | ], 9 | "license": "MIT", 10 | "dependencies": { 11 | "@typescript-eslint/eslint-plugin": "^2.6.0", 12 | "@typescript-eslint/parser": "^2.6.0", 13 | "eslint-config-prettier": "6.5.0", 14 | "eslint-plugin-prettier": "3.1.1" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /other-packages/extract-sfc-blocks/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## [0.0.2](https://github.com/egoist/saber/compare/extract-sfc-blocks@0.0.1...extract-sfc-blocks@0.0.2) (2019-05-02) 7 | 8 | ### Bug Fixes 9 | 10 | - **deps:** update dependency stringify-attributes to v2 ([#125](https://github.com/egoist/saber/issues/125)) ([0465485](https://github.com/egoist/saber/commit/0465485)) 11 | 12 | ## 0.0.1 (2019-04-27) 13 | 14 | ### Features 15 | 16 | - add saber-plugin-transformer-pug ([edc7891](https://github.com/egoist/saber/commit/edc7891)) 17 | -------------------------------------------------------------------------------- /other-packages/extract-sfc-blocks/index.js: -------------------------------------------------------------------------------- 1 | const posthtml = require('posthtml') 2 | const stringifyAttrs = require('stringify-attributes') 3 | 4 | function stringifyNode(node) { 5 | if (typeof node === 'string') { 6 | return node 7 | } 8 | 9 | const content = node.content || [] 10 | return `<${node.tag}${stringifyAttrs(node.attrs || {})}>${content 11 | .map(n => stringifyNode(n)) 12 | .join('')}` 13 | } 14 | 15 | module.exports = input => { 16 | const blocks = [] 17 | const { html } = posthtml([ 18 | tree => 19 | tree.walk(node => { 20 | if (node.tag === 'script' || node.tag === 'style') { 21 | blocks.push(stringifyNode(node)) 22 | return 23 | } 24 | 25 | return node 26 | }) 27 | ]).process(input, { 28 | sync: true, 29 | recognizeSelfClosing: true 30 | }) 31 | 32 | return { 33 | html, 34 | blocks 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /other-packages/extract-sfc-blocks/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "extract-sfc-blocks", 3 | "version": "0.0.2", 4 | "description": "Extract Vue SFC blocks from HTML", 5 | "files": [ 6 | "index.js" 7 | ], 8 | "main": "index.js", 9 | "license": "MIT", 10 | "dependencies": { 11 | "posthtml": "^0.11.3", 12 | "stringify-attributes": "^2.0.0" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "name": "saber", 4 | "scripts": { 5 | "test": "npm run lint && lerna run test", 6 | "lint": "lerna run lint", 7 | "commit": "git-cz", 8 | "prepare": "lerna run prepublishOnly" 9 | }, 10 | "repository": { 11 | "url": "saberland/saber", 12 | "type": "git" 13 | }, 14 | "author": "egoist<0x142857@gmail.com>", 15 | "license": "MIT", 16 | "devDependencies": { 17 | "commitizen": "4.0.3", 18 | "conf": "6.2.0", 19 | "cz-conventional-changelog": "3.0.2", 20 | "enquirer": "^2.3.1", 21 | "eslint": "^6.6.0", 22 | "husky": "3.0.9", 23 | "jest": "^24.9.0", 24 | "lerna": "3.18.3", 25 | "lint-staged": "8.1.6", 26 | "prettier": "1.18.2", 27 | "typedoc": "^0.15.0", 28 | "typescript": "^3.8.0-dev.20191031" 29 | }, 30 | "resolutions": { 31 | "typedoc/typescript": "^3.8.0-dev.20191031" 32 | }, 33 | "husky": { 34 | "hooks": { 35 | "pre-commit": "lint-staged" 36 | } 37 | }, 38 | "lint-staged": { 39 | "linters": { 40 | "*.{json,md}": [ 41 | "prettier --write", 42 | "git add" 43 | ] 44 | }, 45 | "ignore": [ 46 | "**/dist/**", 47 | "**/vendor/**", 48 | "*.min.js", 49 | "**/vue-renderer/app/**", 50 | "**/example/**", 51 | "website/**" 52 | ] 53 | }, 54 | "workspaces": [ 55 | "packages/*", 56 | "other-packages/*", 57 | "website" 58 | ], 59 | "config": { 60 | "commitizen": { 61 | "path": "cz-conventional-changelog" 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /packages/create-blog/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) EGOIST <0x142857@gmail.com> (https://github.com/egoist) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/create-blog/cli.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | require('create-site/cli') 3 | -------------------------------------------------------------------------------- /packages/create-blog/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "create-blog", 3 | "version": "0.2.9", 4 | "bin": "cli.js", 5 | "files": [ 6 | "cli.js" 7 | ], 8 | "dependencies": { 9 | "create-site": "^0.4.0" 10 | }, 11 | "license": "MIT", 12 | "author": { 13 | "name": "EGOIST", 14 | "email": "0x142857@gmail.com" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /packages/create-site/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) EGOIST <0x142857@gmail.com> (https://github.com/egoist) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/create-site/cli.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | const path = require('path') 3 | const { spawnSync } = require('child_process') 4 | const { promisify } = require('util') 5 | const colors = require('kleur') 6 | 7 | const args = process.argv.slice(2) 8 | 9 | if ( 10 | args.length === 0 || 11 | ['-h', '--help'].some(helpFlag => args.includes(helpFlag)) 12 | ) { 13 | console.log( 14 | `create-site v${require('./package').version} 15 | 16 | Usage: create-site 17 | `.trim() 18 | ) 19 | process.exit(1) 20 | } 21 | 22 | if (args.some(arg => arg.startsWith('-'))) { 23 | console.log(`Invalid flag ${args.join('')}`) 24 | process.exit(1) 25 | } 26 | 27 | if (parseInt(process.versions.node, 10) < 8) { 28 | console.log( 29 | `Node.js ${process.versions.node} isn't supported, you need Node.js 8 or above.` 30 | ) 31 | process.exit(1) 32 | } 33 | 34 | const dir = path.resolve(args[0]) 35 | 36 | console.log(`Creating a new site...`) 37 | 38 | const { ncp } = require('ncp') 39 | 40 | let hasYarn = false 41 | try { 42 | spawnSync('yarn', ['--version']) 43 | hasYarn = true 44 | } catch (error) {} 45 | 46 | promisify(ncp)(path.join(__dirname, 'template'), dir) 47 | .then(() => { 48 | console.log( 49 | colors.green(`Successfully created at ${colors.underline(dir)}`) 50 | ) 51 | console.log(colors.bold(`To start dev server, run:`)) 52 | console.log(colors.cyan(`$ cd ${path.relative(process.cwd(), dir)}`)) 53 | if (hasYarn) { 54 | console.log(colors.cyan(`$ yarn`)) 55 | console.log(colors.cyan(`$ yarn dev`)) 56 | } else { 57 | console.log(colors.cyan(`$ npm install`)) 58 | console.log(colors.cyan(`$ npm run dev`)) 59 | } 60 | 61 | console.log(colors.dim(`For more details, please check out the README.md`)) 62 | }) 63 | .catch(console.error) 64 | -------------------------------------------------------------------------------- /packages/create-site/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "create-site", 3 | "version": "0.4.0", 4 | "bin": "cli.js", 5 | "files": [ 6 | "cli.js", 7 | "template" 8 | ], 9 | "license": "MIT", 10 | "dependencies": { 11 | "kleur": "3.0.3", 12 | "ncp": "2.0.0" 13 | }, 14 | "author": { 15 | "name": "EGOIST", 16 | "email": "0x142857@gmail.com" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/create-site/template/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | *.log 3 | .saber 4 | public 5 | -------------------------------------------------------------------------------- /packages/create-site/template/README.md: -------------------------------------------------------------------------------- 1 | # my-saber-blog 2 | 3 | ## Scripts 4 | 5 | ### `npm run dev` 6 | 7 | Run dev server at `http://localhost:3000` 8 | 9 | ### `npm run build` 10 | 11 | Build your website to `public` folder which you can deploy to GitHub Pages, Netlify or wherever you want. 12 | -------------------------------------------------------------------------------- /packages/create-site/template/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "scripts": { 4 | "dev": "saber", 5 | "build": "saber build" 6 | }, 7 | "devDependencies": { 8 | "saber": "latest", 9 | "saber-theme-minima": "latest", 10 | "saber-plugin-feed": "latest", 11 | "saber-plugin-query-posts": "latest" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /packages/create-site/template/pages/_posts/my-example-post.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: My Example Post 3 | date: 2016-05-20 4 | layout: post 5 | --- 6 | 7 | Eos eu docendi tractatos sapientem, brute option menandri in vix, quando vivendo accommodare te ius. Nec melius fastidii constituam id, viderer theophrastus ad sit, hinc semper periculis cum id. Noluisse postulant assentior est in, no choro sadipscing repudiandae vix. Vis in euismod delenit dignissim. Ex quod nostrum sit, suas decore animal id ius, nobis solet detracto quo te. 8 | 9 | No laudem altera adolescens has, volumus lucilius eum no. Eam ei nulla audiam efficiantur. Suas affert per no, ei tale nibh sea. Sea ne magna harum, in denique scriptorem sea, cetero alienum tibique ei eos. Labores persequeris referrentur eos ei. 10 | -------------------------------------------------------------------------------- /packages/create-site/template/pages/_posts/super-short-article.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'Some articles are just so short that we have to make the footer stick' 3 | date: 2016-05-19 4 | layout: post 5 | --- 6 | 7 | Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. 8 | -------------------------------------------------------------------------------- /packages/create-site/template/pages/about.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: About 3 | layout: page 4 | --- 5 | 6 | This is the Saber port of the base Jekyll theme. Check out the [GitHub project](https://github.com/egoist/saber-theme-minima) for detailed usages. 7 | 8 | You can find out more info about customizing your theme, as well as basic Saber usage documentation at https://saber.land 9 | -------------------------------------------------------------------------------- /packages/create-site/template/pages/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | # Fallback to `default` layout if `index` is not found 3 | layout: index 4 | # Inject post list as `page.posts` (by saber-plugin-query-posts) 5 | injectAllPosts: true 6 | --- 7 | -------------------------------------------------------------------------------- /packages/create-site/template/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saberland/saber/e63d22041a9397bec38468caadec6bd7b923d8b6/packages/create-site/template/public/favicon.ico -------------------------------------------------------------------------------- /packages/create-site/template/saber-config.yml: -------------------------------------------------------------------------------- 1 | theme: minima 2 | 3 | siteConfig: 4 | url: https://example.com 5 | author: Author of This Site 6 | email: author@your-domain.com 7 | description: Write an awesome description for your new site here. You can edit this line in saber-config.yml. It will appear in your document head meta (for Google search results) site description. 8 | 9 | themeConfig: 10 | nav: 11 | - text: Home 12 | link: / 13 | - text: About 14 | link: /about.html 15 | social: 16 | twitter: saber_land 17 | github: egoist 18 | rss: true 19 | 20 | plugins: 21 | - resolve: saber-plugin-query-posts 22 | - resolve: saber-plugin-feed 23 | options: 24 | atomFeed: true 25 | -------------------------------------------------------------------------------- /packages/saber-highlight-css/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) EGOIST <0x142857@gmail.com> (https://github.com/egoist) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/saber-highlight-css/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "saber-highlight-css", 3 | "version": "0.1.2", 4 | "description": "Default CSS for code highlighting in Saber", 5 | "files": [ 6 | "*.css" 7 | ], 8 | "license": "MIT", 9 | "peerDependencies": { 10 | "saber": ">=0.7.0" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/saber-highlighter-prism/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) EGOIST <0x142857@gmail.com> (https://github.com/egoist) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/saber-highlighter-prism/README.md: -------------------------------------------------------------------------------- 1 | Don't use this directly, you should use [saber-plugin-prismjs](../saber-plugin-prismjs) instead. 2 | -------------------------------------------------------------------------------- /packages/saber-highlighter-prism/index.js: -------------------------------------------------------------------------------- 1 | const Prism = require('prismjs') 2 | const { log } = require('saber-log') 3 | const loadLanguages = require('./loadLanguages') 4 | 5 | const languageAlias = { 6 | vue: 'html', 7 | sh: 'bash', 8 | styl: 'stylus' 9 | } 10 | 11 | module.exports = (code, lang) => { 12 | if (!lang) return Prism.highlight(code, {}) 13 | 14 | lang = lang.toLowerCase() 15 | 16 | if (lang in languageAlias) { 17 | lang = languageAlias[lang] 18 | } 19 | 20 | if (!Prism.languages[lang]) { 21 | try { 22 | loadLanguages(lang) 23 | } catch (error) { 24 | log.warn(error.message) 25 | return Prism.highlight(code, {}) 26 | } 27 | } 28 | 29 | const grammer = Prism.languages[lang] 30 | 31 | return Prism.highlight(code, grammer, lang) 32 | } 33 | -------------------------------------------------------------------------------- /packages/saber-highlighter-prism/loadLanguages.js: -------------------------------------------------------------------------------- 1 | const Prism = require(`prismjs`) 2 | const prismComponents = require(`prismjs/components`) 3 | 4 | // Get the real name of a language given it or an alias 5 | const getBaseLanguageName = (nameOrAlias, components = prismComponents) => { 6 | if (components.languages[nameOrAlias]) { 7 | return nameOrAlias 8 | } 9 | 10 | return Object.keys(components.languages).find(language => { 11 | const { alias } = components.languages[language] 12 | if (!alias) return false 13 | if (Array.isArray(alias)) { 14 | return alias.includes(nameOrAlias) 15 | } 16 | 17 | return alias === nameOrAlias 18 | }) 19 | } 20 | 21 | module.exports = function loadPrismLanguage(language) { 22 | const baseLanguage = getBaseLanguageName(language) 23 | 24 | if (!baseLanguage) { 25 | throw new Error(`Prism doesn't support language '${language}'.`) 26 | } 27 | 28 | if (Prism.languages[baseLanguage]) { 29 | // Don't load already loaded language 30 | return 31 | } 32 | 33 | const languageData = prismComponents.languages[baseLanguage] 34 | 35 | if (languageData.option === `default`) { 36 | // Default language has already been loaded by Prism 37 | return 38 | } 39 | 40 | if (languageData.require) { 41 | // Load the required language first 42 | if (Array.isArray(languageData.require)) { 43 | languageData.require.forEach(loadPrismLanguage) 44 | } else { 45 | loadPrismLanguage(languageData.require) 46 | } 47 | } 48 | 49 | require(`prismjs/components/prism-${baseLanguage}.js`) 50 | } 51 | 52 | /* Exposed for unit testing */ 53 | module.exports.getBaseLanguageName = getBaseLanguageName 54 | -------------------------------------------------------------------------------- /packages/saber-highlighter-prism/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "saber-highlighter-prism", 3 | "version": "0.3.4", 4 | "license": "MIT", 5 | "files": [ 6 | "index.js", 7 | "loadLanguages.js" 8 | ], 9 | "main": "index.js", 10 | "dependencies": { 11 | "saber-log": "^0.3.1" 12 | }, 13 | "devDependencies": { 14 | "prismjs": "1.17.1" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /packages/saber-log/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## [0.3.1](https://github.com/saberland/saber/compare/saber-log@0.3.0...saber-log@0.3.1) (2019-11-03) 7 | 8 | **Note:** Version bump only for package saber-log 9 | 10 | # [0.3.0](https://github.com/saberland/saber/compare/saber-log@0.2.1...saber-log@0.3.0) (2019-09-11) 11 | 12 | ### Features 13 | 14 | - **cli:** tweak logger style ([d90025d](https://github.com/saberland/saber/commit/d90025d)) 15 | 16 | ## [0.2.1](https://github.com/saberland/saber/compare/saber-log@0.2.0...saber-log@0.2.1) (2019-08-22) 17 | 18 | ### Bug Fixes 19 | 20 | - **pkg:** add missing LICENSE in leaf packages ([9f73603](https://github.com/saberland/saber/commit/9f73603)) 21 | 22 | # [0.2.0](https://github.com/egoist/saber/compare/saber-log@0.1.1...saber-log@0.2.0) (2019-04-09) 23 | 24 | ### Bug Fixes 25 | 26 | - **logger:** set log level properly ([251125d](https://github.com/egoist/saber/commit/251125d)) 27 | 28 | ### Features 29 | 30 | - output fewer logs ([d3a68ea](https://github.com/egoist/saber/commit/d3a68ea)) 31 | 32 | ## [0.1.1](https://github.com/egoist/saber/compare/saber-log@0.1.0...saber-log@0.1.1) (2019-02-13) 33 | 34 | **Note:** Version bump only for package saber-log 35 | 36 | # 0.1.0 (2019-01-21) 37 | 38 | ### Features 39 | 40 | - support markdown highlighter ([5c8ec2e](https://github.com/egoist/saber/commit/5c8ec2e)) 41 | -------------------------------------------------------------------------------- /packages/saber-log/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) EGOIST <0x142857@gmail.com> (https://github.com/egoist) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/saber-log/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "saber-log", 3 | "version": "0.3.1", 4 | "main": "dist/index.js", 5 | "types": "dist/index.d.ts", 6 | "files": [ 7 | "dist" 8 | ], 9 | "license": "MIT", 10 | "scripts": { 11 | "prepublishOnly": "yarn build", 12 | "build": "rollup -c" 13 | }, 14 | "devDependencies": { 15 | "rollup": "^1.26.0", 16 | "rollup-plugin-typescript2": "^0.24.3" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/saber-log/rollup.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | input: 'src/index.ts', 3 | output: { 4 | file: 'dist/index.js', 5 | format: 'cjs' 6 | }, 7 | plugins: [ 8 | require('rollup-plugin-typescript2')({ 9 | tsconfigOverride: { 10 | compilerOptions: { 11 | declaration: true 12 | } 13 | } 14 | }) 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /packages/saber-log/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.base.json", 3 | "include": ["src"], 4 | "compilerOptions": { 5 | "module": "esnext" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/saber-markdown/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) EGOIST <0x142857@gmail.com> (https://github.com/egoist) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/saber-markdown/README.md: -------------------------------------------------------------------------------- 1 | # saber-markdown 2 | 3 | A custom build of markdown-it for Saber. 4 | 5 | ## Differences 6 | 7 | Implemented via a [babel plugin](./babel-plugin-vue-features.js). 8 | 9 | ### Support `@` in attribute names 10 | 11 | In: 12 | 13 | ```html 14 | 15 | ``` 16 | 17 | Out: 18 | 19 | ```diff 20 | -

<button @click="foo">

\n 21 | +

\n 22 | ``` 23 | 24 | ### Support top-level components 25 | 26 | In: 27 | 28 | ```html 29 | 30 | ``` 31 | 32 | Out: 33 | 34 | ```diff 35 | -

hi

\n 36 | + hi 37 | ``` 38 | -------------------------------------------------------------------------------- /packages/saber-markdown/babel-plugin-vue-features.js: -------------------------------------------------------------------------------- 1 | module.exports = ({ types: t }) => { 2 | return { 3 | visitor: { 4 | StringLiteral( 5 | path, 6 | { 7 | file: { 8 | opts: { filename } 9 | } 10 | } 11 | ) { 12 | if ( 13 | filename.endsWith('/html_re.js') && 14 | path.node.value === '[a-zA-Z_:][a-zA-Z0-9:._-]*' 15 | ) { 16 | console.log('support @ in attribute names!') 17 | path.node.value = '[a-zA-Z@_:][a-zA-Z0-9:._-]*' 18 | } 19 | }, 20 | ArrayExpression(path) { 21 | if ( 22 | path.parent.type === 'VariableDeclarator' && 23 | path.parent.id.name === 'HTML_SEQUENCES' 24 | ) { 25 | // Using Vue components at top-level 26 | // Previously `` is transformed to `

` 27 | // Now it's just `` 28 | console.log('support top-level components') 29 | path.node.elements = [ 30 | ...path.node.elements.slice(0, -2), 31 | // PascalCase Components 32 | t.arrayExpression([ 33 | t.regExpLiteral('^<[A-Z]'), 34 | t.regExpLiteral('>'), 35 | t.booleanLiteral(true) 36 | ]), 37 | // custom elements with hyphens 38 | t.arrayExpression([ 39 | t.regExpLiteral('^<\\w+\\-'), 40 | t.regExpLiteral('>'), 41 | t.booleanLiteral(true) 42 | ]), 43 | ...path.node.elements.slice(-2) 44 | ] 45 | } 46 | } 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /packages/saber-markdown/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "saber-markdown", 3 | "version": "0.1.6", 4 | "files": [ 5 | "dist" 6 | ], 7 | "main": "dist/index.js", 8 | "scripts": { 9 | "build": "rollup -c", 10 | "prepublishOnly": "npm run build" 11 | }, 12 | "license": "MIT", 13 | "devDependencies": { 14 | "@babel/core": "7.6.4", 15 | "builtin-modules": "3.1.0", 16 | "markdown-it": "10.0.0", 17 | "rollup": "1.22.0", 18 | "rollup-plugin-babel": "4.3.3", 19 | "rollup-plugin-commonjs": "10.1.0", 20 | "rollup-plugin-json": "4.0.0", 21 | "rollup-plugin-node-resolve": "5.2.0", 22 | "rollup-plugin-terser": "5.1.2" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /packages/saber-markdown/rollup.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | input: './src/index.js', 3 | output: { 4 | file: './dist/index.js', 5 | format: 'cjs' 6 | }, 7 | plugins: [ 8 | require('rollup-plugin-commonjs')(), 9 | require('rollup-plugin-node-resolve')(), 10 | require('rollup-plugin-json')(), 11 | require('rollup-plugin-babel')({ 12 | plugins: [require('./babel-plugin-vue-features')] 13 | }), 14 | require('rollup-plugin-terser').terser() 15 | ], 16 | external: require('builtin-modules') 17 | } 18 | -------------------------------------------------------------------------------- /packages/saber-markdown/src/index.js: -------------------------------------------------------------------------------- 1 | import Markdown from 'markdown-it/lib' 2 | import Token from 'markdown-it/lib/token' 3 | 4 | Markdown.Token = Token 5 | 6 | export default Markdown 7 | -------------------------------------------------------------------------------- /packages/saber-plugin-code-copy/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## [0.3.2](https://github.com/saberland/saber/compare/saber-plugin-code-copy@0.3.1...saber-plugin-code-copy@0.3.2) (2019-11-10) 7 | 8 | ### Bug Fixes 9 | 10 | - **code-copy:** copy button positioning ([#557](https://github.com/saberland/saber/issues/557)) ([175ba24](https://github.com/saberland/saber/commit/175ba24)) 11 | 12 | ## [0.3.1](https://github.com/saberland/saber/compare/saber-plugin-code-copy@0.3.0...saber-plugin-code-copy@0.3.1) (2019-11-03) 13 | 14 | **Note:** Version bump only for package saber-plugin-code-copy 15 | 16 | # 0.3.0 (2019-09-29) 17 | 18 | ### Bug Fixes 19 | 20 | - **plugin-code-copy:** correct package name ([ee7d0ce](https://github.com/saberland/saber/commit/ee7d0ce)) 21 | 22 | ### Features 23 | 24 | - add code-copy plugin ([#450](https://github.com/saberland/saber/issues/450)) ([007636c](https://github.com/saberland/saber/commit/007636c)) 25 | 26 | # 0.2.0 (2019-09-25) 27 | 28 | ### Features 29 | 30 | - add code-copy plugin ([#450](https://github.com/saberland/saber/issues/450)) ([007636c](https://github.com/saberland/saber/commit/007636c)) 31 | -------------------------------------------------------------------------------- /packages/saber-plugin-code-copy/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) EGOIST <0x142857@gmail.com> (https://github.com/egoist) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/saber-plugin-code-copy/README.md: -------------------------------------------------------------------------------- 1 | # saber-plugin-code-copy 2 | 3 | Copy code to clipboard. 4 | 5 | ## Install 6 | 7 | ```bash 8 | yarn add saber-plugin-code-copy 9 | ``` 10 | 11 | ## Usage 12 | 13 | In your `saber-config.yml`: 14 | 15 | ```yml 16 | plugins: 17 | - resolve: saber-plugin-code-copy 18 | ``` 19 | 20 | ## Options 21 | 22 | ### statusAttribute 23 | 24 | - Type: `string` 25 | - Default: `title` 26 | 27 | By default the `title` attribute of the button is set to `Copy`, when code is copied we update it to `Copied`, you can specify another attribute name if you want, e.g. `aria-label`. 28 | 29 | ### buttonStyle 30 | 31 | - Type: `object` 32 | - Default: `undefined` 33 | 34 | Assign custom style to the _Copy_ button, e.g.: 35 | 36 | ```js 37 | { 38 | backgroundColor: 'red' 39 | } 40 | ``` 41 | 42 | ## License 43 | 44 | MIT. 45 | -------------------------------------------------------------------------------- /packages/saber-plugin-code-copy/lib/index.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | 3 | const ID = 'code-copy' 4 | 5 | exports.name = ID 6 | 7 | exports.apply = (api, options) => { 8 | api.browserApi.add(path.join(__dirname, 'saber-browser.js')) 9 | api.hooks.chainWebpack.tap(ID, config => { 10 | config.plugin('constants').tap(([constants]) => [ 11 | Object.assign(constants, { 12 | __CODE_COPY_OPTIONS__: JSON.stringify(options) 13 | }) 14 | ]) 15 | }) 16 | } 17 | -------------------------------------------------------------------------------- /packages/saber-plugin-code-copy/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "saber-plugin-code-copy", 3 | "version": "0.3.2", 4 | "description": "Allow to copy code into clipboard", 5 | "license": "MIT", 6 | "main": "lib/index.js", 7 | "files": [ 8 | "lib" 9 | ], 10 | "peerDependencies": { 11 | "saber": ">=0.7.0" 12 | }, 13 | "dependencies": { 14 | "modern-copy": "^1.0.3" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /packages/saber-plugin-feed/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) EGOIST <0x142857@gmail.com> (https://github.com/egoist) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/saber-plugin-feed/example/pages/_posts/bye-world.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: bye world 3 | date: 2018-03-12 4 | layout: post 5 | --- 6 | 7 | well ok __fine__ 8 | -------------------------------------------------------------------------------- /packages/saber-plugin-feed/example/pages/_posts/hello-world.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: hello world 3 | date: 2018-02-12 4 | layout: post 5 | --- 6 | 7 | wtf is __this__ {{ 1 + 1 }} 8 | -------------------------------------------------------------------------------- /packages/saber-plugin-feed/example/saber-config.yml: -------------------------------------------------------------------------------- 1 | plugins: 2 | - resolve: ../ 3 | options: 4 | atomFeed: true 5 | rss2Feed: true 6 | jsonFeed: blog/feed.json 7 | 8 | siteConfig: 9 | url: https://example.com 10 | author: Your Name 11 | -------------------------------------------------------------------------------- /packages/saber-plugin-feed/lib/saber-browser.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import Vue from 'vue' 3 | import { jsonFeedPath, atomFeedPath, rss2FeedPath } from 'saber/variables' 4 | 5 | const getPermalink = (localePath, feedPath) => { 6 | return `${localePath === '/' ? '' : localePath}/${feedPath.replace( 7 | /^\.?\//, 8 | '' 9 | )}` 10 | } 11 | 12 | Vue.mixin({ 13 | computed: { 14 | $feed() { 15 | const allFeeds = this.$allFeeds 16 | const permalink = allFeeds.atom || allFeeds.rss2 || allFeeds.json 17 | const type = allFeeds.atom ? 'atom' : allFeeds.rss2 ? 'rss2' : 'json' 18 | return { 19 | permalink, 20 | type 21 | } 22 | }, 23 | $allFeeds() { 24 | return { 25 | atom: atomFeedPath && getPermalink(this.$localePath, atomFeedPath), 26 | rss2: rss2FeedPath && getPermalink(this.$localePath, rss2FeedPath), 27 | json: jsonFeedPath && getPermalink(this.$localePath, jsonFeedPath) 28 | } 29 | } 30 | } 31 | }) 32 | -------------------------------------------------------------------------------- /packages/saber-plugin-feed/lib/utils.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | const { URL } = require('url') 3 | 4 | /** 5 | * Get feed path 6 | * @param {string|boolean|undefined} feedPath 7 | * @param {string} defaultPath 8 | */ 9 | exports.getFeedPath = (feedPath, defaultPath) => { 10 | if (feedPath === true) { 11 | return defaultPath 12 | } 13 | 14 | if (typeof feedPath === 'string') { 15 | return feedPath 16 | } 17 | 18 | return null 19 | } 20 | 21 | /** 22 | * @param {string} base 23 | * @param {string} pathname 24 | * @returns {string} 25 | */ 26 | exports.resolveURL = (base, pathname) => { 27 | return new URL(pathname, base).href 28 | } 29 | -------------------------------------------------------------------------------- /packages/saber-plugin-feed/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "saber-plugin-feed", 3 | "version": "0.4.3", 4 | "description": "Generate Atom, RSS2, or JSON feed for your Saber app", 5 | "license": "MIT", 6 | "main": "lib/index.js", 7 | "scripts": { 8 | "generate:example": "saber generate example" 9 | }, 10 | "files": [ 11 | "lib" 12 | ], 13 | "dependencies": { 14 | "feed": "^4.0.0" 15 | }, 16 | "peerDependencies": { 17 | "saber": ">=0.7.0" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/saber-plugin-git-modification-time/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) EGOIST <0x142857@gmail.com> (https://github.com/egoist) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/saber-plugin-git-modification-time/README.md: -------------------------------------------------------------------------------- 1 | # saber-plugin-git-modification-time 2 | 3 | > Use the author time of the last commit as `page.updatedAt` 4 | 5 | Why? See [#9785](https://github.com/gatsbyjs/gatsby/issues/9785). 6 | 7 | **tl;dr** `page.updatedAt` defaults to `file.mtime` which will change on platforms like Netlify. We restore the value to author time of the last commit instead. 8 | 9 | ## Install 10 | 11 | ```bash 12 | yarn add saber-plugin-git-modification-time 13 | ``` 14 | 15 | ## Usage 16 | 17 | In your `saber-config.js`: 18 | 19 | ```js 20 | module.exports = { 21 | plugins: ['saber-plugin-git-modification-time'] 22 | } 23 | ``` 24 | 25 | ## License 26 | 27 | MIT. 28 | -------------------------------------------------------------------------------- /packages/saber-plugin-git-modification-time/lib/index.js: -------------------------------------------------------------------------------- 1 | const execa = require('execa') 2 | 3 | const ID = 'git-modification-time' 4 | 5 | exports.name = ID 6 | 7 | exports.apply = api => { 8 | api.hooks.onCreatePage.tapPromise(ID, async page => { 9 | if (page.internal.absolute) { 10 | const { stdout } = await execa('git', [ 11 | 'log', 12 | '-1', 13 | '--pretty=format:%aI', 14 | '--', 15 | page.internal.absolute 16 | ]) 17 | if (stdout) { 18 | page.updatedAt = new Date(stdout) 19 | } 20 | } 21 | }) 22 | } 23 | -------------------------------------------------------------------------------- /packages/saber-plugin-git-modification-time/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "saber-plugin-git-modification-time", 3 | "version": "0.1.3", 4 | "description": "Use the author time of the last commit as page.updatedAt", 5 | "license": "MIT", 6 | "main": "lib/index.js", 7 | "files": [ 8 | "lib" 9 | ], 10 | "dependencies": { 11 | "execa": "^3.2.0" 12 | }, 13 | "peerDependencies": { 14 | "saber": ">=0.7.0" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /packages/saber-plugin-google-analytics/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) EGOIST <0x142857@gmail.com> (https://github.com/egoist) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/saber-plugin-google-analytics/README.md: -------------------------------------------------------------------------------- 1 | # saber-plugin-google-analytics 2 | 3 | Add Google Analytics to your Saber sites. 4 | 5 | ## Install 6 | 7 | ```bash 8 | yarn add saber-plugin-google-analytics 9 | ``` 10 | 11 | ## Usage 12 | 13 | In your `saber-config.yml`: 14 | 15 | ```yml 16 | plugins: 17 | - resolve: saber-plugin-google-analytics 18 | options: 19 | trackId: UA-XXX-XX # Google Analytics Track ID 20 | ``` 21 | 22 | ## Plugin Options 23 | 24 | ### trackId 25 | 26 | - Type: `string` 27 | - Required: `true` 28 | 29 | Google Analytics Track ID. 30 | 31 | ### anonymizeIp 32 | 33 | - Type: `boolean` 34 | - Default: `false` 35 | 36 | To anonymize the IP address for all hits sent from a single tracker, set the `anonymizeIp` option to `true`. 37 | 38 | ## License 39 | 40 | MIT. 41 | -------------------------------------------------------------------------------- /packages/saber-plugin-google-analytics/index.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | 3 | const ID = 'google-analytics' 4 | 5 | exports.name = ID 6 | 7 | exports.apply = (api, { trackId = false, anonymizeIp = false } = {}) => { 8 | api.hooks.chainWebpack.tap(ID, config => { 9 | config.plugin('constants').tap(([options]) => [ 10 | Object.assign(options, { 11 | __GA_TRACK_ID__: JSON.stringify(trackId), 12 | __GA_ANONYMIZE_IP: JSON.stringify(anonymizeIp) 13 | }) 14 | ]) 15 | }) 16 | 17 | api.browserApi.add(path.join(__dirname, 'saber-browser.js')) 18 | } 19 | -------------------------------------------------------------------------------- /packages/saber-plugin-google-analytics/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "saber-plugin-google-analytics", 3 | "version": "0.2.1", 4 | "main": "index.js", 5 | "files": [ 6 | "index.js", 7 | "saber-browser.js" 8 | ], 9 | "peerDependencies": { 10 | "saber": ">=0.7.0" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/saber-plugin-google-analytics/saber-browser.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | // Google analytics integration for Vue.js renderer 3 | export default function({ router }) { 4 | if ( 5 | process.browser && 6 | process.env.NODE_ENV === 'production' && 7 | __GA_TRACK_ID__ 8 | ) { 9 | function doNotTrackEnabled() { 10 | const dntNumber = parseInt( 11 | navigator.msDoNotTrack || // Internet Explorer 9 and 10 vendor prefix 12 | window.doNotTrack || // IE 11 uses window.doNotTrack 13 | navigator.doNotTrack, // W3C 14 | 10 15 | ) 16 | 17 | return dntNumber === 1 18 | } 19 | 20 | if (doNotTrackEnabled()) { 21 | // Respect doNotTrack setting 22 | return 23 | } 24 | 25 | // prettier-ignore 26 | ;(function(i, s, o, g, r, a, m) { 27 | i.GoogleAnalyticsObject = r 28 | i[r] = i[r] || function () { 29 | (i[r].q = i[r].q || []).push(arguments) 30 | } 31 | i[r].l = Number(new Date()) 32 | a = s.createElement(o) 33 | m = s.getElementsByTagName(o)[0] 34 | a.async = 1 35 | a.src = g 36 | m.parentNode.insertBefore(a, m) 37 | })(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga') 38 | 39 | ga('create', __GA_TRACK_ID__, 'auto') 40 | 41 | if (__GA_ANONYMIZE_IP) { 42 | ga('set', 'anonymizeIp', true) 43 | } 44 | 45 | router.afterEach(to => { 46 | ga('set', 'page', to.fullPath) 47 | ga('send', 'pageview') 48 | }) 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /packages/saber-plugin-image/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) EGOIST <0x142857@gmail.com> (https://github.com/egoist) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/saber-plugin-image/lib/styles.module.css: -------------------------------------------------------------------------------- 1 | .blendIn[data-src], 2 | .blendIn[data-srcset] { 3 | transition: filter 0.3s; 4 | filter: blur(5px); 5 | } 6 | 7 | .blendIn[data-lazy-loaded] { 8 | filter: none; 9 | } 10 | -------------------------------------------------------------------------------- /packages/saber-plugin-image/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "saber-plugin-image", 3 | "version": "0.2.2", 4 | "main": "lib/index.js", 5 | "files": [ 6 | "lib" 7 | ], 8 | "license": "MIT", 9 | "dependencies": { 10 | "jimp": "^0.8.0", 11 | "lozad": "^1.9.0", 12 | "responsive-loader": "^1.2.0" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/saber-plugin-meta-redirect/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) EGOIST <0x142857@gmail.com> (https://github.com/egoist) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/saber-plugin-meta-redirect/README.md: -------------------------------------------------------------------------------- 1 | # saber-plugin-meta-redirect 2 | 3 | Generates `` redirect html files for redirecting on any static file host. 4 | 5 | ## Install 6 | 7 | ```bash 8 | yarn add saber-plugin-meta-redirect 9 | ``` 10 | 11 | ## Usage 12 | 13 | In your `saber-config.yml`: 14 | 15 | ```yml 16 | plugins: 17 | - resolve: saber-plugin-meta-redirect 18 | ``` 19 | 20 | In your `saber-node.js`: 21 | 22 | ```js 23 | exports.onCreatePages = function() { 24 | this.pages.createRedirect({ 25 | fromPath: '/about', 26 | toPath: '/about-us' 27 | }) 28 | } 29 | ``` 30 | 31 | Check out the docs for [`pages.createRedirect`](). 32 | 33 | ## License 34 | 35 | MIT. 36 | -------------------------------------------------------------------------------- /packages/saber-plugin-meta-redirect/example/pages/about.md: -------------------------------------------------------------------------------- 1 | This is about 2 | -------------------------------------------------------------------------------- /packages/saber-plugin-meta-redirect/example/pages/index.md: -------------------------------------------------------------------------------- 1 | hello [about](./redirect-to-about) 2 | -------------------------------------------------------------------------------- /packages/saber-plugin-meta-redirect/example/saber-config.yml: -------------------------------------------------------------------------------- 1 | plugins: 2 | - resolve: ../ 3 | 4 | build: 5 | publicUrl: /blog/ 6 | -------------------------------------------------------------------------------- /packages/saber-plugin-meta-redirect/example/saber-node.js: -------------------------------------------------------------------------------- 1 | exports.onCreatePages = function () { 2 | this.pages.createRedirect({ 3 | fromPath: '/redirect-to-about', 4 | toPath: '/about.html', 5 | redirectInBrowser: true 6 | }) 7 | } 8 | -------------------------------------------------------------------------------- /packages/saber-plugin-meta-redirect/lib/index.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | const urlJoin = require('url-join') 3 | 4 | const ID = 'meta-redirect' 5 | 6 | exports.name = ID 7 | 8 | exports.apply = api => { 9 | api.hooks.afterGenerate.tapPromise(ID, async () => { 10 | const { log } = api 11 | const { fs } = api.utils 12 | 13 | const outDir = api.resolveOutDir() 14 | 15 | const getFileNameFromLink = link => { 16 | const filename = link.endsWith('.html') 17 | ? link 18 | : link.replace(/\/?$/, '/index.html') 19 | return path.join(outDir, filename) 20 | } 21 | 22 | const getPageContent = toPath => { 23 | return `` 27 | } 28 | 29 | const writePage = async config => { 30 | const fileName = getFileNameFromLink(config.fromPath) 31 | log.info(`Generating ${path.relative(outDir, fileName)}`) 32 | await fs.outputFile(fileName, getPageContent(config.toPath), 'utf8') 33 | } 34 | 35 | const configs = [...api.pages.redirectRoutes.values()] 36 | await Promise.all(configs.map(config => writePage(config))) 37 | }) 38 | } 39 | -------------------------------------------------------------------------------- /packages/saber-plugin-meta-redirect/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "saber-plugin-meta-redirect", 3 | "version": "0.1.2", 4 | "description": "Generates meta redirect html files for redirecting on any static file host", 5 | "license": "MIT", 6 | "main": "lib/index.js", 7 | "scripts": { 8 | "dev:example": "saber example", 9 | "build:example": "saber build example" 10 | }, 11 | "files": [ 12 | "lib" 13 | ], 14 | "dependencies": { 15 | "url-join": "^4.0.0" 16 | }, 17 | "peerDependencies": { 18 | "saber": ">=0.7.0" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /packages/saber-plugin-netlify-redirect/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) EGOIST <0x142857@gmail.com> (https://github.com/egoist) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/saber-plugin-netlify-redirect/README.md: -------------------------------------------------------------------------------- 1 | # saber-plugin-netlify-redirect 2 | 3 | Automatically generate or update `_redirects` file in your public folder for [Netlify](https://www.netlify.com/docs/redirects/). 4 | 5 | ## Install 6 | 7 | ```bash 8 | yarn add saber-plugin-netlify-redirect 9 | ``` 10 | 11 | ## Usage 12 | 13 | In your `saber-config.yml`: 14 | 15 | ```yml 16 | plugins: 17 | - resolve: saber-plugin-netlify-redirect 18 | ``` 19 | 20 | Then you can create redirects using the [`pages.createRedirect`]() API. 21 | 22 | Since Netlify automatically rewrites routes like `/about` to `/about.html`, this plugin will also create redirects for all `.html` routes so that `/about` will be redirected to `/about.html` when it does not exist. 23 | 24 | ## License 25 | 26 | MIT. 27 | -------------------------------------------------------------------------------- /packages/saber-plugin-netlify-redirect/example/pages/about.md: -------------------------------------------------------------------------------- 1 | This is about 2 | -------------------------------------------------------------------------------- /packages/saber-plugin-netlify-redirect/example/pages/index.md: -------------------------------------------------------------------------------- 1 | hello [about](./redirect-to-about) 2 | -------------------------------------------------------------------------------- /packages/saber-plugin-netlify-redirect/example/public/_redirects: -------------------------------------------------------------------------------- 1 | /foo /bar 301 2 | -------------------------------------------------------------------------------- /packages/saber-plugin-netlify-redirect/example/saber-config.yml: -------------------------------------------------------------------------------- 1 | plugins: 2 | - resolve: ../ 3 | 4 | build: 5 | publicUrl: /blog/ 6 | -------------------------------------------------------------------------------- /packages/saber-plugin-netlify-redirect/example/saber-node.js: -------------------------------------------------------------------------------- 1 | exports.onCreatePages = function () { 2 | this.pages.createRedirect({ 3 | fromPath: '/redirect-to-about', 4 | toPath: '/about.html', 5 | redirectInBrowser: true 6 | }) 7 | } 8 | -------------------------------------------------------------------------------- /packages/saber-plugin-netlify-redirect/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "saber-plugin-netlify-redirect", 3 | "version": "0.1.2", 4 | "description": "Automatically generate or update `_redirects` file in your public folder for Netlify.", 5 | "license": "MIT", 6 | "main": "lib/index.js", 7 | "scripts": { 8 | "dev:example": "saber example", 9 | "build:example": "saber build example" 10 | }, 11 | "files": [ 12 | "lib" 13 | ], 14 | "dependencies": { 15 | "url-join": "^4.0.0" 16 | }, 17 | "peerDependencies": { 18 | "saber": ">=0.7.0" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /packages/saber-plugin-prismjs/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## [0.2.4](https://github.com/saberland/saber/compare/saber-plugin-prismjs@0.2.3...saber-plugin-prismjs@0.2.4) (2019-11-03) 7 | 8 | **Note:** Version bump only for package saber-plugin-prismjs 9 | 10 | ## [0.2.3](https://github.com/saberland/saber/compare/saber-plugin-prismjs@0.2.2...saber-plugin-prismjs@0.2.3) (2019-09-11) 11 | 12 | **Note:** Version bump only for package saber-plugin-prismjs 13 | 14 | ## [0.2.2](https://github.com/saberland/saber/compare/saber-plugin-prismjs@0.2.1...saber-plugin-prismjs@0.2.2) (2019-08-22) 15 | 16 | ### Bug Fixes 17 | 18 | - **pkg:** add missing LICENSE in leaf packages ([9f73603](https://github.com/saberland/saber/commit/9f73603)) 19 | 20 | ## [0.2.1](https://github.com/saberland/saber/compare/saber-plugin-prismjs@0.2.0...saber-plugin-prismjs@0.2.1) (2019-05-29) 21 | 22 | **Note:** Version bump only for package saber-plugin-prismjs 23 | 24 | # 0.2.0 (2019-05-08) 25 | 26 | ### Features 27 | 28 | - add saber-plugin-prismjs ([1bcf1e6](https://github.com/egoist/saber/commit/1bcf1e6)) 29 | -------------------------------------------------------------------------------- /packages/saber-plugin-prismjs/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) EGOIST <0x142857@gmail.com> (https://github.com/egoist) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/saber-plugin-prismjs/README.md: -------------------------------------------------------------------------------- 1 | # saber-plugin-prismjs 2 | 3 | ## How to use 4 | 5 | Install this package: 6 | 7 | ```bash 8 | yarn add prismjs saber-plugin-prismjs saber-highlight-css 9 | ``` 10 | 11 | Note that saber-highlight-css is required for line highlighting to display properly. 12 | 13 | Use it in your `saber-config.yml`: 14 | 15 | ```yaml 16 | plugins: 17 | - resolve: saber-plugin-prismjs 18 | ``` 19 | 20 | ### Include CSS 21 | 22 | In your `saber-browser.js`: 23 | 24 | ```js 25 | import 'prismjs/themes/prism.css' 26 | ``` 27 | 28 | Optional: Include `saber-highlight-css` for line highlighting styles: 29 | 30 | ```bash 31 | yarn add saber-highlight-css 32 | ``` 33 | 34 | ```js 35 | // saber-browser.js 36 | import 'prismjs/themes/prism.css' 37 | import 'saber-highlight-css/default.css' 38 | ``` 39 | 40 | ## License 41 | 42 | MIT © EGOIST 43 | -------------------------------------------------------------------------------- /packages/saber-plugin-prismjs/index.js: -------------------------------------------------------------------------------- 1 | const ID = 'prismjs' 2 | 3 | exports.name = ID 4 | 5 | exports.apply = api => { 6 | api.hooks.chainMarkdown.tap(ID, config => { 7 | config.options.highlight(require('saber-highlighter-prism')) 8 | }) 9 | } 10 | -------------------------------------------------------------------------------- /packages/saber-plugin-prismjs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "saber-plugin-prismjs", 3 | "version": "0.2.4", 4 | "license": "MIT", 5 | "files": [ 6 | "index.js" 7 | ], 8 | "main": "index.js", 9 | "devDependencies": { 10 | "prismjs": "1.17.1" 11 | }, 12 | "peerDependencies": { 13 | "prismjs": "^1.16.0" 14 | }, 15 | "dependencies": { 16 | "saber-highlighter-prism": "^0.3.4" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/saber-plugin-pwa/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) EGOIST <0x142857@gmail.com> (https://github.com/egoist) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/saber-plugin-pwa/lib/create-element.js: -------------------------------------------------------------------------------- 1 | const stringify = require('stringify-attributes') 2 | 3 | module.exports = (tagName, attrs, content) => { 4 | const attrString = stringify(attrs) 5 | return content 6 | ? `<${tagName}${attrString}>${content}` 8 | } 9 | -------------------------------------------------------------------------------- /packages/saber-plugin-pwa/lib/generate-manifest.js: -------------------------------------------------------------------------------- 1 | module.exports = async (api, { name, themeColor, manifest }) => { 2 | const { log } = api 3 | const { fs } = api.utils 4 | 5 | const newManifest = JSON.stringify( 6 | Object.assign( 7 | { 8 | short_name: name, 9 | name, 10 | start_url: './', 11 | display: 'standalone', 12 | theme_color: themeColor, 13 | background_color: '#ffffff' 14 | }, 15 | manifest 16 | ), 17 | null, 18 | 2 19 | ) 20 | 21 | log.info(`Generating manifest.json`) 22 | await fs.outputFile(api.resolveOutDir('manifest.json'), newManifest, 'utf8') 23 | } 24 | -------------------------------------------------------------------------------- /packages/saber-plugin-pwa/lib/get-app-config.js: -------------------------------------------------------------------------------- 1 | const defaults = { 2 | name: 'Saber PWA App', 3 | themeColor: '#ffffff', 4 | assetsVersion: '' 5 | } 6 | 7 | module.exports = (config = {}) => { 8 | return Object.assign({}, defaults, config, { 9 | name: config.name || defaults.name 10 | }) 11 | } 12 | -------------------------------------------------------------------------------- /packages/saber-plugin-pwa/lib/noop-sw-middleware.js: -------------------------------------------------------------------------------- 1 | const resetScript = ` 2 | self.addEventListener('install', function(e) { 3 | self.skipWaiting() 4 | }) 5 | 6 | self.addEventListener('activate', function(e) { 7 | self.registration 8 | .unregister() 9 | .then(function() { 10 | return self.clients.matchAll() 11 | }) 12 | .then(function(clients) { 13 | clients.forEach(client => client.navigate(client.url)) 14 | }) 15 | }) 16 | ` 17 | 18 | module.exports = () => (req, res, next) => { 19 | if (req.path === '/service-worker.js') { 20 | res.setHeader('Content-Type', 'text/javascript') 21 | res.end(resetScript) 22 | } else { 23 | next() 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /packages/saber-plugin-pwa/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "saber-plugin-pwa", 3 | "version": "0.4.4", 4 | "description": "Add PWA support for your Saber app.", 5 | "license": "MIT", 6 | "main": "lib/index.js", 7 | "files": [ 8 | "lib" 9 | ], 10 | "peerDependencies": { 11 | "saber": ">=0.7.0" 12 | }, 13 | "dependencies": { 14 | "@snackbar/core": "^1.6.0", 15 | "stringify-attributes": "^2.0.0", 16 | "workbox-build": "^4.3.1", 17 | "workbox-window": "^4.3.1" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/saber-plugin-query-posts/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) EGOIST <0x142857@gmail.com> (https://github.com/egoist) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/saber-plugin-query-posts/lib/utils.js: -------------------------------------------------------------------------------- 1 | const slugify = require('slugo') 2 | 3 | function paginate(arr, options) { 4 | options = Object.assign({ perPage: 30 }, options) 5 | 6 | if (options.firstPageOnly) { 7 | return [arr.slice(0, options.perPage)] 8 | } 9 | 10 | const totalPages = Math.ceil(arr.length / options.perPage) 11 | const result = [] 12 | for (let i = 0; i < totalPages; i++) { 13 | result[i] = arr.slice(i * options.perPage, (i + 1) * options.perPage) 14 | } 15 | 16 | return result 17 | } 18 | 19 | function getIdFromMap(map, name) { 20 | let id 21 | if (map[name]) { 22 | id = map[name] 23 | } else { 24 | id = slugify(name.replace(/\//g, '-')) 25 | map[name] = id 26 | } 27 | 28 | return id 29 | } 30 | 31 | function getNameFromMap(map, id) { 32 | for (const name of Object.keys(map)) { 33 | if (map[name] === id) { 34 | return name 35 | } 36 | } 37 | 38 | return id 39 | } 40 | 41 | /** 42 | * Render permalink template 43 | * @param {string} permalink 44 | * @param {{[k:string]: string}} data 45 | */ 46 | function renderPermalink(permalink, data) { 47 | for (const key of Object.keys(data)) { 48 | permalink = permalink.replace(`:${key}`, data[key]) 49 | } 50 | 51 | return permalink 52 | } 53 | 54 | module.exports = { 55 | paginate, 56 | getIdFromMap, 57 | getNameFromMap, 58 | renderPermalink 59 | } 60 | -------------------------------------------------------------------------------- /packages/saber-plugin-query-posts/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "saber-plugin-query-posts", 3 | "version": "0.4.6", 4 | "files": [ 5 | "lib" 6 | ], 7 | "main": "lib/index.js", 8 | "keywords": [ 9 | "saber", 10 | "saber-plugin" 11 | ], 12 | "license": "MIT", 13 | "dependencies": { 14 | "slugo": "^0.3.1", 15 | "url-join": "^4.0.0" 16 | }, 17 | "peerDependencies": { 18 | "saber": ">=0.7.0" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /packages/saber-plugin-search/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | # [1.0.0](https://github.com/saberland/saber/compare/saber-plugin-search@0.1.1...saber-plugin-search@1.0.0) (2019-11-03) 7 | 8 | ### Bug Fixes 9 | 10 | - don't strip html from content ([#535](https://github.com/saberland/saber/issues/535)) ([ed1e9be](https://github.com/saberland/saber/commit/ed1e9be)) 11 | 12 | ### BREAKING CHANGES 13 | 14 | - now you get HTML code in your search result, if you don't like that you have to stripe HTML tags yourself. 15 | 16 | - fix: don't strip html from content 17 | 18 | - fix: don't strip html at all 19 | 20 | ## [0.1.1](https://github.com/saberland/saber/compare/saber-plugin-search@0.1.0...saber-plugin-search@0.1.1) (2019-10-05) 21 | 22 | ### Bug Fixes 23 | 24 | - **plugin-search:** generate data on demand ([#492](https://github.com/saberland/saber/issues/492)) ([18dd8b7](https://github.com/saberland/saber/commit/18dd8b7)) 25 | 26 | # 0.1.0 (2019-08-22) 27 | 28 | ### Features 29 | 30 | - add saber-plugin-search ([#366](https://github.com/saberland/saber/issues/366)) ([aaf2d63](https://github.com/saberland/saber/commit/aaf2d63)) 31 | - add saber-plugin-search ([#366](https://github.com/saberland/saber/issues/366)) ([bcd0693](https://github.com/saberland/saber/commit/bcd0693)) 32 | -------------------------------------------------------------------------------- /packages/saber-plugin-search/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) EGOIST <0x142857@gmail.com> (https://github.com/egoist) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/saber-plugin-search/lib/saber-browser.js: -------------------------------------------------------------------------------- 1 | /* eslint-env browser */ 2 | /* globals __PUBLIC_URL__ */ 3 | 4 | export default ({ Vue }) => { 5 | Vue.prototype.$fetchSearchDatabase = function() { 6 | const locale = this.$localePath.slice(1) || 'default' 7 | return window 8 | .fetch(`${__PUBLIC_URL__}_saber/plugin-search/${locale}.json`) 9 | .then(res => res.json()) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/saber-plugin-search/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "saber-plugin-search", 3 | "version": "1.0.0", 4 | "description": "Add a fast search to your app.", 5 | "license": "MIT", 6 | "main": "lib/index.js", 7 | "files": [ 8 | "lib" 9 | ], 10 | "peerDependencies": { 11 | "saber": ">=0.7.0" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /packages/saber-plugin-transformer-html/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) EGOIST <0x142857@gmail.com> (https://github.com/egoist) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/saber-plugin-transformer-html/README.md: -------------------------------------------------------------------------------- 1 | # saber-plugin-transformer-html 2 | 3 | Write pages in HTML. 4 | 5 | ## Install 6 | 7 | ```bash 8 | yarn add saber-plugin-transformer-html 9 | ``` 10 | 11 | ## Usage 12 | 13 | In your `saber-config.yml`: 14 | 15 | ```yml 16 | plugins: 17 | - resolve: saber-plugin-transformer-html 18 | ``` 19 | 20 | Try it by populating a `pages/try.html`: 21 | 22 | ```html 23 | hello world 24 | ``` 25 | 26 | This page will be rendered as `/try.html`. 27 | 28 | Like Markdown pages, you can only use frontmatter to define page data: 29 | 30 | ```html 31 | --- 32 | title: Try it 33 | layout: try 34 | --- 35 | 36 | 37 | 38 | 47 | 48 | 53 | ``` 54 | 55 | ## License 56 | 57 | MIT. 58 | -------------------------------------------------------------------------------- /packages/saber-plugin-transformer-html/example/pages/index.html: -------------------------------------------------------------------------------- 1 | hello there {{ 1+1 }} 2 | 3 | 8 | -------------------------------------------------------------------------------- /packages/saber-plugin-transformer-html/example/saber-config.yml: -------------------------------------------------------------------------------- 1 | plugins: 2 | - resolve: ../ 3 | -------------------------------------------------------------------------------- /packages/saber-plugin-transformer-html/lib/index.js: -------------------------------------------------------------------------------- 1 | const extractSFCBlocks = require('extract-sfc-blocks') 2 | 3 | exports.name = 'transformer-html' 4 | 5 | exports.apply = api => { 6 | api.transformers.add('html', { 7 | extensions: ['html'], 8 | parse(page) { 9 | const { body, frontmatter } = api.transformers.parseFrontmatter( 10 | page.content 11 | ) 12 | const { html, blocks } = extractSFCBlocks(body) 13 | Object.assign(page, frontmatter) 14 | page.content = html 15 | page.internal.hoistedTags = blocks 16 | }, 17 | getPageComponent(page) { 18 | return ` 23 | ` 24 | } 25 | }) 26 | } 27 | -------------------------------------------------------------------------------- /packages/saber-plugin-transformer-html/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "saber-plugin-transformer-html", 3 | "version": "0.1.3", 4 | "description": "Write pages in HTML", 5 | "license": "MIT", 6 | "main": "lib/index.js", 7 | "scripts": { 8 | "dev:example": "saber example", 9 | "build:example": "saber build example" 10 | }, 11 | "files": [ 12 | "lib" 13 | ], 14 | "dependencies": { 15 | "extract-sfc-blocks": "^0.0.2" 16 | }, 17 | "peerDependencies": { 18 | "saber": ">=0.7.0" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /packages/saber-plugin-transformer-pug/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) EGOIST <0x142857@gmail.com> (https://github.com/egoist) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/saber-plugin-transformer-pug/README.md: -------------------------------------------------------------------------------- 1 | # saber-plugin-transformer-pug 2 | 3 | Write pages in Pug and add support for importing Pug files 4 | 5 | ## Install 6 | 7 | ```bash 8 | yarn add saber-plugin-transformer-pug 9 | ``` 10 | 11 | ## Usage 12 | 13 | In your `saber-config.yml`: 14 | 15 | ```yml 16 | plugins: 17 | - resolve: saber-plugin-transformer-pug 18 | ``` 19 | 20 | Try it by populating a `pages/try.pug`: 21 | 22 | ```pug 23 | strong hello world 24 | ``` 25 | 26 | This page will be rendered as `/try.html`. 27 | 28 | Like Markdown pages, you can only use frontmatter to define page data: 29 | 30 | ```pug 31 | --- 32 | title: Try it 33 | layout: try 34 | --- 35 | 36 | strong hello 37 | i world 38 | ``` 39 | 40 | ### Using Pug in Vue SFC template block 41 | 42 | ```vue 43 | 46 | ``` 47 | 48 | ## License 49 | 50 | MIT. 51 | -------------------------------------------------------------------------------- /packages/saber-plugin-transformer-pug/example/pages/about.vue: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /packages/saber-plugin-transformer-pug/example/pages/index.pug: -------------------------------------------------------------------------------- 1 | --- 2 | foo: true 3 | --- 4 | 5 | div 6 | h1 hello 7 | button(@click="count++") {{ count }} 8 | 9 | script. 10 | export default { 11 | data() { 12 | return { 13 | count: 0 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /packages/saber-plugin-transformer-pug/example/saber-config.yml: -------------------------------------------------------------------------------- 1 | plugins: 2 | - resolve: ../ 3 | -------------------------------------------------------------------------------- /packages/saber-plugin-transformer-pug/lib/index.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | const pug = require('pug') 3 | const extractSFCBlocks = require('extract-sfc-blocks') 4 | 5 | const ID = 'transformer-pug' 6 | 7 | exports.name = ID 8 | 9 | exports.apply = api => { 10 | api.transformers.add('pug', { 11 | extensions: ['pug'], 12 | parse(page) { 13 | const { body, frontmatter } = api.transformers.parseFrontmatter( 14 | page.content 15 | ) 16 | const { base: basename, dir: dirname } = path.parse( 17 | page.internal.absolute || '' 18 | ) 19 | const html = pug.render(body, { 20 | filename: basename, 21 | basedir: dirname 22 | }) 23 | const { html: pageContent, blocks } = extractSFCBlocks(html) 24 | Object.assign(page, frontmatter) 25 | page.content = pageContent 26 | page.internal.hoistedTags = blocks 27 | }, 28 | getPageComponent(page) { 29 | return ` 34 | ` 35 | } 36 | }) 37 | 38 | api.hooks.chainWebpack.tap(ID, config => { 39 | config.module 40 | .rule('pug') 41 | .test(/\.pug$/) 42 | .use('pug-loader') 43 | .loader(require.resolve('./pug-plain-loader')) 44 | }) 45 | } 46 | -------------------------------------------------------------------------------- /packages/saber-plugin-transformer-pug/lib/pug-plain-loader.js: -------------------------------------------------------------------------------- 1 | module.exports = function(source, map) { 2 | if ( 3 | this.resourcePath.endsWith('.vue') && 4 | /\?vue&type=template/.test(this.resourceQuery) 5 | ) { 6 | // Transform